opentelemetry-java
opentelemetry-java copied to clipboard
Fix sign extension on LogRecord flags in low-allocation log marshaler
Fixes #
Description
LogStatelessMarshalerpasses theTraceFlagsbytedirectly into theint-takingserializeFixed32/sizeFixed32forLogRecord.flags, so a flags byte with the high bit set sign-extends.0x80is then written little-endian as80 FF FF FFinstead of80 00 00 00, and the JSON renders the sign-extended integer. fixed32 is always 4 bytes, so the size is unaffected — only the byte/JSON content is wrong.- Fix: use
serializeByteAsFixed32/sizeByteAsFixed32, which mask((int) value) & 0xff, matching the non-stateless siblingLogMarshaler(lines 121, 156).
Testing done
- Set the shared
SPAN_CONTEXTinLowAllocationLogRequestMarshalerTesttoTraceFlags.fromByte((byte) 0x80), so the existing relative assertions (validateOutput,validateJsonOutput) compare the stateless and non-stateless paths with the high bit set. Both fail before the fix and pass after. ./gradlew :exporters:otlp:common:checkpassed (118 tests).- Internal package, so no
docs/apidiffs/change. Added a## UnreleasedCHANGELOG.mdentry under SDK > Exporters.
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 91.60%. Comparing base (2c83278) to head (6547604).
:warning: Report is 1 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #8493 +/- ##
============================================
- Coverage 91.61% 91.60% -0.01%
Complexity 10311 10311
============================================
Files 1013 1013
Lines 27260 27260
Branches 3201 3201
============================================
- Hits 24973 24971 -2
- Misses 1560 1561 +1
- Partials 727 728 +1
:umbrella: View full report in Codecov by Harness.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
Ready for review — CI is green.
Thank you for your contribution @thswlsqls! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey.