-
Notifications
You must be signed in to change notification settings - Fork 477
[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
[EXPORTER] ostream log exporter, fix memory ownership issues #3417
Conversation
✅ Deploy Preview for opentelemetry-cpp-api-docs canceled.
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3417 +/- ##
==========================================
- Coverage 90.06% 89.86% -0.19%
==========================================
Files 212 212
Lines 6937 6941 +4
==========================================
- Hits 6247 6237 -10
- Misses 690 704 +14
🚀 New features to boost your workflow:
|
There was a problem hiding this 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 :)
Is this a breaking change if |
Seems #3147 includes the renaming to |
Added an important changes section in the CHANGELOG, to address @ThomsonTan comments. Waiting for @owent approval, as an alternative fix to PR #3147. |
Additional testing:
|
This changes API, and may make users can not compile. Personally, I prefer to use #3147, which only change the APIs in v2 version. |
See related discussion #3147 (comment) |
Sorry, I shouldn't use the ABI version macro. My goal is to allow users time to migrate their code when upgrading otel-cpp, rather than causing immediate compilation errors. |
Thanks for clarifying. As I understand it, compile-time errors would only occur in the following cases:
None of the core processors and exporters are affected by this change. Given that this is likely a small subset of users, I think introducing these breaking changes should be fine. The changelog should clearly specify the migration steps for affected users in this scenario. |
Yes, but in #3147 , a new record class |
The changelog already gives details about this, in the important changes section. I agree that the potential build break will affect only a small subset of users, which is why this should be fine. Also, note that people affected by the build break will be users who deliberately reuse some SDK classes in their own implementation: they should be fully aware of risks when choosing to do so.
The comment about ABI changes in the SDK is technically correct, as However, I think this comment should not be blocking: opentelemetry-cpp does not guarantee binary stability for the SDK implementation, so if an SDK class changes, it changes. The rationale for creating yet another class like LogRecordData is to preserve a binary compatible This entire fix (the present PR) is +70 -57 lines, and this includes the documentation in the changelog, and unit tests adjustments. Please, let's not blow the fix scope out of proportions, when it can be done simply. |
OK, I closed #3147, let's use this PR. |
Fixes #3135
Fixes #2651
Changes
Fixed the following memory ownership issues in the ostream log exporter:
ReadWriteLogRecord
, memberbody_
now owns a copy of the log bodyReadWriteLogRecord
, memberattributes_map_
now owns a copy of log attributesThis 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