Sha256: dccad7caa152d6c6d9043c7b1c61071bb6d1b7bf5129583856031328b005c53d

Contents?: true

Size: 873 Bytes

Versions: 3

Compression:

Stored size: 873 Bytes

Contents

module Test
  class SpanContext < OpenTracing::SpanContext
    class << self
      def root
        new(trace_id: IdProvider.generate,
            span_id: IdProvider.generate)
      end

      def child_of(parent_context)
        new(trace_id: parent_context.trace_id,
            span_id: IdProvider.generate,
            parent_span_id: parent_context.span_id,
            baggage: parent_context.baggage)
      end
    end

    include TypeCheck

    attr_reader :trace_id, :span_id, :parent_span_id

    def initialize(trace_id:, span_id:, parent_span_id: nil, baggage: {})
      Type! trace_id, String
      Type! span_id, String
      Type! parent_span_id, String, NilClass
      Type! baggage, Hash

      super(baggage: baggage)

      @trace_id = trace_id
      @span_id = span_id
      @parent_span_id = parent_span_id
      @baggage = baggage
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
test-tracer-1.1.1 lib/test/span_context.rb
test-tracer-1.1.0 lib/test/span_context.rb
test-tracer-1.0.0 lib/test/span_context.rb