Tutorial¶
Cantal is a metrics collection system. It integrates with your application by providing some metrics. Here is a bare (but fully working) example:
1 2 3 4 5 6 7 8 9 10 11 12 13 | import cantal
ticks = cantal.Counter(group="main_loop", metric="ticks")
def main():
cantal.start()
while True:
sleep(0.1)
ticks.incr(1)
if __name__ == '__main__':
main
|
The key things:
- You declare metrics
- Then you call
start()
- Afterwards you may freely adjust values of the metrics
Rules of thumb:
- Create all metrics at module import time
- Import all modules before calling
main()
or whatever init function - Writing metric is very cheap, so you don’t need to aggregate them in user code
- Creating metrics dynamically (after
start()
) is not supported, but you can create metrics in a loop or similar
See Choosing Metrics for more info.