class ElasticAPM::OpenTracing::Span

def finish(end_time: Time.now)

def finish(end_time: Time.now)
  return unless (agent = ElasticAPM.agent)
  elastic_span.done clock_end: Util.micros(end_time)
  case elastic_span
  when ElasticAPM::Transaction
    agent.instrumenter.current_transaction = nil
  when ElasticAPM::Span
    agent.instrumenter.current_spans.delete(elastic_span)
  end
  agent.enqueue elastic_span
end