class ElasticAPM::Span

def stop(clock_end = Util.monotonic_micros)

def stop(clock_end = Util.monotonic_micros)
  @duration ||= (clock_end - @clock_start)
  @parent.child_stopped
  @self_time = @duration - child_durations.duration
  if exit_span?
    context.destination ||= Context::Destination.new
    context.destination.service ||= Context::Destination::Service.new
    context.destination.service.resource ||= (subtype || type)
    # Deprecated fields but required by some versions of APM Server, so
    # we auto-infer them from existing fields
    context.destination.service.name ||= (subtype || type)
    context.destination.service.type ||= type
  end
  self
end