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

fix(tracing): Protect from concurrent reads/writes to Span Tags, Contexts, Data #609

Merged
merged 5 commits into from
Apr 4, 2023

Conversation

tonyo
Copy link
Contributor

@tonyo tonyo commented Mar 29, 2023

Span.SetTag(), Span.SetData(), Span.SetContext(), and Span.toEvent() read and write to underlying Span.Tags, Span.Data, and Span.contexts maps, which might read to panics if the operations are not synchronized.

This PR adds a mutex that makes sure that those methods are not executed in parallel.

Note: this doesn't protect from the situation when Set* methods are called on a span that has already been finished. It's tracked separately in #587

…exts, Data

Span.SetTag(), Span.SetData(), Span.SetContext(), and Span.toEvent() read and
write to underlying Span.Tags, Span.Data, and Span.contexts maps,
which might read to panics if the operations are not synchronized.

This PR adds a mutex that makes sure that those methods are not executed
in parallel.
@codecov
Copy link

codecov bot commented Mar 29, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.02 ⚠️

Comparison is base (0d7c935) 79.92% compared to head (db897d6) 79.91%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #609      +/-   ##
==========================================
- Coverage   79.92%   79.91%   -0.02%     
==========================================
  Files          38       38              
  Lines        3861     3873      +12     
==========================================
+ Hits         3086     3095       +9     
- Misses        669      671       +2     
- Partials      106      107       +1     
Impacted Files Coverage Δ
tracing.go 89.07% <100.00%> (+0.28%) ⬆️

... and 1 file with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@tonyo tonyo requested a review from cleptric March 29, 2023 16:21
@tonyo tonyo merged commit ee30222 into master Apr 4, 2023
@tonyo tonyo deleted the tonyo/span-tags-context-data-concurr branch April 4, 2023 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants