Disable openai-v2 when agent-framework is used#142
Open
rads-1996 wants to merge 1 commit into
Open
Conversation
Member
Author
Contributor
There was a problem hiding this comment.
Pull request overview
This PR attempts to prevent duplicate/crashing OpenAI instrumentation by disabling openai auto-instrumentation when Agent Framework instrumentation is active.
Changes:
- Adds
_AGENT_FRAMEWORK_DISABLED_INSTRUMENTATIONS = ("openai",). - Updates instrumentation setup to auto-disable OpenAI when
agent_frameworkis discovered. - Adds unit tests for Agent Framework/OpenAI instrumentation interactions.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/microsoft/opentelemetry/_constants.py |
Defines the Agent Framework-specific disabled instrumentation list. |
src/microsoft/opentelemetry/_distro.py |
Applies the new auto-disable behavior during instrumentation discovery. |
tests/test_distro.py |
Adds tests for OpenAI enable/disable behavior with Agent Framework present. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+712
to
+718
| if any( | ||
| ep.name == "agent_framework" and _is_instrumentation_enabled(otel_kwargs, ep.name) | ||
| for ep in discovered | ||
| ): | ||
| inst_opts = otel_kwargs.setdefault(INSTRUMENTATION_OPTIONS_ARG, {}) | ||
| for lib in _AGENT_FRAMEWORK_DISABLED_INSTRUMENTATIONS: | ||
| inst_opts.setdefault(lib, {}).setdefault("enabled", False) |
Comment on lines
+716
to
+718
| inst_opts = otel_kwargs.setdefault(INSTRUMENTATION_OPTIONS_ARG, {}) | ||
| for lib in _AGENT_FRAMEWORK_DISABLED_INSTRUMENTATIONS: | ||
| inst_opts.setdefault(lib, {}).setdefault("enabled", False) |
Member
|
Is there a way to programmatically disable OpenAI Spans when using Microsoft Agent Framework?, if we decide to go with current approach, we should only change defaults, if customers explicitly config something on we should always honor that |
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.


No description provided.