Add env var to enable/disable custom dimensions truncation limit#45479
Merged
rads-1996 merged 8 commits intoAzure:mainfrom Mar 5, 2026
Merged
Add env var to enable/disable custom dimensions truncation limit#45479rads-1996 merged 8 commits intoAzure:mainfrom
rads-1996 merged 8 commits intoAzure:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a configuration knob to control whether custom-dimensions/custom-properties values are truncated to the default 64KiB limit, aligning runtime behavior with an explicit opt-out environment variable.
Changes:
- Introduces
AZURE_MONITOR_DISABLE_CUSTOM_DIMENSIONS_LIMITand wires it into_filter_custom_propertiesto disable truncation when set to"true". - Updates unit tests to validate truncation behavior for various env var values.
- Updates the package changelog to mention the new behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_utils.py | Adds env-var-controlled truncation logic to _filter_custom_properties. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_constants.py | Defines the new environment variable constant. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/tests/test_utils.py | Expands tests to cover enable/disable truncation behavior via env var values. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md | Notes the new env var behavior in the unreleased changelog. |
Comments suppressed due to low confidence (5)
sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md:11
- This changelog entry link still uses a placeholder PR number ("#XXXXX"). Please replace it with the actual PR number before merge so the release history entry is traceable.
- Add environment variable to disable/enable custom properties truncation
([#45479](https://github.com/Azure/azure-sdk-for-python/pull/45479))
sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_constants.py:358
_constants.pyconsistently prefixes environment variable name constants with_(e.g.,_WEBSITE_SITE_NAME,_FUNCTIONS_WORKER_RUNTIME). To follow the same convention and avoid implying this is part of a public API surface, consider renamingAZURE_MONITOR_DISABLE_CUSTOM_DIMENSIONS_LIMITto_AZURE_MONITOR_DISABLE_CUSTOM_DIMENSIONS_LIMITand updating imports/usages accordingly.
# Custom dimensions limit truncation toggle
AZURE_MONITOR_DISABLE_CUSTOM_DIMENSIONS_LIMIT = "AZURE_MONITOR_DISABLE_CUSTOM_DIMENSIONS_LIMIT"
sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_utils.py:376
max_length = 64 * 1024is recomputed on every iteration of the properties loop. Since it’s a fixed constant, it can be defined once outside the loop (or as a module-level constant) to simplify the control flow slightly and avoid repeated work.
if disable_custom_dimensions_limit:
processed_properties[key] = str(val)
else:
max_length = 64 * 1024
processed_properties[key] = str(val)[:max_length]
sdk/monitor/azure-monitor-opentelemetry-exporter/tests/test_utils.py:75
- In
test_filter_custom_properties_preserves_large_values_after_enable_limit, the test name and inline comment say values larger than 64KiB are not truncated, but the assertions verify the opposite (they expect truncation tomax_length). Please rename/update the test (and comment) to match the behavior being validated (limit enabled => value is truncated unless the disable env var is exactly "true").
def test_filter_custom_properties_preserves_large_values_after_enable_limit(self):
# Ensure values larger than 64KiB are not truncated for all valid/invalid env variable values
disable_values = ["", "False", "truthy", "89", "fALSE", " "]
sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md:15
- The unreleased changelog currently includes both "Add environment variable to disable/enable custom properties truncation" and "Remove custom properties truncation" in the same release section, which is contradictory given truncation is now present by default unless the env var disables it. Please update/remove the older entry (or reword both) so the release notes reflect the actual default behavior and the new opt-out flag accurately.
- Add environment variable to disable/enable custom properties truncation
([#45479](https://github.com/Azure/azure-sdk-for-python/pull/45479))
- Fix io counters import issue in performance counters
([#45286](https://github.com/Azure/azure-sdk-for-python/pull/45286))
- Remove custom properties truncation
([#45118](https://github.com/Azure/azure-sdk-for-python/pull/45118))
15324a3 to
63ba8fc
Compare
JacksonWeber
reviewed
Mar 3, 2026
sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_utils.py
Show resolved
Hide resolved
63ba8fc to
89e324d
Compare
JacksonWeber
approved these changes
Mar 3, 2026
89e324d to
b4caf4c
Compare
hectorhdzg
reviewed
Mar 4, 2026
sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_utils.py
Show resolved
Hide resolved
hectorhdzg
reviewed
Mar 4, 2026
...itor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_constants.py
Show resolved
Hide resolved
b4caf4c to
57026fd
Compare
hectorhdzg
approved these changes
Mar 4, 2026
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
Added a new environment variable,
AZURE_MONITOR_DISABLE_CUSTOM_DIMENSIONS_LIMIT, which, when set totrue, disables the default 64KB size limit on custom dimensions.All SDK Contribution checklist:
General Guidelines and Best Practices