Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A port of my counters gem - easily track counters for your systems
branch: master



A port of counters to Python.

Easily record system performance counters from anywhere in your codebase. The output from this Python port and the original Ruby version are identical, enabling perfect interoperability between both.


Record counters in-memory:

from counters import MemoryCounters
counters = MemoryCounters()"crawler.alive")

Record counters to Redis:

from counters import RedisCounters
# Use default configuration: host='localhost', port=6379, db=0
counters = RedisCounters(rootkey='counters')

# Configure Redis yourself:
rinstance = redis.Redis('')
counters = RedisCounters(redis=rinstance, rootkey='counters')

# Use the returned object"crawler.alive")
counters.magnitude("", 20912)

Since all counters are stored under a single Redis Hash, you should pass the default root you want, although the default of counters should work in most cases.

Records counters to a file:

from counters import FileCounters
# Either pass a path or an instance of a file object
counters = FileCounters("path/to/logfile.log")
counters.latency("crawler.processing", 12) # Expects a number of seconds, possibly float
Something went wrong with that request. Please try again.