class HeimdallApm::MetricStats

Stats associated with a single metric (used in metrics Hashs as value where keys are the metrics names)

Attributes

call_count[RW]
max_call_time[RW]
min_call_time[RW]
total_call_time[RW]
total_exclusive_time[RW]

Public Class Methods

new(scoped: false) click to toggle source

If this metric is scoped inside another, use exclusive time for min/max. Non-scoped metrics (like Controller) track the total call time.

# File lib/heimdall_apm/metric_stats.rb, line 14
def initialize(scoped: false)
  @scoped = scoped
  @call_count = 0
  @total_call_time = 0.0
  @total_exclusive_time = 0.0
  @min_call_time = 0.0
  @max_call_time = 0.0
end

Public Instance Methods

update(call_time, exclusive_time = nil) click to toggle source
# File lib/heimdall_apm/metric_stats.rb, line 23
def update(call_time, exclusive_time = nil)
  self.call_count += 1
  self.total_call_time += call_time
  self.total_exclusive_time += exclusive_time

  t = @scoped ? exclusive_time : call_time
  self.min_call_time = t if call_count == 0 || t < min_call_time
  self.max_call_time = t if t > max_call_time
end