Module: Datadog::Tracing::Contrib::Sinatra::Env

Defined in:
lib/datadog/tracing/contrib/sinatra/env.rb

Overview

Gets and sets trace information from a Rack Env

Class Method Summary collapse

Class Method Details

.datadog_span(env) ⇒ Object



16
17
18
# File 'lib/datadog/tracing/contrib/sinatra/env.rb', line 16

def datadog_span(env)
  env[Ext::RACK_ENV_SINATRA_REQUEST_SPAN]
end

.route_path(env, use_script_names: Datadog.configuration.tracing[:sinatra]) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/datadog/tracing/contrib/sinatra/env.rb', line 24

def route_path(env, use_script_names: Datadog.configuration.tracing[:sinatra][:resource_script_names])
  return unless env['sinatra.route']

  _, path = env['sinatra.route'].split(' ', 2)
  if use_script_names
    env['SCRIPT_NAME'].to_s + path
  else
    path
  end
end

.set_datadog_span(env, span) ⇒ Object



20
21
22
# File 'lib/datadog/tracing/contrib/sinatra/env.rb', line 20

def set_datadog_span(env, span)
  env[Ext::RACK_ENV_SINATRA_REQUEST_SPAN] = span
end