Class: Jaeger::SpanContext

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(span_id:, trace_id:, flags:, parent_id: 0, 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:, trace_id:, flags:, parent_id: 0, 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.



23
24
25
# File 'lib/jaeger/span_context.rb', line 23

def baggage
  @baggage
end

#flagsObject

Returns the value of attribute flags.



22
23
24
# File 'lib/jaeger/span_context.rb', line 22

def flags
  @flags
end

#parent_idObject (readonly)

Returns the value of attribute parent_id.



23
24
25
# File 'lib/jaeger/span_context.rb', line 23

def parent_id
  @parent_id
end

#span_idObject (readonly)

Returns the value of attribute span_id.



23
24
25
# File 'lib/jaeger/span_context.rb', line 23

def span_id
  @span_id
end

#trace_idObject (readonly)

Returns the value of attribute trace_id.



23
24
25
# File 'lib/jaeger/span_context.rb', line 23

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

Returns:

  • (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

Returns:

  • (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_idObject



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_idObject



41
42
43
# File 'lib/jaeger/span_context.rb', line 41

def to_trace_id
  @to_trace_id ||= @trace_id.to_s(16)
end