Use constants to decide distro version#46666
Open
rads-1996 wants to merge 2 commits intoAzure:mainfrom
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to propagate the Azure Monitor distro version via configuration so downstream components (notably the exporter / telemetry pipeline) can identify the distro version consistently.
Changes:
- Adds a distro-version env var write during
_get_configurations(). - Re-exports a new constant from the exporter constants module to avoid duplicating the env var name.
- Adds a unit test asserting the env var is set during configuration.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_constants.py | Imports/re-exports exporter constants intended to standardize distro version keys. |
| sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_utils/configurations.py | Sets the distro version env var when building configurations. |
| sdk/monitor/azure-monitor-opentelemetry/tests/utils/test_configurations.py | Adds coverage to validate the env var gets set. |
| for key, val in kwargs.items(): | ||
| configurations[key] = val | ||
| configurations[DISTRO_VERSION_ARG] = VERSION | ||
| environ[_AZURE_MONITOR_DISTRO_VERSION] = VERSION |
There was a problem hiding this comment.
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) |
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.
Description
Pass the azure monitor distro version the exporter to set the telemetry sdk version, which is then passed on application insights.
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines