diff --git a/CHANGELOG.md b/CHANGELOG.md index cf520b3a21..6d81b4800f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#4099](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4099)) - `opentelemetry-instrumentation-aiohttp-server` Implement new semantic convention opt-in migration ([#3980](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3980)) +- `opentelemetry-instrumentation-falcon`: pass request attributes at span creation + ([#4119](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4119)) - `opentelemetry-instrumentation`: add database stability attribute setters in `_semconv` utilities ([#4108](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4108)) - `opentelemetry-instrumentation-tornado`: Implement new semantic convention opt-in migration diff --git a/instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/__init__.py b/instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/__init__.py index 33fe6d578b..3a8c7600aa 100644 --- a/instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/__init__.py @@ -368,15 +368,16 @@ def __call__(self, env, start_response): start_time = time_ns() + attributes = otel_wsgi.collect_request_attributes( + env, self._sem_conv_opt_in_mode + ) span, token = _start_internal_or_server_span( tracer=self._otel_tracer, span_name=otel_wsgi.get_default_span_name(env), start_time=start_time, context_carrier=env, context_getter=otel_wsgi.wsgi_getter, - ) - attributes = otel_wsgi.collect_request_attributes( - env, self._sem_conv_opt_in_mode + attributes=attributes, ) active_requests_count_attrs = ( otel_wsgi._parse_active_request_count_attrs( @@ -386,8 +387,6 @@ def __call__(self, env, start_response): self.active_requests_counter.add(1, active_requests_count_attrs) if span.is_recording(): - for key, value in attributes.items(): - span.set_attribute(key, value) if span.is_recording() and span.kind == trace.SpanKind.SERVER: custom_attributes = ( otel_wsgi.collect_custom_request_headers_attributes(env)