module StatsD

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

@!attribute client

@return [StatsD::Instrument::Backend] The client that will handle singleton method calls in the next
  major version of this library.
@note This new Client implementation is intended to become the new default in
  the next major release of this library. While this class may already be functional,
  we provide no guarantees about the API and the behavior may change.

@!attribute backend

The backend that is being used to emit the metrics.
@return [StatsD::Instrument::Backend] the currently active backend. If there is no active backend
  yet, it will call {StatsD::Instrument::Environment#default_backend} to obtain a
  default backend for the environment.
@see StatsD::Instrument::Environment#default_backend
@deprecated

@!attribute prefix

The prefix to apply to metric names. This can be useful to group all the metrics
for an application in a shared StatsD server.

When using a prefix a dot will be included automatically to separate the prefix
from the metric name.

@return [String, nil] The prefix, or <tt>nil</tt> when no prefix is used
@see StatsD::Instrument::Metric#name
@deprecated

@!attribute default_sample_rate

The sample rate to use if the sample rate is unspecified for a metric call.
@return [Float] Default is 1.0.
@deprecated

@!attribute logger

The logger to use in case of any errors. The logger is also used as default logger
for the LoggerBackend (although this can be overwritten).
@see StatsD::Instrument::Backends::LoggerBackend
@return [Logger]

@!attribute default_tags

The tags to apply to all metrics.
@return [Array<String>, Hash<String, String>, nil] The default tags, or <tt>nil</tt> when no default tags is used
@deprecated

@!attribute legacy_singleton_client

@nodoc
@deprecated

@!attribute singleton_client

@nodoc
@deprecated

@!method measure(name, value = nil, sample_rate: nil, tags: nil, &block)

(see StatsD::Instrument::LegacyClient#measure)

@!method increment(name, value = 1, sample_rate: nil, tags: nil)

(see StatsD::Instrument::LegacyClient#increment)

@!method gauge(name, value, sample_rate: nil, tags: nil)

(see StatsD::Instrument::LegacyClient#gauge)

@!method set(name, value, sample_rate: nil, tags: nil)

(see StatsD::Instrument::LegacyClient#set)

@!method histogram(name, value, sample_rate: nil, tags: nil)

(see StatsD::Instrument::LegacyClient#histogram)

@!method distribution(name, value = nil, sample_rate: nil, tags: nil, &block)

(see StatsD::Instrument::LegacyClient#distribution)

@!method key_value(name, value)

(see StatsD::Instrument::LegacyClient#key_value)

@!method event(title, text, tags: nil, hostname: nil, timestamp: nil, aggregation_key: nil, priority: nil, source_type_name: nil, alert_type: nil) # rubocop:disable Metrics/LineLength

(see StatsD::Instrument::LegacyClient#event)

@!method service_check(name, status, tags: nil, hostname: nil, timestamp: nil, message: nil)

(see StatsD::Instrument::LegacyClient#service_check)

@see StatsD::Instrument StatsD::Instrument contains module to instrument

existing methods with StatsD metrics

Attributes

logger[RW]
singleton_client[W]

Public Instance Methods

legacy_singleton_client() click to toggle source
# File lib/statsd/instrument.rb, line 403
def legacy_singleton_client
  StatsD::Instrument::LegacyClient.singleton
end
singleton_client() click to toggle source
# File lib/statsd/instrument.rb, line 407
def singleton_client
  @singleton_client ||= StatsD::Instrument::Environment.current.client
end