Sha256: 564dbd4cba0d1a8b9defd9fd299d608ff9cbb1a54758f57bf8f122eabc54e064

Contents?: true

Size: 1.04 KB

Versions: 12

Compression:

Stored size: 1.04 KB

Contents

# typed: true

require_relative '../../metadata/ext'

module Datadog
  module Tracing
    module Contrib
      module Sinatra
        # Gets and sets trace information from a Rack headers Hash
        module Headers
          module_function

          def response_header_tags(headers, target_headers)
            target_headers ||= []

            {}.tap do |result|
              target_headers.each do |header|
                if headers.key?(header)
                  result[Tracing::Metadata::Ext::HTTP::ResponseHeaders.to_tag(header)] = headers[header]
                else
                  # Try a case-insensitive lookup
                  uppercased_header = header.to_s.upcase
                  matching_header = headers.keys.find { |h| h.upcase == uppercased_header }
                  if matching_header
                    result[Tracing::Metadata::Ext::HTTP::ResponseHeaders.to_tag(header)] = headers[matching_header]
                  end
                end
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ddtrace-1.9.0 lib/datadog/tracing/contrib/sinatra/headers.rb
ddtrace-1.8.0 lib/datadog/tracing/contrib/sinatra/headers.rb
ddtrace-1.7.0 lib/datadog/tracing/contrib/sinatra/headers.rb
ddtrace-1.6.1 lib/datadog/tracing/contrib/sinatra/headers.rb
ddtrace-1.6.0 lib/datadog/tracing/contrib/sinatra/headers.rb
ddtrace-1.5.2 lib/datadog/tracing/contrib/sinatra/headers.rb
ddtrace-1.5.1 lib/datadog/tracing/contrib/sinatra/headers.rb
ddtrace-1.5.0 lib/datadog/tracing/contrib/sinatra/headers.rb
ddtrace-1.4.2 lib/datadog/tracing/contrib/sinatra/headers.rb
ddtrace-1.4.1 lib/datadog/tracing/contrib/sinatra/headers.rb
ddtrace-1.4.0 lib/datadog/tracing/contrib/sinatra/headers.rb
ddtrace-1.3.0 lib/datadog/tracing/contrib/sinatra/headers.rb