lib/jaeger/client/span_context.rb in jaeger-client-0.7.1 vs lib/jaeger/client/span_context.rb in jaeger-client-0.8.0

- old
+ new

@@ -16,18 +16,21 @@ flags = sampler.sample?(trace_id) ? Flags::SAMPLED : Flags::NONE new(trace_id: trace_id, span_id: span_id, flags: flags) end 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) + 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 attr_reader :span_id, :parent_id, :trace_id, :baggage, :flags + attr_writer :flags def initialize(span_id:, parent_id: 0, trace_id:, flags:, baggage: {}) @span_id = span_id @parent_id = parent_id @trace_id = trace_id @@ -45,15 +48,19 @@ def to_trace_id @to_trace_id ||= @trace_id.to_s(16) end - def to_parent_id - @to_parent_id ||= @parent_id.zero? ? nil : @parent_id.to_s(16) - end - def to_span_id @to_span_id ||= @span_id.to_s(16) + end + + def set_baggage_item(key, value) + @baggage[key.to_s] = value.to_s + end + + def get_baggage_item(key) + @baggage[key.to_s] end end end end