Class: Jaeger::Client::SpanContext
- Inherits:
-
Object
- Object
- Jaeger::Client::SpanContext
- Defined in:
- lib/jaeger/client/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
readonly
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
- .create_from_parent_context(span_context) ⇒ Object
- .create_parent_context(sampler = Samplers::Const.new(true)) ⇒ Object
Instance Method Summary collapse
- #debug? ⇒ Boolean
-
#initialize(span_id:, parent_id: 0, trace_id:, flags:, baggage: {}) ⇒ SpanContext
constructor
A new instance of SpanContext.
- #sampled? ⇒ Boolean
- #to_parent_id ⇒ 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.
30 31 32 33 34 35 36 |
# File 'lib/jaeger/client/span_context.rb', line 30 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.
28 29 30 |
# File 'lib/jaeger/client/span_context.rb', line 28 def baggage @baggage end |
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
28 29 30 |
# File 'lib/jaeger/client/span_context.rb', line 28 def flags @flags end |
#parent_id ⇒ Object (readonly)
Returns the value of attribute parent_id.
28 29 30 |
# File 'lib/jaeger/client/span_context.rb', line 28 def parent_id @parent_id end |
#span_id ⇒ Object (readonly)
Returns the value of attribute span_id.
28 29 30 |
# File 'lib/jaeger/client/span_context.rb', line 28 def span_id @span_id end |
#trace_id ⇒ Object (readonly)
Returns the value of attribute trace_id.
28 29 30 |
# File 'lib/jaeger/client/span_context.rb', line 28 def trace_id @trace_id end |
Class Method Details
.create_from_parent_context(span_context) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/jaeger/client/span_context.rb', line 20 def self.create_from_parent_context(span_context) trace_id = span_context.trace_id parent_id = span_context.span_id flags = span_context.flags span_id = TraceId.generate new(span_id: span_id, parent_id: parent_id, trace_id: trace_id, flags: flags) end |
.create_parent_context(sampler = Samplers::Const.new(true)) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/jaeger/client/span_context.rb', line 13 def self.create_parent_context(sampler = Samplers::Const.new(true)) trace_id = TraceId.generate span_id = TraceId.generate flags = sampler.sample?(trace_id) ? Flags::SAMPLED : Flags::NONE new(trace_id: trace_id, span_id: span_id, flags: flags) end |
Instance Method Details
#debug? ⇒ Boolean
42 43 44 |
# File 'lib/jaeger/client/span_context.rb', line 42 def debug? @flags & Flags::DEBUG == Flags::DEBUG end |
#sampled? ⇒ Boolean
38 39 40 |
# File 'lib/jaeger/client/span_context.rb', line 38 def sampled? @flags & Flags::SAMPLED == Flags::SAMPLED end |
#to_parent_id ⇒ Object
50 51 52 |
# File 'lib/jaeger/client/span_context.rb', line 50 def to_parent_id @to_parent_id ||= @parent_id.zero? ? nil : @parent_id.to_s(16) end |
#to_span_id ⇒ Object
54 55 56 |
# File 'lib/jaeger/client/span_context.rb', line 54 def to_span_id @to_span_id ||= @span_id.to_s(16) end |
#to_trace_id ⇒ Object
46 47 48 |
# File 'lib/jaeger/client/span_context.rb', line 46 def to_trace_id @to_trace_id ||= @trace_id.to_s(16) end |