Getting started in Python
Here's how to get started with Python in a new or existing project.
Install the library
pip install autometrics
Import the library and use the decorator
from autometrics import autometrics
@autometrics
def create_user(name):
# ...
Set the metrics collection library (optional)
Use the environment variable AUTOMETRICS_TRACKER
to set the metrics collection
library. The default is OPEN_TELEMETRY
.
Options:
OPEN_TELEMETRY
- usesopentelemetry
to collect and expose metricsPROMETHEUS
- usesprometheus_client
to collect and expose metrics
Viewing your metrics
Using Autometrics Explorer
Autometrics Explorer is an open source accompanying utility to preview and validate your metrics locally. It will automatically run Prometheus under the hood for you and show you Autometrics-instrumented functions in a web UI.
See Local Development for more information.
brew install autometrics-dev/tap/am
am start <YOUR_APP_METRICS_ENDPOINT>
View your metrics in your IDE or dashboard
Install the Autometrics VSCode extension (opens in a new tab) to get generated queries in your tooltips in your IDE.
You can now navigate your code in your IDE, hover over the instrumented functions and you will see links for generated queries for your metrics.
If you have Grafana you can also import the Autometrics dashboard (opens in a new tab) for an overview and detailed view of the function metrics.