fix(http): end redirect and CAE retry spans - #735
Open
RKS (rksharma-owg) wants to merge 1 commit into
Open
Conversation
Ensure tracing spans end after successful operations, failures, and cancellation, retaining redirect-limit error events. Fixes microsoft#508
|
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.



Overview
Redirect-attempt spans and CAE retry-decision spans remain open after successful HTTP operations because their normal exit paths never end them. End each span in a
finallyblock so returns, redirects, transport errors, and cancellation all release it. Record the existing redirect-limit exception before ending its span, and keep the CAE span open until its awaited retry finishes.Regression tests use real OpenTelemetry spans with an in-memory exporter. They cover successful and disabled redirects, redirect chains and limits, transport failures and cancellation, each no-retry CAE path, and successful or interrupted retries. The existing CAE integration test also verifies both recursive decision spans are exported.
Related Issue
Fixes #508
Testing Instructions
From
packages/http/httpx, installrequirements-dev.txt, then run:pytest: 124 tests passed on Python 3.12.pytest tests/middleware_tests/test_redirect_handler.py tests/test_httpx_request_adapter.py -q: 77 passed. All 14 added regression cases failed against the unmodified implementation.yapf -dr kiota_http,pylint kiota_http --disable=W --rcfile=.pylintrc, andmypy kiota_http: exited successfully; mypy checked 24 source files.isort --check-only kiota_http/httpx_request_adapter.py kiota_http/middleware/redirect_handler.py: passed.uv build: source distribution and wheel built successfully.The package-wide
isort --check-only kiota_httpreports an existing import-order issue in unchangedmiddleware/options/redirect_handler_option.py; the same check fails on clean main at1d104f2. Pylint emits the same existingsuggestion-modeconfiguration diagnostic on main and this branch while exiting zero. Neither baseline issue is changed here.