Skip to content

Commit 5a8ab0e

Browse files
authored
docs: add information about OpenTelemetry support (#551)
1 parent 5140315 commit 5a8ab0e

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

docs/available-components/middlewares.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Use jitter and exponential backoff to avoid repetitive load peaks, especially in
8787

8888
### Prometheus middleware
8989

90-
You can enable prometheus metrics for workers by adding PrometheusMiddleware.
90+
You can enable prometheus metrics for workers by adding `PrometheusMiddleware`.
9191
To do so, you need to install `prometheus_client` package or you can install metrics extras for taskiq.
9292

9393
::: tabs
@@ -118,3 +118,39 @@ broker = ZeroMQBroker().with_middlewares(
118118

119119
After that, metrics will be available at port 9000. Of course, this parameter can be configured.
120120
If you have other metrics, they'll be shown as well.
121+
122+
### OpenTelemetry Middleware
123+
124+
You can enable opentelemetry tracing for workers by adding `OpenTelemetryMiddleware` or using `TaskiqInstrumentor` (preferred).
125+
126+
```bash
127+
pip install "taskiq[opentelemetry]"
128+
```
129+
130+
::: tabs
131+
132+
133+
@tab instrumentor
134+
135+
```python
136+
from taskiq import ZeroMQBroker
137+
from taskiq.instrumentation import TaskiqInstrumentor
138+
139+
TaskiqInstrumentor().instrument()
140+
broker = ZeroMQBroker()
141+
```
142+
143+
@tab middleware
144+
145+
```python
146+
from taskiq import ZeroMQBroker
147+
from taskiq.middlewares.opentelemetry_middleware import OpenTelemetryMiddleware
148+
149+
broker = ZeroMQBroker().with_middlewares(
150+
OpenTelemetryMiddleware,
151+
)
152+
```
153+
154+
:::
155+
156+
Auto-instrumentation is also supported.

taskiq/instrumentation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
import asyncio
1414
15-
from taskiq import InMemoryBroker, TaskiqEvents, TaskiqState
15+
from taskiq import InMemoryBroker
1616
from taskiq.instrumentation import TaskiqInstrumentor
1717
1818
broker = InMemoryBroker()

0 commit comments

Comments
 (0)