Class: OpenTelemetry::Trace::SpanContext
- Inherits:
-
Object
- Object
- OpenTelemetry::Trace::SpanContext
- Defined in:
- lib/opentelemetry/trace/span_context.rb
Overview
A SpanContext contains the state that must propagate to child Spans and across process boundaries. It contains the identifiers (a trace ID and span ID) associated with the Span, a set of TraceFlags, a system-specific tracestate, and a boolean indicating that the SpanContext was extracted from the wire.
Constant Summary collapse
- INVALID =
Represents an invalid OpenTelemetry::Trace::SpanContext, with an invalid trace ID and an invalid span ID.
new(trace_id: INVALID_TRACE_ID, span_id: INVALID_SPAN_ID)
Instance Attribute Summary collapse
-
#span_id ⇒ String
readonly
Returns the binary representation of the span ID.
-
#trace_flags ⇒ Object
readonly
Returns the value of attribute trace_flags.
-
#trace_id ⇒ String
readonly
Returns the binary representation of the trace ID.
-
#tracestate ⇒ Object
readonly
Returns the value of attribute tracestate.
Instance Method Summary collapse
-
#hex_span_id ⇒ String
Returns the lowercase hex encoded span ID.
-
#hex_trace_id ⇒ String
Returns the lowercase hex encoded trace ID.
-
#initialize(trace_id: Trace.generate_trace_id, span_id: Trace.generate_span_id, trace_flags: TraceFlags::DEFAULT, tracestate: Tracestate::DEFAULT, remote: false) ⇒ SpanContext
constructor
Returns a new SpanContext.
-
#remote? ⇒ Boolean
Returns true if the SpanContext was propagated from a remote parent.
-
#valid? ⇒ Boolean
Returns true if the SpanContext has a non-zero trace ID and non-zero span ID.
Constructor Details
#initialize(trace_id: Trace.generate_trace_id, span_id: Trace.generate_span_id, trace_flags: TraceFlags::DEFAULT, tracestate: Tracestate::DEFAULT, remote: false) ⇒ SpanContext
Returns a new OpenTelemetry::Trace::SpanContext.
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/opentelemetry/trace/span_context.rb', line 24 def initialize( trace_id: Trace.generate_trace_id, span_id: Trace.generate_span_id, trace_flags: TraceFlags::DEFAULT, tracestate: Tracestate::DEFAULT, remote: false ) @trace_id = trace_id @span_id = span_id @trace_flags = trace_flags @tracestate = tracestate @remote = remote end |
Instance Attribute Details
#span_id ⇒ String (readonly)
Returns the binary representation of the span ID.
60 61 62 |
# File 'lib/opentelemetry/trace/span_context.rb', line 60 def span_id @span_id end |
#trace_flags ⇒ Object (readonly)
Returns the value of attribute trace_flags.
14 15 16 |
# File 'lib/opentelemetry/trace/span_context.rb', line 14 def trace_flags @trace_flags end |
#trace_id ⇒ String (readonly)
Returns the binary representation of the trace ID.
55 56 57 |
# File 'lib/opentelemetry/trace/span_context.rb', line 55 def trace_id @trace_id end |
#tracestate ⇒ Object (readonly)
Returns the value of attribute tracestate.
14 15 16 |
# File 'lib/opentelemetry/trace/span_context.rb', line 14 def tracestate @tracestate end |
Instance Method Details
#hex_span_id ⇒ String
Returns the lowercase hex encoded span ID.
48 49 50 |
# File 'lib/opentelemetry/trace/span_context.rb', line 48 def hex_span_id @span_id.unpack1('H*') end |
#hex_trace_id ⇒ String
Returns the lowercase hex encoded trace ID.
41 42 43 |
# File 'lib/opentelemetry/trace/span_context.rb', line 41 def hex_trace_id @trace_id.unpack1('H*') end |
#remote? ⇒ Boolean
Returns true if the OpenTelemetry::Trace::SpanContext was propagated from a remote parent.
72 73 74 |
# File 'lib/opentelemetry/trace/span_context.rb', line 72 def remote? @remote end |
#valid? ⇒ Boolean
Returns true if the OpenTelemetry::Trace::SpanContext has a non-zero trace ID and non-zero span ID.
65 66 67 |
# File 'lib/opentelemetry/trace/span_context.rb', line 65 def valid? @trace_id != INVALID_TRACE_ID && @span_id != INVALID_SPAN_ID end |