From 4375ffc0149339849225fdd5a2736a5b78c5d0c3 Mon Sep 17 00:00:00 2001 From: Leighton Chen Date: Thu, 6 Aug 2026 12:02:33 -0400 Subject: [PATCH 1/3] Enable OneSettings config manager in azure-monitor-opentelemetry distro Bump azure-monitor-opentelemetry-exporter minimum dependency to 1.0.0b56 and contribute distro profile fields (component=dst, distro version) to the OneSettings control plane during configure_azure_monitor. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b13aa0ee-c777-4719-a18e-21985cf46358 --- .../azure-monitor-opentelemetry/CHANGELOG.md | 4 + .../azure/monitor/opentelemetry/_configure.py | 14 +++ .../azure-monitor-opentelemetry/setup.py | 2 +- .../tests/test_configure.py | 85 ++++++++++++++++++- 4 files changed, 103 insertions(+), 2 deletions(-) diff --git a/sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md b/sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md index 236ca51c0c0c..6df9762ee924 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md +++ b/sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md @@ -11,6 +11,10 @@ ### Bugs Fixed ### Other Changes +- Contribute distro profile information (`component="dst"` and distro version) to the OneSettings control plane during `configure_azure_monitor` + ([#TBD](https://github.com/Azure/azure-sdk-for-python/pull/TBD)) +- Update `azure-monitor-opentelemetry-exporter` minimum dependency to `1.0.0b56` + ([#TBD](https://github.com/Azure/azure-sdk-for-python/pull/TBD)) ## 1.8.9 (2026-07-01) diff --git a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py index 11ed74b9e5c6..27897690f062 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py +++ b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py @@ -84,6 +84,9 @@ _is_attach_enabled, _is_on_functions, ) +from azure.monitor.opentelemetry.exporter._configuration._state import ( # pylint: disable=import-error,no-name-in-module + get_configuration_manager, +) from azure.monitor.opentelemetry._diagnostics.diagnostic_logging import ( _DISTRO_DETECTS_ATTACH, AzureDiagnosticLogging, @@ -145,6 +148,17 @@ def configure_azure_monitor(**kwargs) -> None: # pylint: disable=C4758 configurations = _get_configurations(**kwargs) + # Contribute distro-level profile fields to the OneSettings control plane before any exporter is + # created. initialize() is idempotent and _ConfigurationProfile.fill() is first-wins per field, so + # setting component="dst" and the distro version here makes the profile reflect the distro; the + # exporters created below still supply ikey/region without overriding these already-set fields. + config_manager = get_configuration_manager() + if config_manager: + config_manager.initialize( + component="dst", + version=VERSION, + ) + disable_tracing = configurations[DISABLE_TRACING_ARG] disable_logging = configurations[DISABLE_LOGGING_ARG] disable_metrics = configurations[DISABLE_METRICS_ARG] diff --git a/sdk/monitor/azure-monitor-opentelemetry/setup.py b/sdk/monitor/azure-monitor-opentelemetry/setup.py index b0b88c3ff9c9..b710df9b8da5 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/setup.py +++ b/sdk/monitor/azure-monitor-opentelemetry/setup.py @@ -83,7 +83,7 @@ install_requires=[ "azure-core<2.0.0,>=1.28.0", "azure-core-tracing-opentelemetry~=1.0.0b11", - "azure-monitor-opentelemetry-exporter~=1.0.0b54", + "azure-monitor-opentelemetry-exporter~=1.0.0b56", "opentelemetry-sdk~=1.43.0", "opentelemetry-instrumentation-django>=0.64b0,<0.65.0", "opentelemetry-instrumentation-fastapi>=0.64b0,<0.65.0", diff --git a/sdk/monitor/azure-monitor-opentelemetry/tests/test_configure.py b/sdk/monitor/azure-monitor-opentelemetry/tests/test_configure.py index dbb9f1b8538b..9bf3ef2a1400 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/tests/test_configure.py +++ b/sdk/monitor/azure-monitor-opentelemetry/tests/test_configure.py @@ -28,7 +28,7 @@ configure_azure_monitor, ) from azure.monitor.opentelemetry._diagnostics.diagnostic_logging import _DISTRO_DETECTS_ATTACH - +from azure.monitor.opentelemetry._version import VERSION TEST_RESOURCE = Resource({"foo": "bar"}) @@ -53,8 +53,12 @@ class TestConfigure(unittest.TestCase): @patch( "azure.monitor.opentelemetry._configure._setup_tracing", ) + @patch( + "azure.monitor.opentelemetry._configure.get_configuration_manager", + ) def test_configure_azure_monitor( self, + get_config_manager_mock, tracing_mock, logging_mock, metrics_mock, @@ -73,6 +77,85 @@ def test_configure_azure_monitor( instrumentation_mock.assert_called_once() detect_attach_mock.assert_called_once() + @patch( + "azure.monitor.opentelemetry._configure._send_attach_warning", + ) + @patch( + "azure.monitor.opentelemetry._configure._setup_instrumentations", + ) + @patch( + "azure.monitor.opentelemetry._configure._setup_live_metrics", + ) + @patch( + "azure.monitor.opentelemetry._configure._setup_metrics", + ) + @patch( + "azure.monitor.opentelemetry._configure._setup_logging", + ) + @patch( + "azure.monitor.opentelemetry._configure._setup_tracing", + ) + @patch( + "azure.monitor.opentelemetry._configure.get_configuration_manager", + ) + def test_configure_azure_monitor_initializes_config_manager( + self, + get_config_manager_mock, + tracing_mock, + logging_mock, + metrics_mock, + live_metrics_mock, + instrumentation_mock, + detect_attach_mock, + ): + config_manager_mock = Mock() + get_config_manager_mock.return_value = config_manager_mock + configure_azure_monitor(connection_string="test_cs") + # Distro contributes component="dst" and its version before any exporter is created. + config_manager_mock.initialize.assert_called_once_with( + component="dst", + version=VERSION, + ) + + @patch( + "azure.monitor.opentelemetry._configure._send_attach_warning", + ) + @patch( + "azure.monitor.opentelemetry._configure._setup_instrumentations", + ) + @patch( + "azure.monitor.opentelemetry._configure._setup_live_metrics", + ) + @patch( + "azure.monitor.opentelemetry._configure._setup_metrics", + ) + @patch( + "azure.monitor.opentelemetry._configure._setup_logging", + ) + @patch( + "azure.monitor.opentelemetry._configure._setup_tracing", + ) + @patch( + "azure.monitor.opentelemetry._configure.get_configuration_manager", + ) + def test_configure_azure_monitor_config_manager_disabled( + self, + get_config_manager_mock, + tracing_mock, + logging_mock, + metrics_mock, + live_metrics_mock, + instrumentation_mock, + detect_attach_mock, + ): + # When the control plane is disabled, get_configuration_manager returns None and the distro + # skips initialize() without raising. + get_config_manager_mock.return_value = None + configure_azure_monitor(connection_string="test_cs") + tracing_mock.assert_called_once() + logging_mock.assert_called_once() + metrics_mock.assert_called_once() + @patch( "azure.monitor.opentelemetry._configure._setup_instrumentations", ) From 2818c876cb64d6c00bb1fd5763186044f2129b7d Mon Sep 17 00:00:00 2001 From: Leighton Chen Date: Thu, 6 Aug 2026 12:11:08 -0400 Subject: [PATCH 2/3] Patch get_configuration_manager in distro configure tests setUp Prevent configure_azure_monitor tests from starting the real OneSettings worker thread by patching get_configuration_manager for every test. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b13aa0ee-c777-4719-a18e-21985cf46358 --- .../tests/test_configure.py | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/sdk/monitor/azure-monitor-opentelemetry/tests/test_configure.py b/sdk/monitor/azure-monitor-opentelemetry/tests/test_configure.py index 9bf3ef2a1400..62fe78dbb3c5 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/tests/test_configure.py +++ b/sdk/monitor/azure-monitor-opentelemetry/tests/test_configure.py @@ -35,6 +35,14 @@ # pylint: disable=too-many-public-methods class TestConfigure(unittest.TestCase): + def setUp(self): + # Patch get_configuration_manager for every test so configure_azure_monitor never starts the + # real OneSettings worker thread. Tests that care about the interaction use + # self._get_config_manager_mock to control the returned manager. + patcher = patch("azure.monitor.opentelemetry._configure.get_configuration_manager") + self._get_config_manager_mock = patcher.start() + self.addCleanup(patcher.stop) + @patch( "azure.monitor.opentelemetry._configure._send_attach_warning", ) @@ -53,12 +61,8 @@ class TestConfigure(unittest.TestCase): @patch( "azure.monitor.opentelemetry._configure._setup_tracing", ) - @patch( - "azure.monitor.opentelemetry._configure.get_configuration_manager", - ) def test_configure_azure_monitor( self, - get_config_manager_mock, tracing_mock, logging_mock, metrics_mock, @@ -95,12 +99,8 @@ def test_configure_azure_monitor( @patch( "azure.monitor.opentelemetry._configure._setup_tracing", ) - @patch( - "azure.monitor.opentelemetry._configure.get_configuration_manager", - ) def test_configure_azure_monitor_initializes_config_manager( self, - get_config_manager_mock, tracing_mock, logging_mock, metrics_mock, @@ -108,8 +108,7 @@ def test_configure_azure_monitor_initializes_config_manager( instrumentation_mock, detect_attach_mock, ): - config_manager_mock = Mock() - get_config_manager_mock.return_value = config_manager_mock + config_manager_mock = self._get_config_manager_mock.return_value configure_azure_monitor(connection_string="test_cs") # Distro contributes component="dst" and its version before any exporter is created. config_manager_mock.initialize.assert_called_once_with( @@ -135,12 +134,8 @@ def test_configure_azure_monitor_initializes_config_manager( @patch( "azure.monitor.opentelemetry._configure._setup_tracing", ) - @patch( - "azure.monitor.opentelemetry._configure.get_configuration_manager", - ) def test_configure_azure_monitor_config_manager_disabled( self, - get_config_manager_mock, tracing_mock, logging_mock, metrics_mock, @@ -150,7 +145,7 @@ def test_configure_azure_monitor_config_manager_disabled( ): # When the control plane is disabled, get_configuration_manager returns None and the distro # skips initialize() without raising. - get_config_manager_mock.return_value = None + self._get_config_manager_mock.return_value = None configure_azure_monitor(connection_string="test_cs") tracing_mock.assert_called_once() logging_mock.assert_called_once() From 3f68475b4692da302cd95894afa6016868079b5f Mon Sep 17 00:00:00 2001 From: Leighton Chen Date: Fri, 7 Aug 2026 16:23:05 -0400 Subject: [PATCH 3/3] Update CHANGELOG PR links to #48475 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b13aa0ee-c777-4719-a18e-21985cf46358 --- sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md b/sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md index 6df9762ee924..aa3775a925d0 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md +++ b/sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md @@ -12,9 +12,9 @@ ### Other Changes - Contribute distro profile information (`component="dst"` and distro version) to the OneSettings control plane during `configure_azure_monitor` - ([#TBD](https://github.com/Azure/azure-sdk-for-python/pull/TBD)) + ([#48475](https://github.com/Azure/azure-sdk-for-python/pull/48475)) - Update `azure-monitor-opentelemetry-exporter` minimum dependency to `1.0.0b56` - ([#TBD](https://github.com/Azure/azure-sdk-for-python/pull/TBD)) + ([#48475](https://github.com/Azure/azure-sdk-for-python/pull/48475)) ## 1.8.9 (2026-07-01)