Autometrics package for python
Project description
autometrics-py
A Python decorator that makes it easy to understand the error rate, response time, and production usage of any function in your code. Jump straight from your IDE to live Prometheus charts for each HTTP/RPC handler, database method, or other piece of application logic.
Autometrics for Python provides a decorator that can create Prometheus metrics for your functions and class methods throughout your code base, as well as a function that will write corresponding Prometheus queries for you in a Markdown file.
See Why Autometrics? for more details on the ideas behind autometrics
Features
- ✨
autometrics
decorator instruments any function or class method to track the most useful metrics - 💡 Writes Prometheus queries so you can understand the data generated without knowing PromQL
- 🔗 Create links to live Prometheus charts directly into each functions docstrings (with tooltips coming soon!)
- 📊 (Coming Soon!) Grafana dashboard showing the performance of all instrumented functions
- 🚨 (Coming Soon!) Generates Prometheus alerting rules using SLO best practices from simple annotations in your code
- ⚡ Minimal runtime overhead
Using autometrics-py
- Requirement: a running prometheus instance
- include a .env file with your prometheus endpoint
PROMETHEUS_URL = your endpoint
, if not defined the default endpoint will behttp://localhost:9090/
pip install autometrics
- Import the library in your code and use the decorator for any function:
from autometrics import autometrics
@autometrics
def sayHello:
return "hello"
-
If you like to access the queries for your decoraded functions you can run
help(yourfunction)
orprint(yourfunction.__doc__)
-
Unfortunately it is not possible to have the queries in the tooltips due to the static Analyzer. We are currently figuring out to build a VS Code PlugIn to make it work.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for autometrics-0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6122e363705691b2aa635d654f25599ac8c65357bba04774ec58a7022d6180a |
|
MD5 | d8172468ac643c200d4110a3517ce39f |
|
BLAKE2b-256 | 200d496605b5854337b8951e398ace1e9ede1b8e7b8af60b340ac85bfe6207c1 |