Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master


latest commit 1e8e8e3218
Tomaz Muraus Kami authored
Failed to load latest commit information.
examples/twisted/plugins Initial import of the library from the ck repo.
pystats pep8.
tests pep8.
LICENSE Initial import of the library from the ck repo. Add readme. Update


Python library for recording application-specific metrics.

Library has been decoupled from Cloudkick internal code base and it currently only exposes a single class - Counter.


pip install pystats


from pystats.counter import Counter

counter = Counter()

# Increase the counter
counter.add('key_name', 1)

# Change the metric type (by default each metric type is float)
counter.set_type('key_name', 'float|int|gauge')

# Count how many time function has been executed (it basically just increased
# the counter where the counter key is a function name)
my_function('foo', '3', 55)

# Add average - minimum, maximum and average values will automatically be
# calculated and tracked for this key
counter.add_avg('key_name', value, type='float')

# Increase operation count
# This will increase the total and pending operational count for the provided
# key

# Mark pending operation as finished
# This will decrease the pending operation count for the provided key

# Change the counter status / health to "error"

# Retrieve counter health
health =

# Retrieve all the metrics
metrics = counter.get_metrics(include_uptime=True)

# Retrieve counter stats object which contains all the metrics and counter
# health

stats = counter.to_stats()
Something went wrong with that request. Please try again.