API Reference

class FakeStatsDClient(prefix='')[source]

Bases: perfmetrics.statsd.StatsdClient

A mock statsd client that tracks sent statsd metrics in memory rather than pushing them over a socket. This class is a drop in replacement for perfmetrics.statsd.StatsdClient that collects statsd packets and Metric that are sent through the client.

clear()[source]

Clears the statsd metrics that have been collected

iter_metrics()

Iterates the Metrics provided to this statsd client.

iter_raw()[source]

Iterates the raw statsd packets provided to the statsd client.

metrics

A list of Metric objects collected by this client.

See also

iter_metrics

packets

A list of raw statsd packets collected by this client.

See also

iter_raw

METRIC_COUNTER_KIND = 'c'

The statsd metric kind for Counters

METRIC_GAUGE_KIND = 'g'

The statsd metric kind for Gauges

METRIC_SET_KIND = 's'

The statsd metric kind for Sets

METRIC_TIMER_KIND = 'ms'

The statsd metric kind for Timers

class Metric(name, value, kind, sampling_rate=None)[source]

Bases: object

The representation of a single statsd metric.

kind = None

The statsd code for the type of metric. e.g. one of the METRIC_*_KIND constants

classmethod make(packet)[source]

Creates a metric from the provided statsd packet.

Raises:ValueError – if packet is a multi metric packet or otherwise invalid.
classmethod make_all(packet)[source]

Makes a list of metrics from the provided statsd packet.

Like make but supports multi metric packets

name = None

The metric name

sampling_rate = None

The rate with which this event has been sampled from (optional)

value = None

The value provided for the metric