class ScoutApm::SlowPolicy::AgePolicy

Constants

POINT_MULTIPLIER_AGE

For each minute we haven't seen an endpoint

Attributes

last_seen[R]

A hash of Endpoint Name to the last time we stored a slow transaction for it.

Defaults to a start time that is pretty close to application boot time. So the “age” of an endpoint we've never seen is the time the application has been running.

Public Class Methods

new(context) click to toggle source
Calls superclass method
# File lib/scout_apm/slow_policy/age_policy.rb, line 15
def initialize(context)
  super

  zero_time = Time.now
  @last_seen = Hash.new { |h, k| h[k] = zero_time }
end

Public Instance Methods

call(request) click to toggle source
# File lib/scout_apm/slow_policy/age_policy.rb, line 22
def call(request)
  # How long has it been since we've seen this?
  age = Time.now - last_seen[request.unique_name]

  age / 60.0 * POINT_MULTIPLIER_AGE
end
stored!(request) click to toggle source
# File lib/scout_apm/slow_policy/age_policy.rb, line 29
def stored!(request)
  last_seen[request.unique_name] = Time.now
end