Sha256: bb01f4fce4feab756c3637bbdb12c6a1f0acbce7a8607a539c4c59d7ef8e3767

Contents?: true

Size: 540 Bytes

Versions: 10

Compression:

Stored size: 540 Bytes

Contents

require 'honeybadger/metric'

module Honeybadger
  class Gauge < Metric
    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
    end

    def payloads
      [
        {
          total: @total,
          min: @min,
          max: @max,
          avg: @avg,
          latest: @latest
        }
      ]
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
honeybadger-5.26.2 lib/honeybadger/gauge.rb
honeybadger-5.26.1 lib/honeybadger/gauge.rb
honeybadger-5.26.0 lib/honeybadger/gauge.rb
honeybadger-5.25.0 lib/honeybadger/gauge.rb
honeybadger-5.24.0 lib/honeybadger/gauge.rb
honeybadger-5.23.0 lib/honeybadger/gauge.rb
honeybadger-5.22.0 lib/honeybadger/gauge.rb
honeybadger-5.21.0 lib/honeybadger/gauge.rb
honeybadger-5.20.1 lib/honeybadger/gauge.rb
honeybadger-5.20.0 lib/honeybadger/gauge.rb