Class: NewRelic::Processor::EpochCounter

Inherits:
NewRelic::Plugin::Processor::Base show all
Defined in:
lib/newrelic_plugin/processors/epoch_counter_processor.rb

Instance Attribute Summary

Attributes inherited from NewRelic::Plugin::Processor::Base

#ident, #label

Instance Method Summary collapse

Constructor Details

#initializeEpochCounter

Returns a new instance of EpochCounter.



3
4
5
# File 'lib/newrelic_plugin/processors/epoch_counter_processor.rb', line 3

def initialize
  super :epoch_counter, "Epoch Counter"
end

Instance Method Details

#process(val) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/newrelic_plugin/processors/epoch_counter_processor.rb', line 7

def process val
  ret = nil
  curr_time = Time.now

  if val && @last_value && @last_time && curr_time > @last_time
    val = val.to_f
    ret = (val - @last_value.to_f) / (curr_time - @last_time).to_f
  end

  @last_value = val
  @last_time = curr_time

  # This next line is to avoid large negative spikes during epoch reset events...
  return nil if ret.nil? || ret < 0
  ret
end