Sha256: 01f5c1498eb4f890ee66bb9dd890db5fee7b2a3ffe7e6cb932f7fc13ae250b1b
Contents?: true
Size: 1.15 KB
Versions: 4
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true module Zipkin # SpanContext holds the data for a span that gets inherited to child spans class SpanContext def self.create_parent_context(sampler = Samplers::Const.new(true)) trace_id = TraceId.generate sampled = sampler.sample?(trace_id: trace_id) new(trace_id: trace_id, span_id: trace_id, sampled: sampled) end 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 attr_reader :span_id, :parent_id, :trace_id, :baggage 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 def sampled? @sampled end # NOTE: This method is not defined in OpenTracing Ruby spec. Use with # caution. def to_h { span_id: @span_id, parent_id: @parent_id, trace_id: @trace_id, sampled: @sampled } end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
zipkin-1.6.3 | lib/zipkin/span_context.rb |
zipkin-1.6.2 | lib/zipkin/span_context.rb |
zipkin-1.6.1 | lib/zipkin/span_context.rb |
zipkin-1.6.0 | lib/zipkin/span_context.rb |