Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Oct 21, 2024. It is now read-only.

Commit bc3ee80

Browse files
aiohttp_client: fix propagation of traceparent in aiohttp_client (open-telemetry#709)
Fix propagation of aiohttp client traces, which were not properly injected previously. Co-authored-by: Yusuke Tsutsumi <[email protected]>
1 parent 06bab74 commit bc3ee80

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

ext/opentelemetry-ext-aiohttp-client/src/opentelemetry/ext/aiohttp_client/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,7 @@ async def on_request_start(
175175
trace.propagation.set_span_in_context(trace_config_ctx.span)
176176
)
177177

178-
propagators.inject(
179-
tracer, type(params.headers).__setitem__, params.headers
180-
)
178+
propagators.inject(type(params.headers).__setitem__, params.headers)
181179

182180
async def on_request_end(
183181
unused_session: aiohttp.ClientSession,

ext/opentelemetry-ext-aiohttp-client/tests/test_aiohttp_client_integration.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ def _http_request(
7171
"""Helper to start an aiohttp test server and send an actual HTTP request to it."""
7272

7373
async def do_request():
74-
async def default_handler(unused_request):
74+
async def default_handler(request):
75+
assert "traceparent" in request.headers
7576
return aiohttp.web.Response(status=int(status_code))
7677

7778
handler = request_handler or default_handler
@@ -281,8 +282,9 @@ async def do_request(url):
281282
self.memory_exporter.clear()
282283

283284
def test_timeout(self):
284-
async def request_handler(unused_request):
285+
async def request_handler(request):
285286
await asyncio.sleep(1)
287+
assert "traceparent" in request.headers
286288
return aiohttp.web.Response()
287289

288290
host, port = self._http_request(
@@ -312,6 +314,7 @@ def test_too_many_redirects(self):
312314
async def request_handler(request):
313315
# Create a redirect loop.
314316
location = request.url
317+
assert "traceparent" in request.headers
315318
raise aiohttp.web.HTTPFound(location=location)
316319

317320
host, port = self._http_request(

0 commit comments

Comments
 (0)