Skip to content

[Corehttp] Add tracing query param sanitization#46657

Merged
pvaneck merged 1 commit intoAzure:mainfrom
pvaneck:corehttp-query
May 8, 2026
Merged

[Corehttp] Add tracing query param sanitization#46657
pvaneck merged 1 commit intoAzure:mainfrom
pvaneck:corehttp-query

Conversation

@pvaneck
Copy link
Copy Markdown
Member

@pvaneck pvaneck commented May 1, 2026

This adds sanitization to URL query parameters that are set as span attributes.

Port of: #46482

@pvaneck pvaneck force-pushed the corehttp-query branch 2 times, most recently from a6741fa to 556f4c0 Compare May 7, 2026 22:10
@pvaneck pvaneck requested a review from Copilot May 7, 2026 22:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes corehttp tracing safer by default by sanitizing URL query parameter values before recording them as span attributes, while still allowing users to opt-in specific query parameters to remain visible.

Changes:

  • Add sanitize_url utility to redact non-allowlisted query parameter values (default placeholder REDACTED).
  • Introduce additional_allowed_query_params on DistributedHttpTracingPolicy, with a default allowlist including api-version.
  • Add CaseInsensitiveSet to support case-insensitive allowlist checks and expand/update tests and changelog accordingly.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
sdk/core/corehttp/corehttp/runtime/policies/_distributed_tracing.py Sanitizes url.full span attribute and adds allowlist configuration via additional_allowed_query_params.
sdk/core/corehttp/corehttp/runtime/policies/_utils.py Adds sanitize_url helper used by tracing to redact query parameter values.
sdk/core/corehttp/corehttp/utils/_utils.py Adds CaseInsensitiveSet used for case-insensitive allowlist membership checks.
sdk/core/corehttp/tests/test_utils.py Adds unit tests for sanitize_url and CaseInsensitiveSet.
sdk/core/corehttp/tests/test_tracing_policy.py Updates existing tracing assertions and adds new tests validating default/custom sanitization behavior.
sdk/core/corehttp/CHANGELOG.md Documents the new tracing allowlist knob and the default sanitization behavior change.

Comment thread sdk/core/corehttp/corehttp/utils/_utils.py Outdated
Comment thread sdk/core/corehttp/corehttp/runtime/policies/_distributed_tracing.py Outdated
Comment thread sdk/core/corehttp/corehttp/runtime/policies/_utils.py Outdated
@pvaneck pvaneck marked this pull request as ready for review May 7, 2026 23:29
@pvaneck pvaneck requested a review from kashifkhan May 7, 2026 23:29
Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
@pvaneck pvaneck merged commit 4d87661 into Azure:main May 8, 2026
38 of 40 checks passed
@pvaneck pvaneck deleted the corehttp-query branch May 8, 2026 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants