Skip to content

fix(http): end redirect and CAE retry spans - #735

Open
RKS (rksharma-owg) wants to merge 1 commit into
microsoft:mainfrom
rksharma-owg:fix/http-span-cleanup
Open

fix(http): end redirect and CAE retry spans#735
RKS (rksharma-owg) wants to merge 1 commit into
microsoft:mainfrom
rksharma-owg:fix/http-span-cleanup

Conversation

@rksharma-owg

Copy link
Copy Markdown
Contributor

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 finally block 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, install requirements-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, and mypy 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_http reports an existing import-order issue in unchanged middleware/options/redirect_handler_option.py; the same check fails on clean main at 1d104f2. Pylint emits the same existing suggestion-mode configuration diagnostic on main and this branch while exiting zero. Neither baseline issue is changed here.

Ensure tracing spans end after successful operations, failures, and cancellation, retaining redirect-limit error events.

Fixes microsoft#508
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

httpx: OpenTelemetry spans never end for RedirectHandler_send and retry_cae_response_if_required

1 participant