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

Add ProbabilitySampler in SDK. #337

Merged
merged 3 commits into from
May 31, 2019

Conversation

songy23
Copy link
Member

@songy23 songy23 commented May 22, 2019

OpenCensus used to use probability sampler of 1/10000 as default in trace configs. Not sure if we want to keep it that way in the new project.

@codecov-io
Copy link

codecov-io commented May 22, 2019

Codecov Report

Merging #337 into master will decrease coverage by 0.05%.
The diff coverage is 58.82%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #337      +/-   ##
============================================
- Coverage     62.54%   62.48%   -0.06%     
- Complexity      306      316      +10     
============================================
  Files            52       53       +1     
  Lines          1196     1213      +17     
  Branches        104      110       +6     
============================================
+ Hits            748      758      +10     
- Misses          411      414       +3     
- Partials         37       41       +4
Impacted Files Coverage Δ Complexity Δ
...lemetry/sdk/trace/samplers/ProbabilitySampler.java 58.82% <58.82%> (ø) 10 <10> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fb3af1a...d3d027e. Read the comment docs.

Copy link
Member

@tylerbenson tylerbenson left a comment

Choose a reason for hiding this comment

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

Looks pretty good. I think the testing could be a bit more thorough.

* range. We convert an incoming probability into an upper bound on that value, such that we can
* just compare the absolute value of the id and the bound to see if we are within the desired
* probability range. Using the low bits of the traceId also ensures that systems that only use 64
* bit ID's will also work with this sampler.
Copy link
Member

Choose a reason for hiding this comment

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

Nice comment. Is there any chance the assumption about the random distribution might fail?

Copy link
Member Author

Choose a reason for hiding this comment

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

I cannot think of any - @bogdandrutu may have a better example here.

Copy link
Member

Choose a reason for hiding this comment

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

This should be also documented into the specification + @c24t, because we need all the implementations to be consistent.

Copy link
Member Author

Choose a reason for hiding this comment

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

@songy23
Copy link
Member Author

songy23 commented May 23, 2019

Apologies I forgot to mention these two files are a copy-and-paste from https://github.com/census-instrumentation/opencensus-java/blob/master/api/src/main/java/io/opencensus/trace/samplers/ProbabilitySampler.java and https://github.com/census-instrumentation/opencensus-java/blob/master/api/src/test/java/io/opencensus/trace/samplers/SamplersTest.java. Previously we removed ProbabilitySampler from API but I wonder if it makes sense to have it in the SDK.

@yurishkuro
Copy link
Member

OpenCensus used to use probability sampler of 1/10000 as default in trace configs. Not sure if we want to keep it that way in the new project.

We had similar discussions about Jaeger defaults, and the feeling was that 100% would be a better default as new users often get confused why they are not getting traces out.

@yurishkuro
Copy link
Member

To be precise, in Jaeger the default is "remotely controlled sampler" where the sampling strategy is loaded from Jaeger backend, but if the backend is not available then the default probability is still very low.

import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

/**
Copy link
Member

Choose a reason for hiding this comment

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

@since 0.1.0 is missing here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Seems none of the SDK classes have the @since tag. I'll wait to see our decision on #344.

@pavolloffay
Copy link
Member

pavolloffay commented May 23, 2019

We had similar discussions about Jaeger defaults, and the feeling was that 100% would be a better default as new users often get confused why they are not getting traces out.

Maybe the SDK could have modes, production and test.

@carlosalberto
Copy link
Contributor

the feeling was that 100% would be a better default as new users often get confused why they are not getting traces out.

Agreed.

Maybe the SDK could have modes, production and test.

If we were to do this, we should also make sure test is the default mode ;)

@songy23
Copy link
Member Author

songy23 commented May 23, 2019

We can discuss on which sampler to use as the default, but IMO we need to provide the probability sampler option even if it's not made default. WDYT?

@songy23 songy23 force-pushed the probability-sampler branch from 2e3eba2 to d3d027e Compare May 23, 2019 18:40
@songy23
Copy link
Member Author

songy23 commented May 24, 2019

I'm not authorized to merge this pull request - please help me merge it if it looks good :)

@bogdandrutu
Copy link
Member

@songy23 did you follow up with an issue on the specification about the probability algorithm to make sure we have this consistent?

@songy23 songy23 force-pushed the probability-sampler branch from 4691abb to 61e59d7 Compare May 29, 2019 18:29
@bogdandrutu bogdandrutu merged commit 9691526 into open-telemetry:master May 31, 2019
@songy23 songy23 deleted the probability-sampler branch June 4, 2019 16: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.

8 participants