in lib/elastic_apm/opentracing.rb [257:307]
def start_span(
operation_name,
child_of: nil,
references: nil,
start_time: Time.now,
tags: {},
ignore_active_scope: false,
**
)
span_context = prepare_span_context(
child_of: child_of,
references: references,
ignore_active_scope: ignore_active_scope
)
if span_context
trace_context =
span_context.respond_to?(:trace_context) &&
span_context.trace_context
end
elastic_span =
if ElasticAPM.current_transaction
ElasticAPM.start_span(
operation_name,
trace_context: trace_context
)
else
ElasticAPM.start_transaction(
operation_name,
trace_context: trace_context
)
end
unless elastic_span
return ::OpenTracing::Span::NOOP_INSTANCE
end
span_context ||=
SpanContext.from_trace_context(elastic_span.trace_context)
tags.each do |key, value|
elastic_span.context.labels[key] = value
end
elastic_span.start Util.micros(start_time)
Span.new(elastic_span, span_context)
end