Class: Hallmonitor::Outputters::NewRelic

Inherits:
Hallmonitor::Outputter show all
Defined in:
lib/hallmonitor/outputters/new_relic.rb

Overview

Outputs events to NewRelic using their custom metrics API

Instance Attribute Summary

Attributes inherited from Hallmonitor::Outputter

#name

Instance Method Summary collapse

Constructor Details

#initialize(prefix = '') ⇒ NewRelic

Initializes a new instance

Parameters:

  • prefix (String) (defaults to: '')

    String to prefix all metrics with

Raises:

  • String if NewRelic::Agent isn’t defined (Library isn’t loaded)



8
9
10
11
# File 'lib/hallmonitor/outputters/new_relic.rb', line 8

def initialize(prefix='')
  raise "In order to use NewRelic, new_relic gem must be installed" unless defined?(::NewRelic::Agent)
  super(prefix)
end

Instance Method Details

#process(event) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/hallmonitor/outputters/new_relic.rb', line 13

def process(event)
  if(event.respond_to?(:duration))
    ::NewRelic::Agent.record_metric(new_relic_name(event), event.duration)
  elsif(event.respond_to?(:value))
    ::NewRelic::Agent.record_metric(new_relic_name(event), event.value)
  else
    ::NewRelic::Agent.increment_metric(new_relic_name(event), event.count)
  end
end