You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+15-7
Original file line number
Diff line number
Diff line change
@@ -22,10 +22,10 @@ See [Why Autometrics?](https://github.com/autometrics-dev#why-autometrics) for m
22
22
- 💡 Writes Prometheus queries so you can understand the data generated without
23
23
knowing PromQL
24
24
- 🔗 Create links to live Prometheus charts directly into each function's docstring
25
-
-[🔍 Identify commits](#identifying-commits-that-introduced-problems) that introduced errors or increased latency
25
+
-[🔍 Identify commits](#build-info) that introduced errors or increased latency
26
26
-[🚨 Define alerts](#alerts--slos) using SLO best practices directly in your source code
27
27
-[📊 Grafana dashboards](#dashboards) work out of the box to visualize the performance of instrumented functions & SLOs
28
-
-[⚙️ Configurable](#metrics-libraries) metric collection library (`opentelemetry` or `prometheus`)
28
+
-[⚙️ Configurable](#settings) metric collection library (`opentelemetry` or `prometheus`)
29
29
-[📍 Attach exemplars](#exemplars) to connect metrics with traces
30
30
- ⚡ Minimal runtime overhead
31
31
@@ -89,14 +89,17 @@ def api_handler():
89
89
90
90
Autometrics keeps track of instrumented functions calling each other. If you have a function that calls another function, metrics for later will include `caller` label set to the name of the autometricised function that called it.
91
91
92
-
## Metrics Libraries
92
+
## Settings
93
93
94
-
Configure the package that autometrics will use to produce metrics with the `AUTOMETRICS_TRACKER` environment variable.
94
+
Autometrics makes use of a number of environment variables to configure its behavior. All of them are also configurable with keyword arguments to the `init` function.
95
95
96
-
-`opentelemetry` - Enabled by default, can also be explicitly set using the env var `AUTOMETRICS_TRACKER="OPEN_TELEMETERY"`. Look in `pyproject.toml` for the versions of the OpenTelemetry packages that will be used.
97
-
-`prometheus` - Can be set using the env var `AUTOMETRICS_TRACKER="PROMETHEUS"`. Look in `pyproject.toml` for the version of the `prometheus-client` package that will be used.
96
+
-`tracker` - Configure the package that autometrics will use to produce metrics. Default is `opentelemetry`, but you can also use `prometheus`. Look in `pyproject.toml` for the corresponding versions of packages that will be used.
97
+
-`histogram_buckets` - Configure the buckets used for latency histograms. Default is `[0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1.0, 2.5, 5.0, 7.5, 10.0]`.
98
+
-`enable_exemplars` - Enable [exemplar collection](#exemplars). Default is `False`.
99
+
-`service_name` - Configure the [service name](#service-name).
100
+
-`version`, `commit`, `branch` - Used to configure [build_info](#build-info).
98
101
99
-
## Identifying commits that introduced problems
102
+
## Identifying commits that introduced problems <spanname="build-info" />
100
103
101
104
> **NOTE** - As of writing, `build_info` will not work correctly when using the default tracker (`AUTOMETRICS_TRACKER=OPEN_TELEMETRY`).
102
105
> This will be fixed once the following PR is merged on the opentelemetry-python project: https://github.com/open-telemetry/opentelemetry-python/pull/3306
@@ -126,6 +129,7 @@ The service name is loaded from the following environment variables, in this ord
126
129
127
130
1.`AUTOMETRICS_SERVICE_NAME` (at runtime)
128
131
2.`OTEL_SERVICE_NAME` (at runtime)
132
+
3. First part of `__package__` (at runtime)
129
133
130
134
## Exemplars
131
135
@@ -137,6 +141,10 @@ Exemplars are a way to associate a metric sample to a trace by attaching `trace_
137
141
To use exemplars, you need to first switch to a tracker that supports them by setting `AUTOMETRICS_TRACKER=prometheus` and enable
138
142
exemplar collection by setting `AUTOMETRICS_EXEMPLARS=true`. You also need to enable exemplars in Prometheus by launching Prometheus with the `--enable-feature=exemplar-storage` flag.
139
143
144
+
## Exporting metrics
145
+
146
+
After collecting metrics with Autometrics, you need to export them to Prometheus. You can either add a separate route to your server and use the `generate_latest` function from the `prometheus_client` package, or you can use the `start_http_server` function from the same package to start a separate server that will expose the metrics. Autometrics also re-exports the `start_http_server` function with a preselected port 9464 for compatibility with other Autometrics packages.
147
+
140
148
## Development of the package
141
149
142
150
This package uses [poetry](https://python-poetry.org) as a package manager, with all dependencies separated into three groups:
Copy file name to clipboardexpand all lines: examples/README.md
+1-3
Original file line number
Diff line number
Diff line change
@@ -69,8 +69,6 @@ This is a default Django project with autometrics configured. You can find examp
69
69
70
70
## `starlette-otel-exemplars.py`
71
71
72
-
This app shows how to use the OpenTelemetry integration to add exemplars to your metrics. In a distributed system, it allows you to track a request as it flows through your system by adding trace/span ids to it. We can catch these ids from OpenTelemetry and expose them to Prometheus as exemplars. Do note that exemplars are an experimental feature and you need to enable it in Prometheus with a `--enable-feature=exemplar-storage` flag. Run the example with a command:
This app shows how to use the OpenTelemetry integration to add exemplars to your metrics. In a distributed system, it allows you to track a request as it flows through your system by adding trace/span ids to it. We can catch these ids from OpenTelemetry and expose them to Prometheus as exemplars. Do note that exemplars are an experimental feature and you need to enable it in Prometheus with a `--enable-feature=exemplar-storage` flag.
75
73
76
74
> Don't forget to configure Prometheus itself to scrape the metrics endpoint. Refer to the example `prometheus.yaml` file in the root of this project on how to set this up.
0 commit comments