Class: Metrica::Reporters::GraphiteReporter

Inherits:
ScheduledReporter show all
Defined in:
lib/metrica/reporters/graphite_reporter.rb

Overview

GraphiteReporter reports the metrics to a Graphite server.

Instance Attribute Summary

Attributes inherited from Metrica::Reporter

#underlying

Instance Method Summary collapse

Methods inherited from ScheduledReporter

#start

Methods inherited from Metrica::Reporter

#start, #stop

Constructor Details

#initialize(options = {}) ⇒ GraphiteReporter

Returns a new instance of GraphiteReporter

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :hostname (String)

    The hostname of the Graphite server.

  • :port (Integer)

    The port number of the Graphite server.

  • :report_interval (Integer)

    How often the metrics are reported to the Graphite server, in seconds.


11
12
13
14
15
16
17
18
19
20
21
# File 'lib/metrica/reporters/graphite_reporter.rb', line 11

def initialize(options = {})
  super

  require_relative "../../jars/metrics-graphite-3.1.2.jar"
  address = java.net.InetSocketAddress.new(@hostname, @port)
  graphite = com.codahale.metrics.graphite.Graphite.new(address)
  @underlying = com.codahale.metrics.graphite.GraphiteReporter.
      forRegistry(Metrica.registry).
      prefixedWith(Metrica.config.prefix).
      build(graphite)
end