Skip to content

Commit 315043a

Browse files
authored
opentelemetry-instrumentation-falcon: pass request attributes at span creation (#4119)
* opentelemetry-instrumentation-falcon: pass request attributes at span creation To ease sampling work. * Add changelog
1 parent 6778776 commit 315043a

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

  • instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3939
([#4099](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4099))
4040
- `opentelemetry-instrumentation-aiohttp-server` Implement new semantic convention opt-in migration
4141
([#3980](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3980))
42+
- `opentelemetry-instrumentation-falcon`: pass request attributes at span creation
43+
([#4119](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4119))
4244
- `opentelemetry-instrumentation`: add database stability attribute setters in `_semconv` utilities
4345
([#4108](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4108))
4446
- `opentelemetry-instrumentation-tornado`: Implement new semantic convention opt-in migration

instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/__init__.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -368,15 +368,16 @@ def __call__(self, env, start_response):
368368

369369
start_time = time_ns()
370370

371+
attributes = otel_wsgi.collect_request_attributes(
372+
env, self._sem_conv_opt_in_mode
373+
)
371374
span, token = _start_internal_or_server_span(
372375
tracer=self._otel_tracer,
373376
span_name=otel_wsgi.get_default_span_name(env),
374377
start_time=start_time,
375378
context_carrier=env,
376379
context_getter=otel_wsgi.wsgi_getter,
377-
)
378-
attributes = otel_wsgi.collect_request_attributes(
379-
env, self._sem_conv_opt_in_mode
380+
attributes=attributes,
380381
)
381382
active_requests_count_attrs = (
382383
otel_wsgi._parse_active_request_count_attrs(
@@ -386,8 +387,6 @@ def __call__(self, env, start_response):
386387
self.active_requests_counter.add(1, active_requests_count_attrs)
387388

388389
if span.is_recording():
389-
for key, value in attributes.items():
390-
span.set_attribute(key, value)
391390
if span.is_recording() and span.kind == trace.SpanKind.SERVER:
392391
custom_attributes = (
393392
otel_wsgi.collect_custom_request_headers_attributes(env)

0 commit comments

Comments
 (0)