Class: Zipkin::SpanContext

Inherits:
Object
  • Object
show all
Defined in:
lib/zipkin/span_context.rb

Overview

SpanContext holds the data for a span that gets inherited to child spans

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(span_id:, parent_id: nil, trace_id:, sampled:, baggage: {}) ⇒ SpanContext

Returns a new instance of SpanContext.



20
21
22
23
24
25
26
# File 'lib/zipkin/span_context.rb', line 20

def initialize(span_id:, parent_id: nil, trace_id:, sampled:, baggage: {})
  @span_id = span_id
  @parent_id = parent_id
  @trace_id = trace_id
  @sampled = sampled
  @baggage = baggage
end

Instance Attribute Details

#baggageObject (readonly)

Returns the value of attribute baggage.



18
19
20
# File 'lib/zipkin/span_context.rb', line 18

def baggage
  @baggage
end

#parent_idObject (readonly)

Returns the value of attribute parent_id.



18
19
20
# File 'lib/zipkin/span_context.rb', line 18

def parent_id
  @parent_id
end

#span_idObject (readonly)

Returns the value of attribute span_id.



18
19
20
# File 'lib/zipkin/span_context.rb', line 18

def span_id
  @span_id
end

#trace_idObject (readonly)

Returns the value of attribute trace_id.



18
19
20
# File 'lib/zipkin/span_context.rb', line 18

def trace_id
  @trace_id
end

Class Method Details

.create_from_parent_context(span_context) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/zipkin/span_context.rb', line 9

def self.create_from_parent_context(span_context)
  new(
    span_id: TraceId.generate,
    parent_id: span_context.span_id,
    trace_id: span_context.trace_id,
    sampled: span_context.sampled?
  )
end

.create_parent_contextObject



4
5
6
7
# File 'lib/zipkin/span_context.rb', line 4

def self.create_parent_context
  trace_id = TraceId.generate
  new(trace_id: trace_id, span_id: trace_id, sampled: true)
end

Instance Method Details

#sampled?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/zipkin/span_context.rb', line 28

def sampled?
  @sampled
end