Skip to content

[CODE HEALTH] fix nondeterministic pointer iteration order warnings#4035

Open
dbarker wants to merge 2 commits intoopen-telemetry:mainfrom
dbarker:fix_nondeterministic_pointer_iteration_order
Open

[CODE HEALTH] fix nondeterministic pointer iteration order warnings#4035
dbarker wants to merge 2 commits intoopen-telemetry:mainfrom
dbarker:fix_nondeterministic_pointer_iteration_order

Conversation

@dbarker
Copy link
Copy Markdown
Member

@dbarker dbarker commented Apr 26, 2026

Contributes to #2053

Changes

  • clean up memory management of the otlp utils functions
    • OtlpRecordableUtils::PopulateRequest takes in recordables through a const ref nostd::span. Before the method took ownership of the recordables and destroyed them which is unexpected. This PR keeps ownership with the caller.
    • The OTLP proto messages owned by the recordables are not created in a protobuf Arena but the request message is. This results in a deep copy when trying to move the recordable's Span/LogRecord into the request. This PR changes to an explicit deep copy for clarity.
    • Update the PopulateRequest methods to remove local temporary proto messages and only create/modify the request message Arena allocated sub messages directly.
  • add tests to cover corner cases
  • fix the following warnings:

File Line Message
opentelemetry-cpp/exporters/otlp/src/otlp_recordable_utils.cc 86 iteration of pointers is nondeterministic
opentelemetry-cpp/exporters/otlp/src/otlp_recordable_utils.cc 151 iteration of pointers is nondeterministic

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 26, 2026

Codecov Report

❌ Patch coverage is 98.03922% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.09%. Comparing base (d87c130) to head (fcda002).

Files with missing lines Patch % Lines
exporters/otlp/src/otlp_recordable_utils.cc 98.04% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4035      +/-   ##
==========================================
+ Coverage   82.06%   82.09%   +0.04%     
==========================================
  Files         385      385              
  Lines       15891    15891              
==========================================
+ Hits        13039    13044       +5     
+ Misses       2852     2847       -5     
Files with missing lines Coverage Δ
exporters/otlp/src/otlp_recordable_utils.cc 98.39% <98.04%> (+4.64%) ⬆️

... and 3 files with indirect coverage changes

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

@dbarker dbarker marked this pull request as ready for review April 26, 2026 15:42
@dbarker dbarker requested a review from a team as a code owner April 26, 2026 15:42
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