Class: Fluent::LibratoMetricsOutput::AverageAggregator

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/plugin/out_librato_metrics.rb

Overview

avg(value) aggregator

Instance Method Summary collapse

Constructor Details

#initializeAverageAggregator

Returns a new instance of AverageAggregator.



167
168
169
170
# File 'lib/fluent/plugin/out_librato_metrics.rb', line 167

def initialize
  @value = 0
  @num = 0
end

Instance Method Details

#add(value) ⇒ Object



172
173
174
175
# File 'lib/fluent/plugin/out_librato_metrics.rb', line 172

def add(value)
  @value += value
  @num += 1
end

#getObject



177
178
179
# File 'lib/fluent/plugin/out_librato_metrics.rb', line 177

def get
  @value / @num
end