Sha256: fb1a0a56c99eb8e04d2f6c877853bb907add4c2d3b74f9266a08fede66f17ee4

Contents?: true

Size: 1.85 KB

Versions: 4

Compression:

Stored size: 1.85 KB

Contents

# frozen_string_literal: true

# Copyright The OpenTelemetry Authors
#
# SPDX-License-Identifier: Apache-2.0

require 'opentelemetry/trace/propagation/trace_context/trace_parent'
require 'opentelemetry/trace/propagation/trace_context/text_map_extractor'
require 'opentelemetry/trace/propagation/trace_context/text_map_injector'

module OpenTelemetry
  module Trace
    module Propagation
      # The TraceContext module contains injectors, extractors, and utilties
      # for context propagation in the W3C Trace Context format.
      module TraceContext
        extend self

        TEXT_MAP_EXTRACTOR = TextMapExtractor.new
        TEXT_MAP_INJECTOR = TextMapInjector.new
        RACK_EXTRACTOR = TextMapExtractor.new(
          traceparent_key: 'HTTP_TRACEPARENT',
          tracestate_key: 'HTTP_TRACESTATE'
        )
        RACK_INJECTOR = TextMapInjector.new(
          traceparent_key: 'HTTP_TRACEPARENT',
          tracestate_key: 'HTTP_TRACESTATE'
        )

        private_constant :TEXT_MAP_INJECTOR, :TEXT_MAP_EXTRACTOR,
                         :RACK_INJECTOR, :RACK_EXTRACTOR

        # Returns an extractor that extracts context using the W3C Trace Context
        # format
        def text_map_extractor
          TEXT_MAP_EXTRACTOR
        end

        # Returns an injector that injects context using the W3C Trace Context
        # format
        def text_map_injector
          TEXT_MAP_INJECTOR
        end

        # Returns an extractor that extracts context using the W3C Trace Context
        # with Rack normalized keys (upcased and prefixed with HTTP_)
        def rack_extractor
          RACK_EXTRACTOR
        end

        # Returns an injector that injects context using the W3C Trace Context
        # format with Rack normalized keys (upcased and prefixed with HTTP_)
        def rack_injector
          RACK_INJECTOR
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
opentelemetry-api-0.13.0 lib/opentelemetry/trace/propagation/trace_context.rb
opentelemetry-api-0.12.1 lib/opentelemetry/trace/propagation/trace_context.rb
opentelemetry-api-0.12.0 lib/opentelemetry/trace/propagation/trace_context.rb
opentelemetry-api-0.11.0 lib/opentelemetry/trace/propagation/trace_context.rb