class Honeybadger::Histogram
Constants
- DEFAULT_BINS
- INFINITY
Public Instance Methods
Source
# File lib/honeybadger/histogram.rb, line 31 def bins @attributes.fetch(:bins, DEFAULT_BINS).sort end
Source
# File lib/honeybadger/histogram.rb, line 25 def find_bin(value) bin = bins.find {|b| b >= value } bin = INFINITY if bin.nil? bin end
Source
# File lib/honeybadger/histogram.rb, line 35 def payloads [{ total: @total, min: @min, max: @max, avg: @avg, latest: @latest, bins: (bins + [INFINITY]).map { |bin| [bin.to_f, @bin_counts[bin]] } }] end
Source
# File lib/honeybadger/histogram.rb, line 8 def record(value) return unless value @samples += 1 @total ||= 0 @total = @total + value @min = value if @min.nil? || @min > value @max = value if @max.nil? || @max < value @avg = @total.to_f / @samples @latest = value @bin_counts ||= Hash.new(0) @bin_counts[find_bin(value)] += 1 end