Repository navigation
opentelemetry-api: truncate byte array attribute values according to spec - #5855
Open
DylanRussell wants to merge 6 commits into
Open
DylanRussell wants to merge 6 commits into
DylanRussell wants to merge 6 commits into
Conversation
…spec Truncate bytes and bytearray attribute values to max_value_length as mandated by the OpenTelemetry Attribute Limits specification. Assisted-by: Gemini
Assisted-by: Gemini
Pull request dashboard statusWaiting on maintainers · refreshed 2026-11-02 18:50 UTC Merge when ready. Status above doesn't look right?
|
Remove redundant max_string_value_length parameter. Assisted-by: Gemini
Assisted-by: Gemini
herin049
approved these changes
Nov 2, 2026
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Byte-array attribute cleaning can emit multiple limit warnings for a single record, violating the specification’s requirement of at most one limit diagnostic per record.
1 open issue
What changed in this PR
This PR extends the API’s attribute cleaner to apply value-length limits to byte arrays and convert mutable bytearray values to immutable bytes.
Changes:
- Truncate byte-array values, including those nested in sequences and mappings.
- Add tests for truncation and immutable conversion.
- Update parameter documentation and add a changelog entry.
| File | Description |
|---|---|
opentelemetry-api/tests/attributes/test_attributes.py |
Adds byte-array truncation, conversion, and nested-value tests. |
opentelemetry-api/src/opentelemetry/attributes/__init__.py |
Applies length limits to byte arrays and converts bytearray to bytes. |
.changelog/5855.fixed |
Documents the byte-array truncation fix. |
Review effort: Balanced
This branch has not been deployed
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.

Truncate
bytesandbytearrayattribute values tomax_value_lengthin_clean_attribute_valueas mandated by the OpenTelemetry Attribute Limits Specification. Mutablebytearrayvalues are also converted to immutablebytesto preserve attribute immutability.Type of change
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.
tox -e precommittox -e typecheck