Module: ScoutApm::Rack

Defined in:
lib/scout_apm/rack.rb

Class Method Summary collapse

Class Method Details

.install!Object



3
4
5
6
# File 'lib/scout_apm/rack.rb', line 3

def self.install!
  ScoutApm::Agent.instance.start(:skip_app_server_check => true)
  ScoutApm::Agent.instance.start_background_worker
end

.transaction(endpoint_name, env) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/scout_apm/rack.rb', line 8

def self.transaction(endpoint_name, env)
  req = ScoutApm::RequestManager.lookup
  req.annotate_request(:uri => env["REQUEST_PATH"]) rescue nil
  req.context.add_user(:ip => env["REMOTE_ADDR"]) rescue nil

  layer = ScoutApm::Layer.new('Controller', endpoint_name)
  req.start_layer(layer)

  begin
    yield
  rescue
    req.error!
    raise
  ensure
    req.stop_layer
  end
end