Skip to content

Commit 8fea68d

Browse files
authored
Merge branch 'main' into renovate/major-all
2 parents 810ab6c + 01ddd9b commit 8fea68d

4 files changed

Lines changed: 70 additions & 4 deletions

File tree

.github/workflows/python.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@ jobs:
6262
name: artifact
6363
path: dist
6464
- name: Publish package distributions to PyPI
65-
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
65+
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ repos:
1616
- id: check-yaml
1717

1818
- repo: https://github.com/astral-sh/ruff-pre-commit
19-
rev: v0.14.10
19+
rev: v0.15.9
2020
hooks:
2121
- id: ruff
2222
args: [--fix, --exit-non-zero-on-fix, --show-fixes]
@@ -31,7 +31,7 @@ repos:
3131

3232
# Type checking
3333
- repo: https://github.com/pre-commit/mirrors-mypy
34-
rev: v1.19.1
34+
rev: v1.20.0
3535
hooks:
3636
- id: mypy
3737
files: 'src/.*\.py$'

requirements_dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
bidict==0.23.1
22
pika==1.3.2
33
prometheus_client==0.21.0
4-
pytest==8.3.3
4+
pytest==9.0.3
55
pytest-cov==7.1.0
66
pytest-mock==3.14.0
77
pytest-timeout==2.3.1

src/workflows/transport/middleware/otel_tracing.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,72 @@ def wrapped_callback(header, message):
107107

108108
return call_next(channel_hint, wrapped_callback, **kwargs)
109109

110+
def raw_send(self, call_next: Callable, destination: str, message, **kwargs):
111+
# Get current span context (may be None if this is the root span)
112+
current_span = trace.get_current_span()
113+
parent_context = (
114+
trace.set_span_in_context(current_span) if current_span else None
115+
)
116+
117+
with self.tracer.start_as_current_span(
118+
"transport.raw_send",
119+
context=parent_context,
120+
) as span:
121+
self._set_span_attributes(span, destination=destination)
122+
123+
# Inject the current trace context into the message headers
124+
headers = kwargs.get("headers", {})
125+
if headers is None:
126+
headers = {}
127+
inject(headers) # This modifies headers in-place
128+
kwargs["headers"] = headers
129+
130+
return call_next(destination, message, **kwargs)
131+
132+
def broadcast(self, call_next: Callable, destination: str, message, **kwargs):
133+
# Get current span context (may be None if this is the root span)
134+
current_span = trace.get_current_span()
135+
parent_context = (
136+
trace.set_span_in_context(current_span) if current_span else None
137+
)
138+
139+
with self.tracer.start_as_current_span(
140+
"transport.broadcast",
141+
context=parent_context,
142+
) as span:
143+
self._set_span_attributes(span, destination=destination)
144+
145+
# Inject the current trace context into the message headers
146+
headers = kwargs.get("headers", {})
147+
if headers is None:
148+
headers = {}
149+
inject(headers) # This modifies headers in-place
150+
kwargs["headers"] = headers
151+
152+
return call_next(destination, message, **kwargs)
153+
154+
def raw_broadcast(self, call_next: Callable, destination: str, message, **kwargs):
155+
# Get current span context (may be None if this is the root span)
156+
current_span = trace.get_current_span()
157+
parent_context = (
158+
trace.set_span_in_context(current_span) if current_span else None
159+
)
160+
161+
with self.tracer.start_as_current_span(
162+
"transport.raw_broadcast",
163+
context=parent_context,
164+
) as span:
165+
self._set_span_attributes(span, destination=destination)
166+
167+
# Inject the current trace context into the message headers
168+
headers = kwargs.get("headers", {})
169+
if headers is None:
170+
headers = {}
171+
inject(headers) # This modifies headers in-place
172+
kwargs["headers"] = headers
173+
174+
return call_next(destination, message, **kwargs)
175+
110176
def unsubscribe(
111177
self,
112178
call_next: Callable,

0 commit comments

Comments
 (0)