Skip to content

Fix sign extension on LogRecord flags in low-allocation log marshaler#8493

Draft
thswlsqls wants to merge 1 commit into
open-telemetry:mainfrom
thswlsqls:fix/log-stateless-flags-fixed32
Draft

Fix sign extension on LogRecord flags in low-allocation log marshaler#8493
thswlsqls wants to merge 1 commit into
open-telemetry:mainfrom
thswlsqls:fix/log-stateless-flags-fixed32

Conversation

@thswlsqls

Copy link
Copy Markdown
Contributor

Fixes #

Description

  • LogStatelessMarshaler passes the TraceFlags byte directly into the int-taking serializeFixed32 / sizeFixed32 for LogRecord.flags, so a flags byte with the high bit set sign-extends.
  • 0x80 is then written little-endian as 80 FF FF FF instead of 80 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 sibling LogMarshaler (lines 121, 156).

Testing done

  • Set the shared SPAN_CONTEXT in LowAllocationLogRequestMarshalerTest to TraceFlags.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:check passed (118 tests).
  • Internal package, so no docs/apidiffs/ change. Added a ## Unreleased CHANGELOG.md entry under SDK > Exporters.

@codecov

codecov Bot commented Jun 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.77%. Comparing base (824334c) to head (a7a2f98).

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #8493   +/-   ##
=========================================
  Coverage     78.77%   78.77%           
  Complexity     8579     8579           
=========================================
  Files          1009     1009           
  Lines         28993    28993           
  Branches       3599     3599           
=========================================
  Hits          22839    22839           
  Misses         5311     5311           
  Partials        843      843           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant