Skip to content

Commit 63dafcb

Browse files
authored
0.4 release (#126)
2 parents c9e40fb + d3b3dd7 commit 63dafcb

File tree

5 files changed

+89
-17
lines changed

5 files changed

+89
-17
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
GITHUB_CONTEXT: ${{ toJson(github) }}
1919
run: echo "$GITHUB_CONTEXT"
2020

21-
- uses: actions/checkout@v5
21+
- uses: actions/checkout@v6
2222

2323
- name: Set up Python
2424
uses: actions/setup-python@v6

.github/workflows/test.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
if: github.event.pull_request.draft == false
1616
runs-on: ubuntu-latest
1717
steps:
18-
- uses: actions/checkout@v5
18+
- uses: actions/checkout@v6
1919
- uses: actions/setup-python@v6
2020
with:
2121
python-version: 3.13
@@ -41,11 +41,11 @@ jobs:
4141
runs-on: ubuntu-latest
4242
strategy:
4343
matrix:
44-
python-version: ["3.10", "3.11", "3.12", "3.13"]
44+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
4545
fail-fast: false
4646

4747
steps:
48-
- uses: actions/checkout@v5
48+
- uses: actions/checkout@v6
4949
- name: Set up Python
5050
uses: actions/setup-python@v6
5151
with:
@@ -64,7 +64,7 @@ jobs:
6464
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.pydantic-version }}
6565
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.pydantic-version }}
6666
- name: Store coverage files
67-
uses: actions/upload-artifact@v4
67+
uses: actions/upload-artifact@v6
6868
with:
6969
name: .coverage.${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.pydantic-version }}
7070
path: coverage
@@ -76,7 +76,7 @@ jobs:
7676
runs-on: ubuntu-latest
7777

7878
steps:
79-
- uses: actions/checkout@v5
79+
- uses: actions/checkout@v6
8080

8181
- uses: actions/setup-python@v6
8282
with:
@@ -87,7 +87,7 @@ jobs:
8787
version: "latest"
8888

8989
- name: Get coverage files
90-
uses: actions/download-artifact@v5
90+
uses: actions/download-artifact@v7
9191
with:
9292
pattern: .coverage*
9393
path: coverage
@@ -101,7 +101,7 @@ jobs:
101101
- run: coverage html --show-contexts --title "taskiq-faststream coverage for ${{ github.sha }}"
102102

103103
- name: Store coverage html
104-
uses: actions/upload-artifact@v4
104+
uses: actions/upload-artifact@v6
105105
with:
106106
name: coverage-html
107107
path: htmlcov

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ pip install taskiq-faststream[nats]
4646
pip install taskiq-faststream[redis]
4747
```
4848

49+
For **OpenTelemetry** distributed tracing support:
50+
51+
```bash
52+
pip install taskiq-faststream[otel]
53+
```
54+
4955
## Usage
5056

5157
The package gives you two classes: `AppWrapper` and `BrokerWrapper`
@@ -141,3 +147,39 @@ taskiq_broker.task(
141147
...,
142148
)
143149
```
150+
151+
## OpenTelemetry Support
152+
153+
**taskiq-faststream** supports taskiq's OpenTelemetry middleware. To enable it, pass `OpenTelemetryMiddleware` when creating the broker wrapper:
154+
155+
```python
156+
from faststream.nats import NatsBroker
157+
from taskiq_faststream import BrokerWrapper
158+
from taskiq.middlewares.otel_middleware import OpenTelemetryMiddleware
159+
160+
broker = NatsBroker()
161+
162+
# Enable OpenTelemetry middleware
163+
taskiq_broker = BrokerWrapper(broker, middlewares=[OpenTelemetryMiddleware()])
164+
```
165+
166+
This will automatically add OpenTelemetry middleware to track task execution, providing insights into:
167+
- Task execution spans
168+
- Task dependencies and call chains
169+
- Performance metrics
170+
- Error tracking
171+
172+
Make sure to configure your OpenTelemetry exporter (e.g., Jaeger, Zipkin) according to your monitoring setup.
173+
174+
The same applies to `AppWrapper`:
175+
176+
```python
177+
from faststream import FastStream
178+
from taskiq_faststream import AppWrapper
179+
from taskiq.middlewares.otel_middleware import OpenTelemetryMiddleware
180+
181+
app = FastStream(broker)
182+
183+
# Enable OpenTelemetry middleware
184+
taskiq_broker = AppWrapper(app, middlewares=[OpenTelemetryMiddleware()])
185+
```

pyproject.toml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[project]
22
name = "taskiq-faststream"
3-
version = "0.3.2"
3+
version = "0.4.0"
44
description = "FastStream - taskiq integration to schedule FastStream tasks"
55
readme = "README.md"
66
license = "MIT"
77
license-files = ["LICENSE"]
88
authors = [
99
{ name = "Taskiq team", email = "[email protected]" },
10-
{ name = "Nikita Pastukhov", email = "nikita@pastukhov-dev.com" },
10+
{ name = "Nikita Pastukhov", email = "nikita@pastukhov-dev.ru" },
1111
]
1212

1313
keywords = ["taskiq", "tasks", "distributed", "async", "FastStream"]
@@ -40,7 +40,7 @@ classifiers = [
4040

4141

4242
dependencies = [
43-
"taskiq>=0.11.0,<0.12.0",
43+
"taskiq>=0.12.1,<0.13.0",
4444
"faststream>=0.3.14,<0.7",
4545
]
4646

@@ -65,23 +65,27 @@ redis = [
6565
"faststream[redis]"
6666
]
6767

68+
otel = [
69+
"taskiq[opentelemetry]"
70+
]
71+
6872
[dependency-groups]
6973
test = [
7074
"taskiq-faststream[nats]",
7175
"taskiq-faststream[rabbit]",
7276
"taskiq-faststream[kafka]",
7377
"taskiq-faststream[confluent]",
7478
"taskiq-faststream[redis]",
75-
79+
"taskiq-faststream[otel]",
7680
"coverage[toml]>=7.2.0,<8.0.0",
77-
"pytest>=7.4.0,<9",
81+
"pytest>=7.4.0,<10",
7882
"freezegun>=1.2.2"
7983
]
8084

8185
dev = [
8286
{include-group = "test"},
83-
"mypy==1.18.2",
84-
"ruff==0.14.0",
87+
"mypy==1.19.1",
88+
"ruff==0.14.10",
8589
"pre-commit >=3.6.0,<5.0.0",
8690
]
8791

taskiq_faststream/broker.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import typing
22
import warnings
3+
from collections.abc import Iterable
34
from typing import Any, TypeAlias
45

56
import anyio
67
from faststream._internal.application import Application
78
from faststream.types import SendableMessage
89
from taskiq import AsyncBroker
10+
from taskiq.abc.middleware import TaskiqMiddleware
911
from taskiq.acks import AckableMessage
1012
from taskiq.decor import AsyncTaskiqDecoratedTask
1113

@@ -30,10 +32,22 @@ class BrokerWrapper(AsyncBroker):
3032
task : Register FastStream scheduled task.
3133
"""
3234

33-
def __init__(self, broker: Any) -> None:
35+
def __init__(
36+
self,
37+
broker: Any,
38+
*,
39+
middlewares: Iterable[TaskiqMiddleware] = (),
40+
) -> None:
41+
"""Initialize BrokerWrapper.
42+
43+
Args:
44+
broker: FastStream broker instance to wrap.
45+
middlewares: Middlewares to add to the broker.
46+
"""
3447
super().__init__()
3548
self.formatter = PatchedFormatter()
3649
self.broker = broker
50+
self.add_middlewares(*middlewares)
3751

3852
async def startup(self) -> None:
3953
"""Startup wrapped FastStream broker."""
@@ -105,10 +119,22 @@ class AppWrapper(BrokerWrapper):
105119
task : Register FastStream scheduled task.
106120
"""
107121

108-
def __init__(self, app: Application) -> None:
122+
def __init__(
123+
self,
124+
app: Application,
125+
*,
126+
middlewares: Iterable[TaskiqMiddleware] = (),
127+
) -> None:
128+
"""Initialize AppWrapper.
129+
130+
Args:
131+
app: FastStream application instance to wrap.
132+
middlewares: Middlewares to add to the broker.
133+
"""
109134
super(BrokerWrapper, self).__init__()
110135
self.formatter = PatchedFormatter()
111136
self.app = app
137+
self.add_middlewares(*middlewares)
112138

113139
async def startup(self) -> None:
114140
"""Startup wrapped FastStream."""

0 commit comments

Comments
 (0)