Class: Sentry::Metrics::GaugeMetric

Inherits:
Metric
  • Object
show all
Defined in:
lib/sentry/metrics/gauge_metric.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#countObject (readonly)

Returns the value of attribute count.



6
7
8
# File 'lib/sentry/metrics/gauge_metric.rb', line 6

def count
  @count
end

#lastObject (readonly)

Returns the value of attribute last.



6
7
8
# File 'lib/sentry/metrics/gauge_metric.rb', line 6

def last
  @last
end

#maxObject (readonly)

Returns the value of attribute max.



6
7
8
# File 'lib/sentry/metrics/gauge_metric.rb', line 6

def max
  @max
end

#minObject (readonly)

Returns the value of attribute min.



6
7
8
# File 'lib/sentry/metrics/gauge_metric.rb', line 6

def min
  @min
end

#sumObject (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

#serializeObject



26
27
28
# File 'lib/sentry/metrics/gauge_metric.rb', line 26

def serialize
  [last, min, max, sum, count]
end

#weightObject



30
31
32
# File 'lib/sentry/metrics/gauge_metric.rb', line 30

def weight
  5
end