Class: OpenTracing::Instrumentation::Rack::HttpTagger
- Inherits:
-
Object
- Object
- OpenTracing::Instrumentation::Rack::HttpTagger
- Defined in:
- lib/opentracing/instrumentation/rack/http_tagger.rb
Overview
HttpTagger create addition tags on span
Constant Summary collapse
- DEFAULT_TAG_REQUEST_HEADERS =
{ connection: 'Connection', content_type: 'Content-Type', user_agent: 'User-Agent', }.freeze
- DEFAULT_TAG_RESPONSE_HEADERS =
{ connection: 'Connection', content_type: 'Content-Type', keep_alive: 'Keep-Alive', }.freeze
Instance Method Summary collapse
-
#initialize(tag_request_headers: DEFAULT_TAG_REQUEST_HEADERS, tag_response_headers: DEFAULT_TAG_RESPONSE_HEADERS) ⇒ HttpTagger
constructor
A new instance of HttpTagger.
- #request_tags(env) ⇒ Object
- #response_tags(headers) ⇒ Object
Constructor Details
#initialize(tag_request_headers: DEFAULT_TAG_REQUEST_HEADERS, tag_response_headers: DEFAULT_TAG_RESPONSE_HEADERS) ⇒ HttpTagger
Returns a new instance of HttpTagger.
22 23 24 25 26 27 28 29 30 |
# File 'lib/opentracing/instrumentation/rack/http_tagger.rb', line 22 def initialize( tag_request_headers: DEFAULT_TAG_REQUEST_HEADERS, tag_response_headers: DEFAULT_TAG_RESPONSE_HEADERS ) @tag_request_headers = prepare_request_mapping(tag_request_headers) @tag_response_headers = prepare_response_mapping(tag_response_headers) end |
Instance Method Details
#request_tags(env) ⇒ Object
32 33 34 35 36 |
# File 'lib/opentracing/instrumentation/rack/http_tagger.rb', line 32 def (env) @tag_request_headers .transform_values { |header_name| env[header_name] } .compact end |
#response_tags(headers) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/opentracing/instrumentation/rack/http_tagger.rb', line 38 def (headers) header_mapper = lambda do |header_regexp| headers.find do |(header, _value)| header_regexp.match?(header) end&.dig(1) end @tag_response_headers .transform_values(&header_mapper) .compact end |