Class: ScoutApm::RequestManager

Inherits:
Object
  • Object
show all
Defined in:
lib/scout_apm/request_manager.rb

Class Method Summary collapse

Class Method Details

.createObject

Create a new TrackedRequest object for this thread



22
23
24
25
26
27
28
29
30
# File 'lib/scout_apm/request_manager.rb', line 22

def self.create
  store = if ScoutApm::Agent.instance.apm_enabled?
            ScoutApm::Agent.instance.store
          else
            ScoutApm::FakeStore.new
          end

  Thread.current[:scout_request] = TrackedRequest.new(store)
end

.findObject

Get the current Thread local, and detecting, and not returning a stale request



11
12
13
14
15
16
17
18
19
# File 'lib/scout_apm/request_manager.rb', line 11

def self.find
  req = Thread.current[:scout_request]

  if req && (req.stopping? || req.recorded?)
    nil
  else
    req
  end
end

.lookupObject



6
7
8
# File 'lib/scout_apm/request_manager.rb', line 6

def self.lookup
  find || create
end