Class: Jaeger::Client::SpanContext

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(span_id:, parent_id: 0, trace_id:, flags:, baggage: {}) ⇒ SpanContext

Returns a new instance of SpanContext.



27
28
29
30
31
32
33
# File 'lib/jaeger/client/span_context.rb', line 27

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

#baggageObject (readonly)

Returns the value of attribute baggage.



25
26
27
# File 'lib/jaeger/client/span_context.rb', line 25

def baggage
  @baggage
end

#flagsObject (readonly)

Returns the value of attribute flags.



25
26
27
# File 'lib/jaeger/client/span_context.rb', line 25

def flags
  @flags
end

#parent_idObject (readonly)

Returns the value of attribute parent_id.



25
26
27
# File 'lib/jaeger/client/span_context.rb', line 25

def parent_id
  @parent_id
end

#span_idObject (readonly)

Returns the value of attribute span_id.



25
26
27
# File 'lib/jaeger/client/span_context.rb', line 25

def span_id
  @span_id
end

#trace_idObject (readonly)

Returns the value of attribute trace_id.



25
26
27
# File 'lib/jaeger/client/span_context.rb', line 25

def trace_id
  @trace_id
end

Class Method Details

.create_from_parent_context(span_context) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/jaeger/client/span_context.rb', line 17

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_contextObject



10
11
12
13
14
15
# File 'lib/jaeger/client/span_context.rb', line 10

def self.create_parent_context
  trace_id = TraceId.generate
  span_id = TraceId.generate
  flags = Flags::SAMPLED
  new(trace_id: trace_id, span_id: span_id, flags: flags)
end

Instance Method Details

#inspectObject



35
36
37
# File 'lib/jaeger/client/span_context.rb', line 35

def inspect
  to_s
end

#to_sObject



39
40
41
42
43
44
# File 'lib/jaeger/client/span_context.rb', line 39

def to_s
  "#<SpanContext @span_id=#{span_id.to_s(16)} " +
    "@parent_id=#{parent_id.to_s(16)} " +
    "@trace_id=#{trace_id.to_s(16)} " +
    "@flags=#{flags}>"
end