Migrate agentserver tracing from azure-monitor-opentelemetry-exporter…#46561
Merged
Migrate agentserver tracing from azure-monitor-opentelemetry-exporter…#46561
Conversation
… to microsoft-opentelemetry Replace manual Azure Monitor and OTLP exporter wiring (~100 lines) with a single use_microsoft_opentelemetry() call via the new microsoft-opentelemetry distro. The distro auto-detects exporters from environment variables. Changes: - core pyproject.toml: swap azure-monitor-opentelemetry-exporter + otlp-grpc for microsoft-opentelemetry>=0.5.0 - core _tracing.py: refactor _configure_tracing() to delegate to new _setup_distro_export() wrapper; remove 4 _setup_* functions and guard flags - Update all test mocks in core and invocations to patch the single _setup_distro_export target instead of multiple _setup_* functions - Remove azure-monitor-opentelemetry-exporter from dev_requirements.txt in both core and invocations packages Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates AgentServer observability export wiring from manual Azure Monitor + OTLP exporter setup to the microsoft-opentelemetry distro, centralizing configuration behind a single _setup_distro_export() wrapper and updating tests/dev dependencies accordingly.
Changes:
- Replace
azure-monitor-opentelemetry-exporter+ OTLP gRPC exporter dependencies withmicrosoft-opentelemetry>=0.5.0. - Refactor
azure-ai-agentserver-coretracing setup to delegate exporter configuration to the distro (and simplify/remove legacy setup functions/flags). - Update tests to patch
_setup_distro_exportand remove dev requirement references toazure-monitor-opentelemetry-exporter.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/agentserver/azure-ai-agentserver-core/azure/ai/agentserver/core/_tracing.py | Refactors tracing/export configuration to use the microsoft-opentelemetry distro and removes legacy exporter setup logic. |
| sdk/agentserver/azure-ai-agentserver-core/pyproject.toml | Swaps exporter dependencies to microsoft-opentelemetry and removes local uv source for the old exporter. |
| sdk/agentserver/azure-ai-agentserver-core/dev_requirements.txt | Drops local editable install of azure-monitor-opentelemetry-exporter. |
| sdk/agentserver/azure-ai-agentserver-core/tests/test_tracing.py | Updates mocks/assertions to patch the single distro setup function rather than multiple exporter setup functions. |
| sdk/agentserver/azure-ai-agentserver-invocations/tests/test_tracing.py | Updates test patch points to _setup_distro_export. |
| sdk/agentserver/azure-ai-agentserver-invocations/tests/test_span_parenting.py | Updates test patch points to _setup_distro_export. |
| sdk/agentserver/azure-ai-agentserver-invocations/pyproject.toml | Removes azure-monitor-opentelemetry-exporter from dev dependencies and uv sources. |
| sdk/agentserver/azure-ai-agentserver-invocations/dev_requirements.txt | Removes local reference to azure-monitor-opentelemetry-exporter. |
Log a warning in _configure_tracing() when _create_resource() returns None, making it clear that tracing will not be configured. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Fix docstring and inline comment to accurately describe logger suppression (only Azure Core HTTP logging policy, not generic OTel exporters) - Make _ensure_trace_provider idempotent via _agentserver_processors_added guard to prevent duplicate processors on repeated calls - Rename TestSetupAzureMonitor -> TestSetupDistroExport to match new impl Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The invocations min-dependency CI installs the published core package from PyPI, which does not yet have _setup_distro_export. Adding create=True allows the mock to succeed regardless of the installed core version. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The microsoft-opentelemetry distro validates that the instrumentation key is a proper UUID. Replace 'InstrumentationKey=test' with 'InstrumentationKey=00000000-0000-0000-0000-000000000000' in all test files. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The previous requirement >=0.5.0 doesn't exist on PyPI. The latest available release is 0.1.0b1 (just published). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The previous code logged INFO for each exporter configured (e.g. 'Application Insights trace exporter configured.'). This preserves that pattern with a single INFO message when the distro setup succeeds. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The microsoft-opentelemetry distro has Azure Monitor disabled by default. Pass enable_azure_monitor=True and the connection string via azure_monitor_connection_string when a connection string is provided. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adds test_span_parenting_in_appinsights which verifies that a child span created inside request_span is correctly parented in App Insights: - Captures child span ID locally during handler execution - Queries dependencies table by child span ID - Follows operation_ParentId to find the parent invoke_agent span in requests table Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Move module-level set_tracer_provider() calls in invocations unit tests into autouse fixtures. When pytest collects tests it imports ALL modules, even deselected ones. Module-level calls consumed the OTel Once guard before the e2e test could configure the microsoft-opentelemetry distro, causing spans to never reach App Insights. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
RaviPidaparthi
approved these changes
Apr 29, 2026
ankitbko
approved these changes
Apr 29, 2026
The dependency analyzer requires all package dependencies to be listed in shared_requirements.txt. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add :keyword: docstring entries for _setup_distro_export (C4758) - Use dict literal instead of dict() call (R1735) - Add :param: docstring entries for _ensure_trace_provider (C4739) - Suppress protected-access warning on idempotency guard (W0212) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Author
ankitbko
approved these changes
Apr 29, 2026
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.
… to microsoft-opentelemetry
Replace manual Azure Monitor and OTLP exporter wiring (~100 lines) with a single use_microsoft_opentelemetry() call via the new microsoft-opentelemetry distro. The distro auto-detects exporters from environment variables.
Changes:
Description
Please add an informative description that covers that changes made by the pull request and link all relevant issues.
If an SDK is being regenerated based on a new API spec, a link to the pull request containing these API spec changes should be included above.
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines