autometrics-dev / autometrics-py

Easily add metrics to your code that actually help you spot and debug issues in production. Built on Prometheus and OpenTelemetry.
https://autometrics.dev
Apache License 2.0
214 stars 7 forks source link

Initialize counters at zero #54

Closed brettimus closed 1 year ago

brettimus commented 1 year ago

Related to discussion: https://github.com/orgs/autometrics-dev/discussions/31


This PR adds an initialize_at_zero method to the Prometheus and OpenTelemetry trackers, which is called when a function is initially decorated. The changes include tests.

This will allow tooling that connects to Prometheus to be able to tell which functions (and objectives!) are being tracked, even if those functions haven't been called since adding autometrics to the codebase.

Additionally, I removed old code that we won't be using anymore 🧹