Skip to content

Fix HTTP suppression in AI SDKs #41341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

lmolkova
Copy link
Member

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 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 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
Member 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

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.

4 participants