Module: ActiveMetrics::Instrumentable

Defined in:
lib/active_metrics/instrumentable.rb

Overview

Custom metrics for Librato

Instance Method Summary collapse

Instance Method Details

#count(event, number = 1) ⇒ Object

Count log lines are used to submit increments to Librato.

You can submit increments as frequently as desired and every minute the current total will be flushed to Librato and reset to zero.

Parameters:

  • event (String)

    The name of the event

  • number (Integer) (defaults to: 1)

    The number to increment the current count (defaults to 1)



13
14
15
# File 'lib/active_metrics/instrumentable.rb', line 13

def count(event, number = 1)
  ActiveMetrics::Collector.record(event, { metric: 'count', value: number })
end

#measure(event, value = 0) ⇒ Object

Measure log lines are used to submit individual measurements that comprise a statistical distribution. The most common use case are timings i.e. latency measurements, but it can also be used to represent non-temporal distributions such as counts.

You can submit as many measures as you’d like (typically they are submitted per-request) and every minute Librato will calculate/record a complete set of summary statistics over the measures submitted in that interval.

Parameters:

  • event (String)

    The name of the event

  • value (Integer, String) (defaults to: 0)

    The value measured.



29
30
31
# File 'lib/active_metrics/instrumentable.rb', line 29

def measure(event, value = 0)
  ActiveMetrics::Collector.record(event, { metric: 'measure', value: value })
end

#sample(key, value) ⇒ Object

Sample metrics are used to convey simple key/numerical value pairs when you are already calculating some kind of summary statistic in your app and merely need a simple transport mechanism to Librato.

Typically you would submit sample metrics on some periodic tick and set said period on the metric in Librato.

Parameters:

  • key (String)

    The name of the sample

  • value (Object)

    The value of the sample



42
43
44
# File 'lib/active_metrics/instrumentable.rb', line 42

def sample(key, value)
  ActiveMetrics::Collector.record(key, { metric: 'sample', value: value })
end