def end_segment(end_time: nil)
      segment = current_segment
      return unless segment
      segment.close end_time: end_time
      context.clear!
      emitter.send_entity entity: segment if segment.ready_to_send?
    end
def end_segment(end_time: nil)
      segment = current_segment
      return unless segment
      segment.close end_time: end_time
      context.clear!
      emitter.send_entity entity: segment if segment.ready_to_send?
    end
End the current segment and send it to X-Ray daemon if it is ready.