Skip to content

Fix HTTP suppression in AI SDKs#41341

Merged
lmolkova merged 4 commits intoAzure:mainfrom
lmolkova:suppression-http
Jun 21, 2025
Merged

Fix HTTP suppression in AI SDKs#41341
lmolkova merged 4 commits intoAzure:mainfrom
lmolkova:suppression-http

Conversation

@lmolkova
Copy link

we currently produce duplicate HTTP spans when tracing inference and agents SDKs

image

It's caused by incorrect context propagation that in its turn leads to Azure SDK HTTP instrumentation being enabled along with underlying generic requests instrumentation.

Fixing it.

Copilot AI review requested due to automatic review settings May 29, 2025 02:32
@github-actions github-actions bot added AI Agents AI Model Inference Issues related to the client library for Azure AI Model Inference (\sdk\ai\azure-ai-inference) labels May 29, 2025
Copy link
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

Fix HTTP suppression in AI SDKs by correcting context propagation to avoid duplicate HTTP spans

  • Updated change_context calls to accept the span object instead of its internal span_instance across sync and async tracing
  • Added new tests to verify HTTP instrumentation suppression under custom contexts and auto-instrumentation policy
  • Adjusted test imports to include SansIOHTTPPolicy and 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 PipelineClient at the top of the test.
self._client = PipelineClient(endpoint, policies=policies, transport=RequestsTransport())

Copy link
Member

@howieleung howieleung left a comment

Choose a reason for hiding this comment

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

Please change target to feature/azure-ai-agents/1.1.0b2 and feature/azure-ai-agents/1.0.1 for agents.
But I am not sure about the core and inference

@lmolkova lmolkova requested a review from howieleung May 30, 2025 14:50
@lmolkova
Copy link
Author

lmolkova commented May 30, 2025

@howieleung I'll send agent changes in a separate PR, please take another look at this one and #41361, #41362, thanks

@lmolkova lmolkova enabled auto-merge (squash) June 21, 2025 17:13
@lmolkova
Copy link
Author

/azp run python - cosmos - ci

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@lmolkova lmolkova disabled auto-merge June 21, 2025 18:16
@lmolkova
Copy link
Author

/check-enforcer override

@lmolkova lmolkova merged commit 824cc36 into Azure:main Jun 21, 2025
39 of 43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Agents AI Model Inference Issues related to the client library for Azure AI Model Inference (\sdk\ai\azure-ai-inference)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants