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(dynamic-sampling): Do not crash in Span.Finish() when Client is empty #520

Merged
merged 4 commits into from Jan 11, 2023

Conversation

tonyo
Copy link
Member

@tonyo tonyo commented Dec 20, 2022

Making a draft since I'm not entirely sure if there are any other places right now where we might have this issue, and also because I'll have to confirm what DynamicSamplingContext to return when Client or Scope are empty.

Should be ready for review now.

Fixes #518.

@tonyo tonyo self-assigned this Dec 20, 2022
@tonyo tonyo requested a review from cleptric December 20, 2022 16:46
Copy link
Member

@cleptric cleptric left a comment

Choose a reason for hiding this comment

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

This will attach the DSC to the event here

if !s.dynamicSamplingContext.IsFrozen() {

In the transport, we'll skip attaching the DSC as it's empty
https://github.com/getsentry/sentry-go/blob/master/transport.go#L103

I think this is a feasible solution.

@tonyo tonyo changed the title fix(dynamic-sampling): Do not crash when Client is empty fix(dynamic-sampling): Do not crash in Transaction.Finish() when Client is empty Jan 9, 2023
@tonyo tonyo changed the title fix(dynamic-sampling): Do not crash in Transaction.Finish() when Client is empty fix(dynamic-sampling): Do not crash in Span.Finish() when Client is empty Jan 9, 2023
@tonyo tonyo marked this pull request as ready for review January 9, 2023 16:39
@tonyo tonyo requested a review from cleptric January 9, 2023 16:39
if client == nil || scope == nil {
return DynamicSamplingContext{
Entries: map[string]string{},
Frozen: false,
Copy link
Member Author

Choose a reason for hiding this comment

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

Made it more explicit to make sure there are no default-value surprises.

@tonyo tonyo merged commit 3c8662b into master Jan 11, 2023
@tonyo tonyo deleted the fix/crash-dynamic-sampl-client branch January 11, 2023 09:32
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.

panic because nil client in DynamicSamplingContextFromTransaction
2 participants