Module: StatsD

Extended by:
Forwardable
Defined in:
lib/statsd/instrument.rb,
lib/statsd/instrument/sink.rb,
lib/statsd/instrument/client.rb,
lib/statsd/instrument/strict.rb,
lib/statsd/instrument/helpers.rb,
lib/statsd/instrument/railtie.rb,
lib/statsd/instrument/version.rb,
lib/statsd/instrument/datagram.rb,
lib/statsd/instrument/log_sink.rb,
lib/statsd/instrument/matchers.rb,
lib/statsd/instrument/null_sink.rb,
lib/statsd/instrument/aggregator.rb,
lib/statsd/instrument/assertions.rb,
lib/statsd/instrument/environment.rb,
lib/statsd/instrument/expectation.rb,
lib/statsd/instrument/batched_sink.rb,
lib/statsd/instrument/capture_sink.rb,
lib/statsd/instrument/udp_connection.rb,
lib/statsd/instrument/uds_connection.rb,
lib/statsd/instrument/datagram_builder.rb,
lib/statsd/instrument/dogstatsd_datagram.rb,
lib/statsd/instrument/connection_behavior.rb,
lib/statsd/instrument/statsd_datagram_builder.rb,
lib/statsd/instrument/dogstatsd_datagram_builder.rb

Overview

The StatsD module contains low-level metrics for collecting metrics and sending them to the backend.

Defined Under Namespace

Modules: Instrument

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.loggerLogger

The logger to use in case of any errors.



332
333
334
# File 'lib/statsd/instrument.rb', line 332

def logger
  @logger
end

.singleton_clientStatsD::Instrument::Client

The StatsD client that handles method calls on the StatsD singleton



343
344
345
# File 'lib/statsd/instrument.rb', line 343

def singleton_client
  @singleton_client ||= StatsD::Instrument::Environment.current.client
end

Class Method Details

.distribution(name, value = nil, sample_rate: nil, tags: nil, &block) ⇒ void

Note:

The distribution metric type is not available on all implementations. A NotImplementedError will be raised if you call this method, but the active implementation does not support it.

This method returns an undefined value.

Emits a distribution metric, which builds a histogram of the reported values.



371
372
373
374
375
376
377
378
379
# File 'lib/statsd/instrument.rb', line 371

def_delegators :singleton_client,
:increment,
:gauge,
:set,
:measure,
:histogram,
:distribution,
:event,
:service_check

.event(title, text, tags: nil, hostname: nil, timestamp: nil, aggregation_key: nil, priority: nil, source_type_name: nil, alert_type: nil) ⇒ void

Note:

Supported by the Datadog implementation only.

This method returns an undefined value.

Emits an event. An event represents any record of activity noteworthy for engineers.



371
372
373
374
375
376
377
378
379
# File 'lib/statsd/instrument.rb', line 371

def_delegators :singleton_client,
:increment,
:gauge,
:set,
:measure,
:histogram,
:distribution,
:event,
:service_check

.gauge(name, value, sample_rate: nil, tags: nil) ⇒ void

This method returns an undefined value.

Emits a gauge metric.

You should use a gauge if you are reporting the current value of something that can only have one value at the time. E.g., the speed of your car. A newly reported value will replace the previously reported value.



371
372
373
374
375
376
377
378
379
# File 'lib/statsd/instrument.rb', line 371

def_delegators :singleton_client,
:increment,
:gauge,
:set,
:measure,
:histogram,
:distribution,
:event,
:service_check

.histogram(name, value, sample_rate: nil, tags: nil) ⇒ void

Note:

The histogram metric type is not available on all implementations. A NotImplementedError will be raised if you call this method, but the active implementation does not support it.

This method returns an undefined value.

Emits a histogram metric, which builds a histogram of the reported values.



371
372
373
374
375
376
377
378
379
# File 'lib/statsd/instrument.rb', line 371

def_delegators :singleton_client,
:increment,
:gauge,
:set,
:measure,
:histogram,
:distribution,
:event,
:service_check

.increment(name, value = 1, sample_rate: nil, tags: nil) ⇒ void

This method returns an undefined value.

Emits a counter metric.

You should use a counter metric to count the frequency of something happening. As a result, the value should generally be set to 1 (the default), unless you reporting about a batch of activity. E.g. increment('messages.processed', messages.size) For values that are not frequencies, you should use another metric type, e.g. #histogram or #distribution.



371
372
373
374
375
376
377
378
379
# File 'lib/statsd/instrument.rb', line 371

def_delegators :singleton_client,
:increment,
:gauge,
:set,
:measure,
:histogram,
:distribution,
:event,
:service_check

.measure(name, value = nil, sample_rate: nil, tags: nil, &block) ⇒ void

This method returns an undefined value.

Emits a timing metric.



371
372
373
374
375
376
377
378
379
# File 'lib/statsd/instrument.rb', line 371

def_delegators :singleton_client,
:increment,
:gauge,
:set,
:measure,
:histogram,
:distribution,
:event,
:service_check

.service_check(name, status, tags: nil, hostname: nil, timestamp: nil, message: nil) ⇒ void

Note:

Supported by the Datadog implementation only.

This method returns an undefined value.

Emits a service check. Services Checks allow you to characterize the status of a service in order to monitor it within Datadog.



371
372
373
374
375
376
377
378
379
# File 'lib/statsd/instrument.rb', line 371

def_delegators :singleton_client,
:increment,
:gauge,
:set,
:measure,
:histogram,
:distribution,
:event,
:service_check

.set(name, value, sample_rate: nil, tags: nil) ⇒ void

This method returns an undefined value.

Emits a set metric, which counts distinct values.



371
372
373
374
375
376
377
378
379
# File 'lib/statsd/instrument.rb', line 371

def_delegators :singleton_client,
:increment,
:gauge,
:set,
:measure,
:histogram,
:distribution,
:event,
:service_check