Skip to content

Instantly share code, notes, and snippets.

@coderfi
Created October 29, 2015 04:31
Show Gist options
  • Save coderfi/05a7245689294b1066d0 to your computer and use it in GitHub Desktop.
Save coderfi/05a7245689294b1066d0 to your computer and use it in GitHub Desktop.
pyformance Registry + Carbon example
#!/usr/bin/env python
from pyformance.reporters import CarbonReporter
from pyformance import MetricsRegistry
from pyformance import timer
import random
import time
if __name__ == '__main__':
registry = MetricsRegistry()
reporter = CarbonReporter(registry=registry,
server='127.0.0.1',
port=2003)
reporter.start()
timer = registry.timer('test.timer1')
for x in xrange(5):
with timer.time():
print 'sleeping randomly'
time.sleep(random.random())
print timer.get_mean()
reporter.report_now()
reporter.stop()
print 'metrics should be in carbon now!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment