-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[pdata] Introduce runtime safeguards to catch incorrect pdata mutations #8494
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
Conversation
df2fb46
to
14d4455
Compare
Codecov ReportAttention:
📢 Thoughts on this report? Let us know!. |
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.
Thanks for taking this on @dmitryax, have you run benchmarks to compare the results of this change?
14d4455
to
6a06d44
Compare
@codeboten the performance should not be affected because the additional field is a part of a struct that stays on the memory stack. I added some benchmarks from my previous work to confirm it: Before:
After:
|
930fc3d
to
5738a36
Compare
Updated PR to add coverage for panics. Had to make some related chores in pdatagen that I moved to another PR #8537 |
ad0779d
to
2cd811d
Compare
da33394
to
a1692b7
Compare
3621036
to
ad98f6d
Compare
This change introduces an option to enable runtime assertions to catch unintentional pdata mutations in components that are claimed as non-mutating pdata. Without these assertions, runtime errors may still occur, but thrown by unrelated components, making it difficult to troubleshoot the problem. For now, this doesn't change the default behavior. It just introduces a new method on [Metrics/Traces|Logs].Shared. The method will be applied to fan out consumers in the next PR. This change unblocks the 1.0 release of pdata. Going-forward we may introduce copy-on-write solution which won't require the runtime assertions. That will be likely part of 2.0 release.
ad98f6d
to
9f7ce90
Compare
This change introduces an option to enable runtime assertions to catch unintentional pdata mutations in components that are claimed as non-mutating pdata. Without these assertions, runtime errors may still occur, but thrown by unrelated components, making it very difficult to troubleshoot.
For now, this doesn't change the default behavior. It just introduces a new method on
[Metrics/Traces|Logs].Shared()
that returns pdata marked as shared. The method will be applied to fan-out consumers in the next PR.Later, if we want to remove the need of
MutatesData
capability, we can introduce another method[Metrics/Traces|Logs].Exclusive()
which returns a copy of the pdata if it's shared.This change unblocks the 1.0 release by implementing the original solution proposed by @bogdandrutu in #6794. Going forward, we may introduce a copy-on-write solution that doesn't require the runtime assertions. That will likely be part of the 2.0 release.