class ScoutApm::RequestHistograms

Constants

DEFAULT_HISTOGRAM_SIZE

Attributes

histogram_size[R]
histograms[R]

Private Accessor: A hash of Endpoint Name to an approximate histogram

Each time a new request is requested to see if it's slow or not, we should insert it into the histogram, and get the approximate percentile of that time

Public Class Methods

new(histogram_size = DEFAULT_HISTOGRAM_SIZE) click to toggle source
# File lib/scout_apm/request_histograms.rb, line 16
def initialize(histogram_size = DEFAULT_HISTOGRAM_SIZE)
  @histogram_size = histogram_size
  initialize_histograms_hash
end

Public Instance Methods

add(item, value) click to toggle source
# File lib/scout_apm/request_histograms.rb, line 33
def add(item, value)
  @histograms[item].add(value)
end
approximate_quantile_of_value(item, value) click to toggle source
# File lib/scout_apm/request_histograms.rb, line 37
def approximate_quantile_of_value(item, value)
  @histograms[item].approximate_quantile_of_value(value)
end
as_json() click to toggle source
# File lib/scout_apm/request_histograms.rb, line 25
def as_json
  Hash[
    @histograms.map{ |key, histogram|
      [key, histogram.as_json]
    }
  ]
end
each_name() { |n| ... } click to toggle source
# File lib/scout_apm/request_histograms.rb, line 21
def each_name
  @histograms.keys.each { |n| yield n }
end
initialize_histograms_hash() click to toggle source
# File lib/scout_apm/request_histograms.rb, line 54
def initialize_histograms_hash
  @histograms = Hash.new { |h, k| h[k] = NumericHistogram.new(histogram_size) }
end
quantile(item, q) click to toggle source
# File lib/scout_apm/request_histograms.rb, line 41
def quantile(item, q)
  @histograms[item].quantile(q)
end
raw(item) click to toggle source
# File lib/scout_apm/request_histograms.rb, line 50
def raw(item)
  @histograms[item]
end
reset_all!() click to toggle source

Wipes all histograms, setting them back to empty

# File lib/scout_apm/request_histograms.rb, line 46
def reset_all!
  initialize_histograms_hash
end