pip install statsd python import statsd import time client = statsd.StatsClient('localhost', 8125) def foo(): start_time = time.time() time.sleep(2) end_time = time.time() client.timing('function.foo', int((end_time - start_time) * 1000)) def bar(): time.sleep(0.5) client.incr('requests.bar') def baz(): try: raise Exception('Some error') except: client.incr('errors.baz') foo() bar() baz()


上一篇:
下一篇:
切换中文