Class: LightStep::SpanContext
- Inherits:
-
Object
- Object
- LightStep::SpanContext
- Defined in:
- lib/lightstep/span_context.rb
Overview
SpanContext holds the data for a span that gets inherited to child spans
Constant Summary collapse
- ZERO_PADDING =
'0' * 16
Instance Attribute Summary collapse
-
#baggage ⇒ Object
readonly
Returns the value of attribute baggage.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#sampled ⇒ Object
(also: #sampled?)
readonly
Returns the value of attribute sampled.
-
#trace_id ⇒ Object
(also: #trace_id64)
readonly
Returns the value of attribute trace_id.
-
#trace_id_upper64 ⇒ Object
readonly
Returns the value of attribute trace_id_upper64.
Instance Method Summary collapse
-
#id_truncated? ⇒ Boolean
Returns true if the original trace_id was 128 bits.
-
#initialize(id:, trace_id:, trace_id_upper64: nil, sampled: true, baggage: {}) ⇒ SpanContext
constructor
A new instance of SpanContext.
-
#trace_id128 ⇒ Object
Lazily initializes and returns a 128-bit representation of a 64-bit trace id.
Constructor Details
#initialize(id:, trace_id:, trace_id_upper64: nil, sampled: true, baggage: {}) ⇒ SpanContext
Returns a new instance of SpanContext.
12 13 14 15 16 17 18 |
# File 'lib/lightstep/span_context.rb', line 12 def initialize(id:, trace_id:, trace_id_upper64: nil, sampled: true, baggage: {}) @id = id.freeze @trace_id = truncate_id(trace_id).freeze @trace_id_upper64 = trace_id_upper64 || extended_bits(trace_id).freeze @sampled = sampled @baggage = baggage.freeze end |
Instance Attribute Details
#baggage ⇒ Object (readonly)
Returns the value of attribute baggage.
6 7 8 |
# File 'lib/lightstep/span_context.rb', line 6 def baggage @baggage end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/lightstep/span_context.rb', line 6 def id @id end |
#sampled ⇒ Object (readonly) Also known as: sampled?
Returns the value of attribute sampled.
6 7 8 |
# File 'lib/lightstep/span_context.rb', line 6 def sampled @sampled end |
#trace_id ⇒ Object (readonly) Also known as: trace_id64
Returns the value of attribute trace_id.
6 7 8 |
# File 'lib/lightstep/span_context.rb', line 6 def trace_id @trace_id end |
#trace_id_upper64 ⇒ Object (readonly)
Returns the value of attribute trace_id_upper64.
6 7 8 |
# File 'lib/lightstep/span_context.rb', line 6 def trace_id_upper64 @trace_id_upper64 end |
Instance Method Details
#id_truncated? ⇒ Boolean
Returns true if the original trace_id was 128 bits
26 27 28 |
# File 'lib/lightstep/span_context.rb', line 26 def id_truncated? !@trace_id_upper64.nil? end |
#trace_id128 ⇒ Object
Lazily initializes and returns a 128-bit representation of a 64-bit trace id
21 22 23 |
# File 'lib/lightstep/span_context.rb', line 21 def trace_id128 @trace_id128 ||= "#{trace_id_upper64 || ZERO_PADDING}#{trace_id}" end |