Class: Datadog::Profiling::TraceIdentifiers::Ddtrace
- Inherits:
-
Object
- Object
- Datadog::Profiling::TraceIdentifiers::Ddtrace
- Defined in:
- lib/ddtrace/profiling/trace_identifiers/ddtrace.rb
Overview
Used by Datadog::Profiling::TraceIdentifiers::Helper to get the trace identifiers (trace id and span id) for a given thread, if there is an active trace for that thread in Datadog.tracer.
Instance Method Summary collapse
-
#initialize(tracer: nil) ⇒ Ddtrace
constructor
A new instance of Ddtrace.
- #trace_identifiers_for(thread) ⇒ Object
Constructor Details
#initialize(tracer: nil) ⇒ Ddtrace
12 13 14 |
# File 'lib/ddtrace/profiling/trace_identifiers/ddtrace.rb', line 12 def initialize(tracer: nil) @tracer = (tracer if tracer.respond_to?(:call_context)) end |
Instance Method Details
#trace_identifiers_for(thread) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ddtrace/profiling/trace_identifiers/ddtrace.rb', line 16 def trace_identifiers_for(thread) return unless @tracer context = @tracer.call_context(thread) return unless context trace_id = context.trace_id || 0 span_id = context.span_id || 0 [trace_id, span_id, maybe_extract_resource(context.current_root_span)] if trace_id != 0 && span_id != 0 end |