Fix HTTP suppression in AI SDKs#41341
Merged
lmolkova merged 4 commits intoAzure:mainfrom Jun 21, 2025
Merged
Conversation
added 2 commits
May 28, 2025 18:43
Contributor
There was a problem hiding this comment.
Pull Request Overview
Fix HTTP suppression in AI SDKs by correcting context propagation to avoid duplicate HTTP spans
- Updated
change_contextcalls to accept the span object instead of its internalspan_instanceacross sync and async tracing - Added new tests to verify HTTP instrumentation suppression under custom contexts and auto-instrumentation policy
- Adjusted test imports to include
SansIOHTTPPolicyand context API for suppression checks
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| sdk/core/azure-core-tracing-opentelemetry/tests/test_tracing_implementations.py | Added tests for HTTP suppression under change_context and auto-instrumentation policy; updated imports |
| sdk/ai/azure-ai-inference/azure/ai/inference/tracing.py | Switched change_context usage to accept span instead of span.span_instance for both sync and async methods |
| sdk/ai/azure-ai-agents/azure/ai/agents/telemetry/_ai_agents_instrumentor.py | Updated multiple change_context calls to accept the span object rather than its span_instance |
Comments suppressed due to low confidence (2)
sdk/core/azure-core-tracing-opentelemetry/tests/test_tracing_implementations.py:145
- The import 'HttpRequest' is not used in this test and can be removed to clean up unused dependencies.
from azure.core.rest import HttpRequest
sdk/core/azure-core-tracing-opentelemetry/tests/test_tracing_implementations.py:159
- The symbol 'PipelineClient' is not imported in this test, leading to a NameError. Add
from azure.core.pipeline import PipelineClientat the top of the test.
self._client = PipelineClient(endpoint, policies=policies, transport=RequestsTransport())
jhakulin
approved these changes
May 29, 2025
pvaneck
approved these changes
May 29, 2025
howieleung
requested changes
May 29, 2025
Author
|
@howieleung I'll send agent changes in a separate PR, please take another look at this one and #41361, #41362, thanks |
This was referenced May 30, 2025
howieleung
approved these changes
Jun 20, 2025
Author
|
/azp run python - cosmos - ci |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Author
|
/check-enforcer override |
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.
we currently produce duplicate HTTP spans when tracing inference and agents SDKs
It's caused by incorrect context propagation that in its turn leads to Azure SDK HTTP instrumentation being enabled along with underlying generic
requestsinstrumentation.Fixing it.