Class: Metriksd::LibratoMetricsReporter::TimesliceRollup::AverageGauge

Inherits:
Object
  • Object
show all
Defined in:
lib/metriksd/librato_metrics_reporter/timeslice_rollup.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, source) ⇒ AverageGauge

Returns a new instance of AverageGauge.



6
7
8
9
10
11
12
13
14
# File 'lib/metriksd/librato_metrics_reporter/timeslice_rollup.rb', line 6

def initialize(name, source)
  @name           = name
  @source         = source
  @count          = 0
  @sum            = 0
  @sum_squares = 0
  @min            = nil
  @max            = nil
end

Instance Attribute Details

#countObject

Returns the value of attribute count.



4
5
6
# File 'lib/metriksd/librato_metrics_reporter/timeslice_rollup.rb', line 4

def count
  @count
end

#maxObject

Returns the value of attribute max.



4
5
6
# File 'lib/metriksd/librato_metrics_reporter/timeslice_rollup.rb', line 4

def max
  @max
end

#minObject

Returns the value of attribute min.



4
5
6
# File 'lib/metriksd/librato_metrics_reporter/timeslice_rollup.rb', line 4

def min
  @min
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/metriksd/librato_metrics_reporter/timeslice_rollup.rb', line 4

def name
  @name
end

#sourceObject

Returns the value of attribute source.



4
5
6
# File 'lib/metriksd/librato_metrics_reporter/timeslice_rollup.rb', line 4

def source
  @source
end

#sumObject

Returns the value of attribute sum.



4
5
6
# File 'lib/metriksd/librato_metrics_reporter/timeslice_rollup.rb', line 4

def sum
  @sum
end

#sum_squaresObject

Returns the value of attribute sum_squares.



4
5
6
# File 'lib/metriksd/librato_metrics_reporter/timeslice_rollup.rb', line 4

def sum_squares
  @sum_squares
end

Instance Method Details

#mark(value) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/metriksd/librato_metrics_reporter/timeslice_rollup.rb', line 16

def mark(value)
  @count += 1
  @sum += value
  @sum_squares += value ** 2

  if !@min || value < @min
    @min = value
  end

  if !@max || value > @max
    @max = value
  end
end

#to_hashObject



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/metriksd/librato_metrics_reporter/timeslice_rollup.rb', line 30

def to_hash
  {
    :name => name,
    :source => source,
    :count => count,
    :sum => sum,
    :sum_squares => sum_squares,
    :min => min,
    :max => max
  }
end