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
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.
5
+
A Python library that exports a 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.
4
6
5
7
Autometrics for Python provides:
6
8
@@ -18,8 +20,7 @@ See [Why Autometrics?](https://github.com/autometrics-dev#why-autometrics) for m
18
20
- 🔗 Create links to live Prometheus charts directly into each functions docstrings (with tooltips coming soon!)
19
21
- 📊 (Coming Soon!) Grafana dashboard showing the performance of all
20
22
instrumented functions
21
-
- 🚨 (Coming Soon!) Generates Prometheus alerting rules using SLO best practices
22
-
from simple annotations in your code
23
+
- 🚨 Enable Prometheus alerts using SLO best practices from simple annotations in your code
23
24
- ⚡ Minimal runtime overhead
24
25
25
26
## Using autometrics-py
@@ -45,15 +46,96 @@ def sayHello:
45
46
46
47
> Note that we cannot support tooltips without a VSCode extension due to behavior of the [static analyzer](https://github.com/davidhalter/jedi/issues/1921) used in VSCode.
47
48
49
+
## Alerts / SLOs
50
+
51
+
Autometrics makes it easy to add Prometheus alerts using Service-Level Objectives (SLOs) to a function or group of functions.
52
+
53
+
In order to receive alerts you need to add a set of rules to your Prometheus set up. You can find out more about those rules here: [Prometheus alerting rules](https://github.com/autometrics-dev/autometrics-shared#prometheus-recording--alerting-rules). Once added, most of the recording rules are dormant. They are enabled by specific metric labels that can be automatically attached by autometrics.
54
+
55
+
To use autometrics SLOs and alerts, create one or multiple `Objective`s based on the function(s) success rate and/or latency, as shown below. The `Objective` can be passed as an argument to the `autometrics` macro to include the given function in that objective.
56
+
57
+
```python
58
+
from autometrics import autometrics
59
+
from autometrics.objectives import Objective, ObjectiveLatency, ObjectivePercentile
Autometrics by default will try to store information on which function calls a decorated function. As such you may want to place the autometrics in the top/first decorator, as otherwise you may get `inner` or `wrapper` as the caller function.
This package uses [poetry](https://python-poetry.org) as a package manager, with all dependencies separated into three groups:
51
-
- root level dependencies, required
52
-
-`dev`, everything that is needed for development or in ci
53
-
-`examples`, dependencies of everything in `examples/` directory
109
+
110
+
- root level dependencies, required
111
+
-`dev`, everything that is needed for development or in ci
112
+
-`examples`, dependencies of everything in `examples/` directory
54
113
55
114
By default, poetry will only install required dependencies, if you want to run examples, install using this command:
56
115
57
-
`poetry install --with examples`
116
+
```sh
117
+
poetry install --with examples
118
+
```
119
+
120
+
Code in this repository is:
121
+
122
+
- formatted using [black](https://black.readthedocs.io/en/stable/).
123
+
- contains type definitions (which are linted by [pyright](https://microsoft.github.io/pyright/))
124
+
- tested using [pytest](https://docs.pytest.org/)
125
+
126
+
In order to run these tools locally you have to install them, you can install them using poetry:
58
127
59
-
Code in this repository is formatted using [black](https://black.readthedocs.io/en/stable/) and contains type definitions (which are linted by [pyright](https://microsoft.github.io/pyright/))
0 commit comments