Sha256: c42d8b376640b8adb76bd60450bc1e458635ce95e0380751a141d2d9449458d1

Contents?: true

Size: 906 Bytes

Versions: 7

Compression:

Stored size: 906 Bytes

Contents

require 'ddtrace/ext/http'

module Datadog
  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[Datadog::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 }
                result[Datadog::Ext::HTTP::ResponseHeaders.to_tag(header)] = headers[matching_header] if matching_header
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ddtrace-0.51.1 lib/ddtrace/contrib/sinatra/headers.rb
ddtrace-0.51.0 lib/ddtrace/contrib/sinatra/headers.rb
ddtrace-0.50.0 lib/ddtrace/contrib/sinatra/headers.rb
ddtrace-0.49.0 lib/ddtrace/contrib/sinatra/headers.rb
ddtrace-0.48.0 lib/ddtrace/contrib/sinatra/headers.rb
ddtrace-0.47.0 lib/ddtrace/contrib/sinatra/headers.rb
ddtrace-0.46.0 lib/ddtrace/contrib/sinatra/headers.rb