Skip to content

Commit d1a6c1d

Browse files
authored
aiohttp-server: pass request attributes at span creation (#4118)
* aiohttp-server: pass request attributes at span creation To easy sampling work. * Add changelog
1 parent 3b357c0 commit d1a6c1d

File tree

2 files changed

+4
-3
lines changed
  • instrumentation/opentelemetry-instrumentation-aiohttp-server/src/opentelemetry/instrumentation/aiohttp_server

2 files changed

+4
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4343
([#4119](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4119))
4444
- `opentelemetry-instrumentation`: add database stability attribute setters in `_semconv` utilities
4545
([#4108](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4108))
46+
- `opentelemetry-instrumentation-aiohttp-server`: pass request attributes at span creation
47+
([#4118](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4118))
4648
- `opentelemetry-instrumentation-tornado`: Implement new semantic convention opt-in migration
4749
([#3993](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3993))
4850
- `opentelemetry-instrumentation-tornado`: pass request attributes at span creation

instrumentation/opentelemetry-instrumentation-aiohttp-server/src/opentelemetry/instrumentation/aiohttp_server/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,13 +468,12 @@ async def _middleware(request, handler):
468468
span_name,
469469
context=extract(request, getter=getter),
470470
kind=trace.SpanKind.SERVER,
471+
attributes=request_attrs,
471472
) as span:
472473
if span.is_recording():
473-
request_headers_attributes = (
474+
span.set_attributes(
474475
collect_request_headers_attributes(request)
475476
)
476-
request_attrs.update(request_headers_attributes)
477-
span.set_attributes(request_attrs)
478477
start = default_timer()
479478
active_requests_counter.add(1, active_requests_count_attrs)
480479
try:

0 commit comments

Comments
 (0)