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

Trace sampling #753

Merged
merged 21 commits into from
Jan 22, 2021
Merged

Trace sampling #753

merged 21 commits into from
Jan 22, 2021

Conversation

Tyrrrz
Copy link
Contributor

@Tyrrrz Tyrrrz commented Jan 19, 2021

Related: #663

@Tyrrrz Tyrrrz added Feature New feature or request Sentry labels Jan 19, 2021
src/Sentry/SentryClient.cs Outdated Show resolved Hide resolved
src/Sentry/SentryClient.cs Outdated Show resolved Hide resolved
@Tyrrrz Tyrrrz marked this pull request as ready for review January 21, 2021 18:56
src/Sentry/Internal/ThreadSafeRandom.cs Outdated Show resolved Hide resolved
Comment on lines +135 to +137
// Custom sampler may not exist or may return null, in which case we fallback
// to the static sample rate.
_options.TracesSampler?.Invoke(samplingContext)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is different from Java. I decided to allow the dynamic sampler to return null to fallback to the configured sample rate. I think it would be very useful, in case when you only want special sampling rules for a subset of transactions and default rules for everything else.

Copy link
Member

Choose a reason for hiding this comment

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

It makes sense to me and I don't have a problem with that.
Maybe @marandaneto has opinions though.

Please make a note on the spec then that this is an alternative approach.

Copy link
Contributor

Choose a reason for hiding this comment

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

that sounds a good use case, lets talk about this today in the meeting

Copy link
Contributor

Choose a reason for hiding this comment

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

we'll make this on Java too

/// </summary>
string? Description { get; set; }
// 'new' because it adds a setter.
new string? Description { get; set; }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

new is yikes

Copy link
Member

Choose a reason for hiding this comment

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

yeah, if the reference held is of a base type this new won't show up. And the wrong getter will run. But hey, not the worst thing we got going on to add this API right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The getter will run correctly (since both interfaces still map to the same member on the class). However, if you implement explicitly then yeah you can end up with two different properties:

ISpanContext.Description {get;set;}
ISpan.Description {get;set;}

@@ -33,17 +33,17 @@ public class Span : ISpan, IJsonSerializable
/// <inheritdoc />
public DateTimeOffset? EndTimestamp { get; private set; }

/// <inheritdoc />
/// <inheritdoc cref="ISpan.Operation" />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Side-effect of having new

/// <summary>
/// Span metadata used for sampling.
/// </summary>
public class SpanContext : ISpanContext
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I still don't know why we need SpanContext here though. Both guidelines and Java has it, but it's not used in sampling.

@Tyrrrz
Copy link
Contributor Author

Tyrrrz commented Jan 21, 2021

@bruno-garcia are you happy with the API? I've commented on some places of interest.
If it's all good, I'll move on to tests.

Copy link
Member

@bruno-garcia bruno-garcia left a comment

Choose a reason for hiding this comment

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

why did the submodule change?

src/Sentry/Internal/ThreadSafeRandom.cs Outdated Show resolved Hide resolved
src/Sentry/Internal/ThreadSafeRandom.cs Outdated Show resolved Hide resolved
Comment on lines +135 to +137
// Custom sampler may not exist or may return null, in which case we fallback
// to the static sample rate.
_options.TracesSampler?.Invoke(samplingContext)
Copy link
Member

Choose a reason for hiding this comment

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

It makes sense to me and I don't have a problem with that.
Maybe @marandaneto has opinions though.

Please make a note on the spec then that this is an alternative approach.

/// </summary>
string? Description { get; set; }
// 'new' because it adds a setter.
new string? Description { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

yeah, if the reference held is of a base type this new won't show up. And the wrong getter will run. But hey, not the worst thing we got going on to add this API right?

@Tyrrrz
Copy link
Contributor Author

Tyrrrz commented Jan 21, 2021

why did the submodule change?

not sure, i just merged origin

@Tyrrrz
Copy link
Contributor Author

Tyrrrz commented Jan 21, 2021

@bruno-garcia why is codecov not showing up? :(

@Tyrrrz Tyrrrz enabled auto-merge (squash) January 21, 2021 21:49
@Tyrrrz
Copy link
Contributor Author

Tyrrrz commented Jan 21, 2021

@bruno-garcia can you retry appveyor build? Don't know why it broke but I can't merge it because all checks need to pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants