def begin_subsegment(name, namespace: nil, segment: nil)
      entity = segment || current_entity
      return unless entity
      if entity.sampled
        subsegment = Subsegment.new name: name, segment: entity.segment, namespace: namespace
      else
        subsegment = DummySubsegment.new name: name, segment: entity.segment
      end
      # attach the new created subsegment under the current active entity
      entity.add_subsegment subsegment: subsegment
      # associate the new subsegment to the current context
      context.store_entity entity: subsegment
      subsegment
    end
def begin_subsegment(name, namespace: nil, segment: nil)
      entity = segment || current_entity
      return unless entity
      if entity.sampled
        subsegment = Subsegment.new name: name, segment: entity.segment, namespace: namespace
      else
        subsegment = DummySubsegment.new name: name, segment: entity.segment
      end
      # attach the new created subsegment under the current active entity
      entity.add_subsegment subsegment: subsegment
      # associate the new subsegment to the current context
      context.store_entity entity: subsegment
      subsegment
    end
Begin a new subsegment and add it to be the child of the current active
 subsegment or segment. Also tie the new created subsegment to the current context.
 Its sampling decision will follow its parent.
 @return [Subsegment] the newly created subsegment. It could be `nil` if no active entity
   can be found and `context_missing` is set to `LOG_ERROR`.