File tree Expand file tree Collapse file tree
instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -47,6 +47,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4747 ([ #4140 ] ( https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4140 ) )
4848- ` opentelemetry-instrumentation-pyramid ` Implement new semantic convention opt-in migration
4949 ([ #3982 ] ( https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3982 ) )
50+ - ` opentelemetry-instrumentation-pyramid ` : pass request attributes at span creation
51+ ([ #4139 ] ( https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4139 ) )
5052
5153### Fixed
5254
Original file line number Diff line number Diff line change @@ -115,27 +115,29 @@ def _before_traversal(event):
115115 else :
116116 span_name = otel_wsgi .get_default_span_name (request_environ )
117117
118+ attributes = otel_wsgi .collect_request_attributes (
119+ request_environ , _sem_conv_opt_in_mode
120+ )
121+ if request .matched_route :
122+ attributes [HTTP_ROUTE ] = request .matched_route .pattern
123+
118124 span , token = _start_internal_or_server_span (
119125 tracer = tracer ,
120126 span_name = span_name ,
121127 start_time = start_time ,
122128 context_carrier = request_environ ,
123129 context_getter = otel_wsgi .wsgi_getter ,
130+ attributes = attributes ,
124131 )
125132
126133 if span .is_recording ():
127- attributes = otel_wsgi .collect_request_attributes (
128- request_environ , _sem_conv_opt_in_mode
129- )
130- if request .matched_route :
131- attributes [HTTP_ROUTE ] = request .matched_route .pattern
134+ attributes = {}
132135 _set_http_url (
133136 attributes ,
134137 redact_url (wsgiref_util .request_uri (request_environ )),
135138 _sem_conv_opt_in_mode ,
136139 )
137- for key , value in attributes .items ():
138- span .set_attribute (key , value )
140+ span .set_attributes (attributes )
139141 if span .kind == trace .SpanKind .SERVER :
140142 custom_attributes = (
141143 otel_wsgi .collect_custom_request_headers_attributes (
You can’t perform that action at this time.
0 commit comments