Created
October 29, 2015 04:31
-
-
Save coderfi/05a7245689294b1066d0 to your computer and use it in GitHub Desktop.
pyformance Registry + Carbon example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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