Sha256: 419543e3ba94ac5ed8debf43b4b18c8875dd81a4ed524b7860251ccb5ac5ce08

Contents?: true

Size: 945 Bytes

Versions: 2

Compression:

Stored size: 945 Bytes

Contents

# frozen_string_literal: false
# typed: false

require_relative '../../../distributed/fetcher'

module Datadog
  module Tracing
    module Contrib
      module HTTP
        module Distributed
          # Retrieves Rack formatted headers from HTTP headers.
          class Fetcher < Tracing::Distributed::Fetcher
            # TODO: Don't assume Rack format.
            #       Make distributed tracing headers apathetic.
            # DEV: Should we try to parse both verbatim an Rack-formatted headers,
            # DEV: given Rack-formatted is the most common format in Ruby?
            def [](name)
              rack_header = "HTTP-#{name}"
              rack_header.upcase!
              rack_header.tr!('-'.freeze, '_'.freeze)

              hdr = super(rack_header)

              # Only return the value if it is not an empty string
              hdr if hdr != ''
            end
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ddtrace-1.8.0 lib/datadog/tracing/contrib/http/distributed/fetcher.rb
ddtrace-1.7.0 lib/datadog/tracing/contrib/http/distributed/fetcher.rb