diff --git a/CHANGELOG.md b/CHANGELOG.md index cb9d7ae22a..4470050941 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#1733](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1733)) - Make Django request span attributes available for `start_span`. ([#1730](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1730)) +- Make ASGI request span attributes available for `start_span`. + ([#1762](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1762)) ### Fixed diff --git a/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py b/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py index d4653ac50b..6fc88d3eeb 100644 --- a/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py @@ -531,15 +531,16 @@ async def __call__(self, scope, receive, send): span_name, additional_attributes = self.default_span_details(scope) + attributes = collect_request_attributes(scope) + attributes.update(additional_attributes) span, token = _start_internal_or_server_span( tracer=self.tracer, span_name=span_name, start_time=None, context_carrier=scope, context_getter=asgi_getter, + attributes=attributes, ) - attributes = collect_request_attributes(scope) - attributes.update(additional_attributes) active_requests_count_attrs = _parse_active_request_count_attrs( attributes )