Class: Sentry::Metrics::GaugeMetric
- Defined in:
- lib/sentry/metrics/gauge_metric.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#last ⇒ Object
readonly
Returns the value of attribute last.
-
#max ⇒ Object
readonly
Returns the value of attribute max.
-
#min ⇒ Object
readonly
Returns the value of attribute min.
-
#sum ⇒ Object
readonly
Returns the value of attribute sum.
Instance Method Summary collapse
- #add(value) ⇒ Object
-
#initialize(value) ⇒ GaugeMetric
constructor
A new instance of GaugeMetric.
- #serialize ⇒ Object
- #weight ⇒ Object
Constructor Details
#initialize(value) ⇒ GaugeMetric
Returns a new instance of GaugeMetric.
8 9 10 11 12 13 14 15 |
# File 'lib/sentry/metrics/gauge_metric.rb', line 8 def initialize(value) value = value.to_f @last = value @min = value @max = value @sum = value @count = 1 end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
6 7 8 |
# File 'lib/sentry/metrics/gauge_metric.rb', line 6 def count @count end |
#last ⇒ Object (readonly)
Returns the value of attribute last.
6 7 8 |
# File 'lib/sentry/metrics/gauge_metric.rb', line 6 def last @last end |
#max ⇒ Object (readonly)
Returns the value of attribute max.
6 7 8 |
# File 'lib/sentry/metrics/gauge_metric.rb', line 6 def max @max end |
#min ⇒ Object (readonly)
Returns the value of attribute min.
6 7 8 |
# File 'lib/sentry/metrics/gauge_metric.rb', line 6 def min @min end |
#sum ⇒ Object (readonly)
Returns the value of attribute sum.
6 7 8 |
# File 'lib/sentry/metrics/gauge_metric.rb', line 6 def sum @sum end |
Instance Method Details
#add(value) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/sentry/metrics/gauge_metric.rb', line 17 def add(value) value = value.to_f @last = value @min = [@min, value].min @max = [@max, value].max @sum += value @count += 1 end |
#serialize ⇒ Object
26 27 28 |
# File 'lib/sentry/metrics/gauge_metric.rb', line 26 def serialize [last, min, max, sum, count] end |
#weight ⇒ Object
30 31 32 |
# File 'lib/sentry/metrics/gauge_metric.rb', line 30 def weight 5 end |