-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix attribute value truncation #5997
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5997 +/- ##
=====================================
Coverage 82.1% 82.1%
=====================================
Files 273 273
Lines 23624 23652 +28
=====================================
+ Hits 19406 19437 +31
+ Misses 3873 3870 -3
Partials 345 345 |
ac0f7f3
to
6d3cfee
Compare
Used to evaluate performance impact of changes.
6d3cfee
to
6a43878
Compare
6a43878
to
54c61ac
Compare
What about the value truncation in |
|
I imagine they need to be truncated and limits need to be honored there. This PR is scoped to address the existing bug in the already implemented trace signal. |
Tracking in #6004 |
Fix #5996
Correctness
From the OTel specification:
Our current implementation truncates on number of bytes not characters.
Unit tests are added/updated to validate this fix and prevent regressions.
Performance
Values shorter than limit
This is the default code path. Most attribute values will be shorter than the default 128 limit that users will not modify.
The current code,
safeTruncate
requires a full iteration of the value to determine it is valid and under the limit.The replacement,
truncate
, first checks if the number of bytes in the value are less than or equal to the limit (which guarantees the number of characters are less than or equal to the limit) and returns immediately. This will mean that invalid encoding less than the limit is not changed, which meets the specification requirements.Values longer than the limit
For values who's number of bytes exceeds the limit, they are iterated only once with the replacement,
truncate
.In comparison, the current code,
safeTruncate
, can iterate the string up to three separate times when the string contains invalid characters.