Skip to content

Modify logic to add providers when azure monitor config is disabled - #24

Merged
Radhika Gupta (rads-1996) merged 4 commits into
microsoft:mainfrom
rads-1996:fix-duplicate-provider-setup
Apr 10, 2026
Merged

Radhika Gupta (rads-1996) merged 4 commits into
microsoft:mainfrom
rads-1996:fix-duplicate-provider-setup

Conversation

@rads-1996

Copy link
Copy Markdown
Member

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates use_microsoft_opentelemetry() orchestration so that when Azure Monitor is explicitly disabled, the distro still initializes “bare” OpenTelemetry providers, while Azure Monitor-enabled scenarios delegate provider creation/configuration to Azure Monitor setup.

Changes:

  • Move core provider initialization to the enable_azure_monitor=False path (create tracing/metrics/logging providers even without an exporter).
  • Delegate Azure Monitor-enabled setup entirely to _setup_azure_monitor(**merged) and run instrumentations after providers are set.
  • Update unit tests and add a changelog entry reflecting the new behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/microsoft/opentelemetry/_distro.py Restructures provider initialization vs. Azure Monitor setup and reorders instrumentation setup.
tests/test_distro.py Updates mocks/assertions to match the new orchestration and disabled-Azure-Monitor provider behavior.
CHANGELOG.md Documents the behavior change in release notes.
Comments suppressed due to low confidence (1)

tests/test_distro.py:167

  • test_setup_tracing_adds_span_processors now calls _setup_tracing() without patching set_tracer_provider, so it mutates global OpenTelemetry state and can make this test order-dependent. It also doesn’t assert that the span processor was actually added (despite the comment). Patch set_tracer_provider (as in the previous test) and assert that the created provider contains the supplied processor.
    def test_setup_tracing_adds_span_processors(self):
        """_setup_tracing adds user-supplied span processors."""
        sp = MagicMock()
        tp = _setup_tracing(TEST_RESOURCE, {"span_processors": [sp]})
        # Processor is in the provider's active span processors
        self.assertIsInstance(tp, TracerProvider)


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/microsoft/opentelemetry/_distro.py Outdated
Comment thread CHANGELOG.md
Comment thread src/microsoft/opentelemetry/_distro.py
@rads-1996
Radhika Gupta (rads-1996) merged commit f51964d into microsoft:main Apr 10, 2026
7 checks passed
@rads-1996
Radhika Gupta (rads-1996) deleted the fix-duplicate-provider-setup branch April 10, 2026 17:31
Comment thread src/microsoft/opentelemetry/_distro.py
Copilot AI mentioned this pull request Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants