Class: Honeybadger::Gauge

Inherits:
Metric
  • Object
show all
Defined in:
lib/honeybadger/gauge.rb

Direct Known Subclasses

Timer

Instance Attribute Summary

Attributes inherited from Metric

#attributes, #name, #samples

Instance Method Summary collapse

Methods inherited from Metric

#base_payload, #event_payloads, #initialize, #metric_type, metric_type, register, signature, #signature

Constructor Details

This class inherits a constructor from Honeybadger::Metric

Instance Method Details

#payloadsObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/honeybadger/gauge.rb', line 19

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

#record(value) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/honeybadger/gauge.rb', line 5

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