Skip to content
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

[pdata] Enable the pdata mutation safeguards in the fanout consumers #8634

Merged

Conversation

dmitryax
Copy link
Member

@dmitryax dmitryax commented Oct 7, 2023

This change enables the runtime assertions to catch unintentional pdata mutations in components claiming as non-mutating pdata. Without these assertions, runtime errors may still occur, but thrown by unrelated components, making it very difficult to troubleshoot.

This required introducing extra API to get the pdata mutability state:

  • p[metric|trace|log].[Metrics|Traces|Logs].IsReadOnly()

Resolves: #6794

@dmitryax dmitryax requested review from a team and jpkrohling October 7, 2023 00:25
@dmitryax dmitryax force-pushed the enable-pdata-mutation-safeguard branch 2 times, most recently from d6855ae to af945d7 Compare October 7, 2023 00:27
@codecov
Copy link

codecov bot commented Oct 7, 2023

Codecov Report

All modified lines are covered by tests ✅

Files Coverage Δ
internal/fanoutconsumer/logs.go 100.00% <100.00%> (ø)
internal/fanoutconsumer/metrics.go 100.00% <100.00%> (ø)
internal/fanoutconsumer/traces.go 100.00% <100.00%> (ø)
pdata/plog/logs.go 100.00% <100.00%> (ø)
pdata/pmetric/metrics.go 100.00% <100.00%> (ø)
pdata/ptrace/traces.go 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

📢 Thoughts on this report? Let us know!.

@dmitryax dmitryax force-pushed the enable-pdata-mutation-safeguard branch 3 times, most recently from e9607bb to 6aa4367 Compare October 7, 2023 04:38
internal/fanoutconsumer/logs.go Outdated Show resolved Hide resolved
internal/fanoutconsumer/logs.go Outdated Show resolved Hide resolved
internal/fanoutconsumer/metrics.go Show resolved Hide resolved
internal/fanoutconsumer/logs.go Outdated Show resolved Hide resolved
@dmitryax dmitryax force-pushed the enable-pdata-mutation-safeguard branch 3 times, most recently from 7fb8350 to 7cbd3e2 Compare October 10, 2023 23:54
Copy link
Member

@bogdandrutu bogdandrutu left a comment

Choose a reason for hiding this comment

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

I like more the logs code.

This required introducing extra API to get the pdata mutability state:
- p[metric|trace|log].[Metrics|Traces|Logs].IsReadOnly()
@dmitryax dmitryax force-pushed the enable-pdata-mutation-safeguard branch from 7cbd3e2 to 6d9cb0f Compare October 16, 2023 15:47
@dmitryax
Copy link
Member Author

I like more the logs code.

Ok, I applied this approach on other data types

@dmitryax dmitryax merged commit 8a385c2 into open-telemetry:main Oct 16, 2023
31 checks passed
@github-actions github-actions bot added this to the next release milestone Oct 16, 2023
@dmitryax dmitryax deleted the enable-pdata-mutation-safeguard branch October 17, 2023 05:44
dmitryax added a commit that referenced this pull request Oct 17, 2023
A follow-up optimization after merging
#8634.

There is no need to create a fanout consumer for only one read-only
consumer. This introduces a behavior that closely resembles its previous
state, before the introduction of the readonly/mutable states.
mx-psi added a commit that referenced this pull request Aug 2, 2024
#10632)

The primary objective here was to add new test cases for the graph.
However, I found that mutability assertions added in #8634 appear to be
nondeterministic. Therefore, important test cases cannot be covered with
them in place. This effectively removes the assertions about mutability
for now.

@dmitryax, I'm curious if you have better ideas here. I am thinking that
perhaps it would be better to have an entirely separate set of test
cases which are focused on mutability expectations.

Co-authored-by: Pablo Baeyens <pablo.baeyens@datadoghq.com>
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.

Proposal: New way of handling data mutability
2 participants