Skip to content

[EXPORTER] ostream log exporter, fix memory ownership issues #3417

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

marcalff
Copy link
Member

@marcalff marcalff commented May 15, 2025

Fixes #3135
Fixes #2651

Changes

Fixed the following memory ownership issues in the ostream log exporter:

  • In class ReadWriteLogRecord, member body_ now owns a copy of the log body
  • In class ReadWriteLogRecord, member attributes_map_ now owns a copy of log attributes

This prevents the use of stale pointers, that could lead to crashes previously.

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

Copy link

netlify bot commented May 15, 2025

Deploy Preview for opentelemetry-cpp-api-docs canceled.

Name Link
🔨 Latest commit 064b082
🔍 Latest deploy log https://app.netlify.com/projects/opentelemetry-cpp-api-docs/deploys/682766dc4eefc000098b2b28

@marcalff marcalff changed the title POC, alternate fix for log record lifecycle. [POC], [ALTERNATE], Fix lifetime for sdk::ReadWriteLogRecord May 15, 2025
Copy link

codecov bot commented May 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.87%. Comparing base (44018b0) to head (064b082).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3417      +/-   ##
==========================================
- Coverage   90.01%   89.87%   -0.13%     
==========================================
  Files         212      212              
  Lines        6932     6936       +4     
==========================================
- Hits         6239     6233       -6     
- Misses        693      703      +10     
Files with missing lines Coverage Δ
sdk/src/logs/read_write_log_record.cc 96.43% <100.00%> (+0.05%) ⬆️

... and 8 files with indirect coverage changes

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

@marcalff marcalff changed the title [POC], [ALTERNATE], Fix lifetime for sdk::ReadWriteLogRecord [EXPORTER] ostream log exporter, fixed memory ownership issues May 15, 2025
@marcalff marcalff marked this pull request as ready for review May 15, 2025 20:49
@marcalff marcalff requested a review from a team as a code owner May 15, 2025 20:49
@marcalff marcalff changed the title [EXPORTER] ostream log exporter, fixed memory ownership issues [EXPORTER] ostream log exporter, fix memory ownership issues May 15, 2025
Copy link
Member

@lalitb lalitb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done, thanks. I would ideally prefer to get rid of ReadableLogRecord, and just have ReadWriteLogRecord (probably renamed to LogData), and so have the API consistent with SpanData, but that's not related to the issue :)

@ThomsonTan
Copy link
Contributor

Is this a breaking change if ReadWriteLogRecord is used by the user? Mention this in the changelog if so.

@ThomsonTan
Copy link
Contributor

Nicely done, thanks. I would ideally prefer to get rid of ReadableLogRecord, and just have ReadWriteLogRecord (probably renamed to LogData), and so have the API consistent with SpanData, but that's not related to the issue :)

Seems #3147 includes the renaming to LogRecordData.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants