Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# --------------------------------------------------------------------------

from azure.monitor.opentelemetry.exporter._constants import ( # pylint: disable=import-error,no-name-in-module
Comment thread
rads-1996 marked this conversation as resolved.
_AZURE_MONITOR_DISTRO_VERSION,
_AZURE_MONITOR_DISTRO_VERSION_ARG,
)

Comment thread
rads-1996 marked this conversation as resolved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

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

Setting the distro version into os.environ here overwrites any existing value each time _get_configurations() is called. If the intent is just to provide a default for downstream components, consider using environ.setdefault(...) (similar to _default_resource) so user/host-provided values aren’t clobbered.

Suggested change
environ[_AZURE_MONITOR_DISTRO_VERSION] = VERSION
environ.setdefault(_AZURE_MONITOR_DISTRO_VERSION, VERSION)

Copilot uses AI. Check for mistakes.

_default_disable_logging(configurations)
_default_disable_metrics(configurations)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Comment thread
rads-1996 marked this conversation as resolved.
@patch.dict(
"os.environ",
{
Expand Down
Loading