Sha256: dbb1260ad18809b81c567bd08e22dc5edbc45c7718eca1107603d6468479cad9

Contents?: true

Size: 886 Bytes

Versions: 4

Compression:

Stored size: 886 Bytes

Contents

# frozen_string_literal: true

# Custom patch to temporarily maintain 2.7.x support

module OpenTelemetry
  module Common
    module Propagation
      # The RackEnvGetter class provides a common methods for reading
      # keys from a rack environment. It abstracts away the rack-normalization
      # process so that keys can be looked up without having to transform them
      # first. With this class you can get +traceparent+ instead of
      # +HTTP_TRACEPARENT+
      class RackEnvGetter

        private

        def to_rack_key(key)
          ret = "HTTP_#{key}"
          ret = ret.tr('-', '_')
          ret = ret.upcase
          ret
        end

        def from_rack_key(key)
          start = key.start_with?('HTTP_') ? 5 : 0
          ret = key[start..]
          ret = ret.tr('_', '-')
          ret = ret.downcase!
          ret
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hypertrace-agent-0.3.0 lib/hypertrace/instrumentation/rack_env_getter.rb
hypertrace-agent-0.2.2 lib/hypertrace/instrumentation/rack_env_getter.rb
hypertrace-agent-0.2.1 lib/hypertrace/instrumentation/rack_env_getter.rb
hypertrace-agent-0.1.2 lib/hypertrace/instrumentation/rack_env_getter.rb