Module: Datadog::Contrib::Sinatra::Env
- Defined in:
- lib/ddtrace/contrib/sinatra/env.rb
Overview
Gets and sets trace information from a Rack Env
Class Method Summary collapse
- .datadog_span(env) ⇒ Object
- .header_to_rack_header(name) ⇒ Object
- .request_header_tags(env, headers) ⇒ Object
- .set_datadog_span(env, span) ⇒ Object
Class Method Details
.datadog_span(env) ⇒ Object
11 12 13 |
# File 'lib/ddtrace/contrib/sinatra/env.rb', line 11 def datadog_span(env) env[Ext::RACK_ENV_REQUEST_SPAN] end |
.header_to_rack_header(name) ⇒ Object
32 33 34 |
# File 'lib/ddtrace/contrib/sinatra/env.rb', line 32 def header_to_rack_header(name) "HTTP_#{name.to_s.upcase.gsub(/[-\s]/, '_')}" end |
.request_header_tags(env, headers) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ddtrace/contrib/sinatra/env.rb', line 19 def (env, headers) headers ||= [] {}.tap do |result| headers.each do |header| rack_header = header_to_rack_header(header) if env.key?(rack_header) result[Datadog::Ext::HTTP::RequestHeaders.to_tag(header)] = env[rack_header] end end end end |
.set_datadog_span(env, span) ⇒ Object
15 16 17 |
# File 'lib/ddtrace/contrib/sinatra/env.rb', line 15 def set_datadog_span(env, span) env[Ext::RACK_ENV_REQUEST_SPAN] = span end |