Repository navigation
fix(http): isolate parent span per request, extend user agent span over transport, and record telemetry errors - #827
Open
Hardik K (hardikkaurani) wants to merge 1 commit into
Conversation
…er transport, and record telemetry errors
Contributor
Author
|
Following up on our middleware work in kiota_http, this PR addresses OpenTelemetry span lifecycle and isolation:
All new unit tests and the full HTTP test suite (pytest packages/http/httpx/tests) pass cleanly locally (205 passed in 68.90s). Whenever convenient, please take a look. |
|
Comment on lines
+72
to
+75
| parent_span = self.parent_span | ||
| if options and (req_parent_span := options.get("parent_span", None)): | ||
| parent_span = req_parent_span | ||
| if parent_span is None: |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Summary
Addresses OpenTelemetry span lifecycle and isolation in
kiota_http:UserAgentHandlerwithin the handler span lifecycle (try...finally: _span.end()) and records downstream pipeline errors via_span.record_exception(exc).parent_spanoptions from mutatingBaseMiddleware.parent_spanon the middleware instance, isolating trace contexts between requests.UrlReplaceHandlerandUserAgentHandler.Fix
middleware.py(BaseMiddleware._create_observability_span):parent_spanlocally instead of mutatingself.parent_span. Subsequent requests processed by the same middleware instance without aparent_spanoption no longer inherit earlier trace spans.user_agent_handler.py(UserAgentHandler.send):if request is None: raise TypeError("request cannot be null")._span.end()into afinallyblock enclosingawait super().send(request, transport)so the span accurately measures full execution and downstream spans remain properly nested._span.record_exception(exc)).url_replace_handler.py(UrlReplaceHandler.send):if request is None: raise TypeError("request cannot be null")._enable_span.record_exception(exc)).test_base_middleware.py: Addedtest_parent_span_option_does_not_mutate_middleware_instanceverifying request options do not leak parent spans across requests.test_user_agent_handler.py: Added tests verifying null request rejection, span enclosing transport, and exception recording on transport failure.test_url_replace_handler.py: Added tests verifying null request rejection and exception recording on transport failure.Testing
cc Vincent Biret (@baywet)