Module: Datadog::Tracing::Contrib::Sinatra::Headers
- Defined in:
- lib/datadog/tracing/contrib/sinatra/headers.rb
Overview
Gets and sets trace information from a Rack headers Hash
Class Method Summary collapse
Class Method Details
.response_header_tags(headers, target_headers) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/datadog/tracing/contrib/sinatra/headers.rb', line 13 def (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 |