statsd.counter

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

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)

Decrement the counter with delta

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

Increment the counter with delta

Parameters:
  • subname – The subname to report the data to (appended to the client name)
  • delta – The delta to add to the counter
>>> counter = Counter('application_name')
>>> counter.increment('counter_name', 10)
>>> counter.increment(delta=10)
>>> counter.increment('counter_name')

Project Versions

Previous topic

statsd.timer

This Page