statsd.counter

class statsd.counter.Counter(name, connection=None)[source]

Class to implement a statd counter

Additional documentation is available at the parent class Client

The values can be incremented/decremented by using either the increment() and decrement() methods or by simply adding/deleting from the object.

>>> counter = Counter('application_name')
>>> counter += 10
>>> counter = Counter('application_name')
>>> counter -= 10
decrement(subname=None, delta=1)[source]

Decrement the counter with delta

Parameters:
  • subname (str) – The subname to report the data to (appended to the client name)
  • delta (int) – The delta to remove from the counter
>>> counter = Counter('application_name')
>>> counter.decrement('counter_name', 10)
True
>>> counter.decrement(delta=10)
True
>>> counter.decrement('counter_name')
True
increment(subname=None, delta=1)[source]

Increment the counter with delta

Parameters:
  • subname (str) – The subname to report the data to (appended to the client name)
  • delta (int) – The delta to add to the counter
>>> counter = Counter('application_name')
>>> counter.increment('counter_name', 10)
True
>>> counter.increment(delta=10)
True
>>> counter.increment('counter_name')
True
statsd.counter.decrement(key, delta=1)[source]

Decrement the counter with delta

Parameters:
  • key (str) – The key to report the data to
  • delta (int) – The delta to remove from the counter
statsd.counter.increment(key, delta=1)[source]

Increment the counter with delta

Parameters:
  • key (str) – The key to report the data to
  • delta (int) – The delta to add to the counter