Class: Jaeger::SpanContext
- Inherits:
-
Object
- Object
- Jaeger::SpanContext
- Defined in:
- lib/jaeger/span_context.rb
Overview
SpanContext holds the data for a span that gets inherited to child spans
Defined Under Namespace
Modules: Flags
Instance Attribute Summary collapse
-
#baggage ⇒ Object
readonly
Returns the value of attribute baggage.
-
#flags ⇒ Object
Returns the value of attribute flags.
-
#parent_id ⇒ Object
readonly
Returns the value of attribute parent_id.
-
#span_id ⇒ Object
readonly
Returns the value of attribute span_id.
-
#trace_id ⇒ Object
readonly
Returns the value of attribute trace_id.
Class Method Summary collapse
Instance Method Summary collapse
- #debug? ⇒ Boolean
- #get_baggage_item(key) ⇒ Object
-
#initialize(span_id:, parent_id: 0, trace_id:, flags:, baggage: {}) ⇒ SpanContext
constructor
A new instance of SpanContext.
- #sampled? ⇒ Boolean
- #set_baggage_item(key, value) ⇒ Object
- #to_span_id ⇒ Object
- #to_trace_id ⇒ Object
Constructor Details
#initialize(span_id:, parent_id: 0, trace_id:, flags:, baggage: {}) ⇒ SpanContext
Returns a new instance of SpanContext.
25 26 27 28 29 30 31 |
# File 'lib/jaeger/span_context.rb', line 25 def initialize(span_id:, parent_id: 0, trace_id:, flags:, baggage: {}) @span_id = span_id @parent_id = parent_id @trace_id = trace_id @baggage = baggage @flags = flags end |
Instance Attribute Details
#baggage ⇒ Object (readonly)
Returns the value of attribute baggage.
22 23 24 |
# File 'lib/jaeger/span_context.rb', line 22 def baggage @baggage end |
#flags ⇒ Object
Returns the value of attribute flags.
22 23 24 |
# File 'lib/jaeger/span_context.rb', line 22 def flags @flags end |
#parent_id ⇒ Object (readonly)
Returns the value of attribute parent_id.
22 23 24 |
# File 'lib/jaeger/span_context.rb', line 22 def parent_id @parent_id end |
#span_id ⇒ Object (readonly)
Returns the value of attribute span_id.
22 23 24 |
# File 'lib/jaeger/span_context.rb', line 22 def span_id @span_id end |
#trace_id ⇒ Object (readonly)
Returns the value of attribute trace_id.
22 23 24 |
# File 'lib/jaeger/span_context.rb', line 22 def trace_id @trace_id end |
Class Method Details
.create_from_parent_context(span_context) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/jaeger/span_context.rb', line 12 def self.create_from_parent_context(span_context) new( trace_id: span_context.trace_id, parent_id: span_context.span_id, span_id: TraceId.generate, flags: span_context.flags, baggage: span_context.baggage.dup ) end |
Instance Method Details
#debug? ⇒ Boolean
37 38 39 |
# File 'lib/jaeger/span_context.rb', line 37 def debug? @flags & Flags::DEBUG == Flags::DEBUG end |
#get_baggage_item(key) ⇒ Object
53 54 55 |
# File 'lib/jaeger/span_context.rb', line 53 def get_baggage_item(key) @baggage[key.to_s] end |
#sampled? ⇒ Boolean
33 34 35 |
# File 'lib/jaeger/span_context.rb', line 33 def sampled? @flags & Flags::SAMPLED == Flags::SAMPLED end |
#set_baggage_item(key, value) ⇒ Object
49 50 51 |
# File 'lib/jaeger/span_context.rb', line 49 def set_baggage_item(key, value) @baggage[key.to_s] = value.to_s end |
#to_span_id ⇒ Object
45 46 47 |
# File 'lib/jaeger/span_context.rb', line 45 def to_span_id @to_span_id ||= @span_id.to_s(16) end |
#to_trace_id ⇒ Object
41 42 43 |
# File 'lib/jaeger/span_context.rb', line 41 def to_trace_id @to_trace_id ||= @trace_id.to_s(16) end |