Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#4140](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4140))
- `opentelemetry-instrumentation-pyramid` Implement new semantic convention opt-in migration
([#3982](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3982))
- `opentelemetry-instrumentation-pyramid`: pass request attributes at span creation
([#4139](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4139))

### Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,27 +115,29 @@ def _before_traversal(event):
else:
span_name = otel_wsgi.get_default_span_name(request_environ)

attributes = otel_wsgi.collect_request_attributes(
request_environ, _sem_conv_opt_in_mode
)
if request.matched_route:
attributes[HTTP_ROUTE] = request.matched_route.pattern

span, token = _start_internal_or_server_span(
tracer=tracer,
span_name=span_name,
start_time=start_time,
context_carrier=request_environ,
context_getter=otel_wsgi.wsgi_getter,
attributes=attributes,
)

if span.is_recording():
attributes = otel_wsgi.collect_request_attributes(
request_environ, _sem_conv_opt_in_mode
)
if request.matched_route:
attributes[HTTP_ROUTE] = request.matched_route.pattern
attributes = {}
_set_http_url(
attributes,
redact_url(wsgiref_util.request_uri(request_environ)),
_sem_conv_opt_in_mode,
)
for key, value in attributes.items():
span.set_attribute(key, value)
span.set_attributes(attributes)
if span.kind == trace.SpanKind.SERVER:
custom_attributes = (
otel_wsgi.collect_custom_request_headers_attributes(
Expand Down