diff --git a/sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md b/sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md index 940554b92da4..b3ccb76a30e1 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md +++ b/sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md @@ -3,6 +3,8 @@ ## 1.8.8 (Unreleased) ### Features Added +- Set `AZURE_MONITOR_DISTRO_VERSION` environment variable to pass distro version to the exporter + ([#46666](https://github.com/Azure/azure-sdk-for-python/pull/46666)) ### Breaking Changes diff --git a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_constants.py b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_constants.py index 2823f173894a..3226e413928d 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_constants.py +++ b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_constants.py @@ -5,6 +5,7 @@ # -------------------------------------------------------------------------- from azure.monitor.opentelemetry.exporter._constants import ( # pylint: disable=import-error,no-name-in-module + _AZURE_MONITOR_DISTRO_VERSION, _AZURE_MONITOR_DISTRO_VERSION_ARG, ) diff --git a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_utils/configurations.py b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_utils/configurations.py index f323ddffcb01..d6a1c889932b 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_utils/configurations.py +++ b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_utils/configurations.py @@ -37,6 +37,7 @@ from azure.monitor.opentelemetry._constants import ( _AZURE_APP_SERVICE_RESOURCE_DETECTOR_NAME, _AZURE_VM_RESOURCE_DETECTOR_NAME, + _AZURE_MONITOR_DISTRO_VERSION, _FULLY_SUPPORTED_INSTRUMENTED_LIBRARIES, _PREVIEW_INSTRUMENTED_LIBRARIES, BROWSER_SDK_LOADER_CONFIG_ARG, @@ -92,6 +93,7 @@ def _get_configurations(**kwargs) -> Dict[str, ConfigurationValue]: for key, val in kwargs.items(): configurations[key] = val configurations[DISTRO_VERSION_ARG] = VERSION + environ[_AZURE_MONITOR_DISTRO_VERSION] = VERSION _default_disable_logging(configurations) _default_disable_metrics(configurations) diff --git a/sdk/monitor/azure-monitor-opentelemetry/tests/utils/test_configurations.py b/sdk/monitor/azure-monitor-opentelemetry/tests/utils/test_configurations.py index 81caeeda6faf..91cc3e5308b0 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/tests/utils/test_configurations.py +++ b/sdk/monitor/azure-monitor-opentelemetry/tests/utils/test_configurations.py @@ -804,6 +804,12 @@ def test_get_configurations_env_vars_parentbased_trace_id_ratio_non_numeric_valu self.assertEqual(configurations["sampling_arg"], 1.0) self.assertEqual(configurations["sampler_type"], "parentbased_trace_id_ratio") + @patch.dict("os.environ", {}, clear=True) + @patch("opentelemetry.sdk.resources.Resource.create", return_value=TEST_DEFAULT_RESOURCE) + def test_get_configurations_sets_distro_version_env_var(self, resource_create_mock): + _get_configurations() + self.assertEqual(environ.get("AZURE_MONITOR_DISTRO_VERSION"), VERSION) + @patch.dict( "os.environ", {