Module: Instana::Trace
- Includes:
- OpenTelemetry::Trace
- Defined in:
- lib/instana/trace.rb,
lib/instana/trace/export.rb,
lib/instana/samplers/result.rb,
lib/instana/samplers/samplers.rb,
lib/instana/trace/span_limits.rb,
lib/instana/trace/tracer_provider.rb
Overview
The Trace API allows recording a set of events, triggered as a result of a single logical operation, consolidated across various components of an application.
Defined Under Namespace
Modules: Export, Samplers Classes: SpanLimits, TracerProvider
Constant Summary collapse
- ID_RANGE =
-2**63..2**63 - 1
Class Method Summary collapse
-
.context_with_span(span, parent_context: OpenTelemetry::Context.current) ⇒ Object
Returns a context containing the span, derived from the optional parent context, or the current context if one was not provided.
-
.current_span(context = nil) ⇒ Object
Returns the current span from the current or provided context.
-
.generate_span_id(size = 1) ⇒ Object
Generates a valid span identifier.
-
.generate_trace_id(size = 1) ⇒ Object
Generates a valid trace identifier.
-
.non_recording_span(span_context) ⇒ Span
Wraps a SpanContext with an object implementing the Span interface.
-
.with_span(span) {|span, context| ... } ⇒ Object
Activates/deactivates the Span within the current Context, which makes the “current span” available implicitly.
Class Method Details
.context_with_span(span, parent_context: OpenTelemetry::Context.current) ⇒ Object
Returns a context containing the span, derived from the optional parent context, or the current context if one was not provided.
44 45 46 |
# File 'lib/instana/trace.rb', line 44 def context_with_span(span, parent_context: OpenTelemetry::Context.current) parent_context.set_value(CURRENT_SPAN_KEY, span) end |
.current_span(context = nil) ⇒ Object
Returns the current span from the current or provided context
34 35 36 37 |
# File 'lib/instana/trace.rb', line 34 def current_span(context = nil) context ||= OpenTelemetry::Context.current context.value(CURRENT_SPAN_KEY) || nil end |
.generate_span_id(size = 1) ⇒ Object
Generates a valid span identifier
24 25 26 27 28 |
# File 'lib/instana/trace.rb', line 24 def generate_span_id(size = 1) Array.new(size) { rand(ID_RANGE) } .pack('q>*') .unpack1('H*') end |
.generate_trace_id(size = 1) ⇒ Object
Generates a valid trace identifier
16 17 18 19 20 |
# File 'lib/instana/trace.rb', line 16 def generate_trace_id(size = 1) Array.new(size) { rand(ID_RANGE) } .pack('q>*') .unpack1('H*') end |
.non_recording_span(span_context) ⇒ Span
Wraps a SpanContext with an object implementing the Span interface. This is done in order to expose a SpanContext as a Span in operations such as in-process Span propagation.
65 66 67 |
# File 'lib/instana/trace.rb', line 65 def non_recording_span(span_context) OpenTelemetry::Trace::Span.new(span_context: span_context) end |
.with_span(span) {|span, context| ... } ⇒ Object
Activates/deactivates the Span within the current Context, which makes the “current span” available implicitly.
On exit, the Span that was active before calling this method will be reactivated.
55 56 57 |
# File 'lib/instana/trace.rb', line 55 def with_span(span) OpenTelemetry::Context.with_value(CURRENT_SPAN_KEY, span) { |c, s| yield s, c } end |