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

Allow non-integral X-Ray sampling rates #803

Merged
merged 1 commit into from
Sep 17, 2020
Merged

Conversation

ChimeraCoder
Copy link
Contributor

@ChimeraCoder ChimeraCoder commented Sep 16, 2020

Summary

Allow non-integer values to be set for X-Ray sampling rates. Notably, this allows users to set rates below 1% (without disabling X-Ray entirely).

Motivation

Test plan

Rollout/monitoring/revert plan

r? @stripe/observability

@stripe-ci
Copy link

👀 Heads Up

@aditya-stripe
Copy link
Contributor

aditya-stripe commented Sep 16, 2020

re-r? @stripe/observability

@@ -80,7 +80,7 @@ type XRaySpanSink struct {
var _ sinks.SpanSink = &XRaySpanSink{}

// NewXRaySpanSink creates a new instance of a XRaySpanSink.
func NewXRaySpanSink(daemonAddr string, sampleRatePercentage int, commonTags map[string]string, annotationTags []string, log *logrus.Logger) (*XRaySpanSink, error) {
func NewXRaySpanSink(daemonAddr string, sampleRatePercentage float64, commonTags map[string]string, annotationTags []string, log *logrus.Logger) (*XRaySpanSink, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this irritate the math.MaxUint32 below? (otherwise, it looks pretty simple)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It actually doesn't! (it compiles, and I even test-logged the sample value).

If you're curious why it works: despite the semantic significance, math.MaxUint32 is actually defined as an untyped constant (MaxUint8 = 1<<8 - 1), so to the compiler, it's the same as multiplying a float64 by a hard-coded, untyped numeric literal.

Copy link
Contributor

Choose a reason for hiding this comment

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

That was my suspicion, excellent!

@ChimeraCoder ChimeraCoder merged commit f0abcf0 into master Sep 17, 2020
@ChimeraCoder ChimeraCoder deleted the aditya-xray-float branch September 17, 2020 15:18
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.

5 participants