Class: Metrica::Reporters::OpenTSDBReporter

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

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 = {}) ⇒ OpenTSDBReporter

Returns a new instance of OpenTSDBReporter

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :url (String) — default: "http://localhost:4242"

    The URL of the OpenTSDB Server.

  • :tags (Hash) — default: {"host": "the-hostname-of-your-server"}

    A set of tags to be attached to each event.

  • :report_interval (Integer) — default: 30

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


14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/metrica/reporters/opentsdb_reporter.rb', line 14

def initialize(options = {})
  super

  require_relative "../../jars/metrics-opentsdb-1.0.4.jar"
  opentsdb = com.github.sps.metrics.opentsdb.OpenTsdb.
      forService(@url).create
  @underlying = com.github.sps.metrics.OpenTsdbReporter.
      forRegistry(Metrica.registry).
      prefixedWith(Metrica.config.prefix).
      withTags(to_java_hashmap(@tags)).
      build(opentsdb)
end