async def test_influxdb(influxdb): rep = InfluxReporter(port=influxdb.port, tags={"mark": "X"}, autocreate_database=True) with timer("test").time(): pass with timer("test2").time(): pass cpu_micro = CPUMicroBenchMark() gauge("CPU", cpu_micro) await rep.report_now() assert influxdb.querycount == 1 assert influxdb.writecount == 1 # cpu micro has none-empty cache assert cpu_micro.last_value is not None if influxdb.failure: raise influxdb.failure for line in influxdb.lines: assert "mark=X" in line
def callme(): logging.info('Called me!') pyf.gauge('demo.time').set_value(time.time())
sys.path.insert(0, os.path.join( os.path.dirname(os.path.abspath(__file__)), '..')) import signalfx.pyformance # noqa if __name__ == '__main__': parser = argparse.ArgumentParser( description='SignalFx metrics reporting demo') parser.add_argument('token', help='Your SignalFx API access token') options = parser.parse_args() @pyf.count_calls def callme(): logging.info('Called me!') pyf.gauge('demo.time').set_value(time.time()) logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) sfx = signalfx.pyformance.SignalFxReporter(options.token) sfx.start() pyf.gauge('demo.pid').set_value(os.getpid()) try: while True: callme() time.sleep(0.5) except KeyboardInterrupt: pass sfx.stop()
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), '..')) import signalfx.pyformance # noqa if __name__ == '__main__': parser = argparse.ArgumentParser( description='SignalFx metrics reporting demo') parser.add_argument('token', help='Your SignalFx API access token') options = parser.parse_args() @pyf.count_calls def callme(): logging.info('Called me!') pyf.gauge('demo.time').set_value(time.time()) logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) sfx = signalfx.pyformance.SignalFxReporter(options.token) sfx.start() pyf.gauge('demo.pid').set_value(os.getpid()) try: while True: callme() time.sleep(0.5) except KeyboardInterrupt: pass sfx.stop()
def start_auto_benchmark(self) -> None: """Add all auto benchmarking to pyformance""" gauge("self.spec.cpu", CPUMicroBenchMark())