Sha256: 20637fef2325adee386df54722e6c00c7502074f728132968ac073cb38e2624c
Contents?: true
Size: 685 Bytes
Versions: 21
Compression:
Stored size: 685 Bytes
Contents
require 'honeybadger/metric' module Honeybadger class Histogram < Metric DEFAULT_BINS = [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0, 10.0] INFINITY = 1e20.to_f # not quite, but pretty much def record(value) return unless value @samples += 1 @bin_counts ||= Hash.new(0) @bin_counts[find_bin(value)] += 1 end def find_bin(value) bin = bins.find {|b| b >= value } bin = INFINITY if bin.nil? bin end def bins @attributes.fetch(:bins, DEFAULT_BINS).sort end def payloads [{ bins: (bins + [INFINITY]).map { |bin| [bin.to_f, @bin_counts[bin]] } }] end end end
Version data entries
21 entries across 21 versions & 1 rubygems