Sha256: 4c9df7fbcda89b8f85cea105c8bf59419e7ad9af8c87f14dea5cd50be1c8a548

Contents?: true

Size: 1.71 KB

Versions: 2

Compression:

Stored size: 1.71 KB

Contents

# frozen_string_literal: true

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

require 'opentelemetry/correlation_context/propagation/context_keys'
require 'opentelemetry/correlation_context/propagation/text_injector'
require 'opentelemetry/correlation_context/propagation/text_extractor'

module OpenTelemetry
  module CorrelationContext
    # The Correlation::Propagation module contains injectors and
    # extractors for sending and receiving correlation context over the wire
    module Propagation
      extend self

      TEXT_EXTRACTOR = TextExtractor.new
      TEXT_INJECTOR = TextInjector.new
      RACK_EXTRACTOR = TextExtractor.new(
        correlation_context_key: 'HTTP_CORRELATION_CONTEXT'
      )
      RACK_INJECTOR = TextInjector.new(
        correlation_context_key: 'HTTP_CORRELATION_CONTEXT'
      )

      private_constant :TEXT_INJECTOR, :TEXT_EXTRACTOR, :RACK_INJECTOR,
                       :RACK_EXTRACTOR

      # Returns an extractor that extracts context using the W3C Correlation
      # Context format
      def text_injector
        TEXT_INJECTOR
      end

      # Returns an injector that injects context using the W3C Correlation
      # Context format
      def text_extractor
        TEXT_EXTRACTOR
      end

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
opentelemetry-api-0.4.0 lib/opentelemetry/correlation_context/propagation.rb
opentelemetry-api-0.3.0 lib/opentelemetry/correlation_context/propagation.rb