Skip to main content

Autometrics package for python

Project description


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


  • 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 be http://localhost:9090/
  • pip install autometrics
  • Import the library in your code and use the decorator for any function:
from autometrics import autometrics

def sayHello:
   return "hello"

  • If you like to access the queries for your decoraded functions you can run help(yourfunction) or print(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

autometrics-0.2.tar.gz (4.3 kB view hashes)

Uploaded Source

Built Distribution

autometrics-0.2-py3-none-any.whl (4.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page