def capture(name, namespace: nil, segment: nil)
      subsegment = begin_subsegment name, namespace: namespace, segment: segment
      # prevent passed block from failing in case of context missing with log error
      if subsegment.nil?
        segment = DummySegment.new name: name
        subsegment = DummySubsegment.new name: name, segment: segment
      end

      begin
        yield subsegment
      rescue Exception => e
        subsegment.add_exception exception: e
        raise e
      ensure
        end_subsegment
      end
    end
def capture(name, namespace: nil, segment: nil)
      subsegment = begin_subsegment name, namespace: namespace, segment: segment
      # prevent passed block from failing in case of context missing with log error
      if subsegment.nil?
        segment = DummySegment.new name: name
        subsegment = DummySubsegment.new name: name, segment: segment
      end

      begin
        yield subsegment
      rescue Exception => e
        subsegment.add_exception exception: e
        raise e
      ensure
        end_subsegment
      end
    end
Record the passed block as a subsegment.
 If `context_missing` is set to `LOG_ERROR` and no active entity can be found,
 the passed block will be executed as normal but it will not be recorded.