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 a provider for consistent parent based probability sampler #1005

Merged
merged 3 commits into from
Aug 18, 2023

Conversation

kes2464
Copy link
Contributor

@kes2464 kes2464 commented Aug 17, 2023

Description:

Adding a ConfigurableSamplerProvider for parent based probability sampler to autoconfigure to use in auto instrumentation.

Existing Issue(s):

Discussed in here
#999

Testing:

Tested it by using it in a java application with auto instrumentation on.

Documentation:

Outstanding items:

It's only adding a provider for one sampler that I need, but I am happy to discuss if we should add them all.

@kes2464 kes2464 requested a review from a team August 17, 2023 04:16
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Aug 17, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@kes2464
Copy link
Contributor Author

kes2464 commented Aug 17, 2023

@trask

Copy link
Member

@mateuszrzeszutek mateuszrzeszutek left a comment

Choose a reason for hiding this comment

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

👍

@kes2464
Copy link
Contributor Author

kes2464 commented Aug 17, 2023

👍

Not sure why, but I am seeing this, am I pointing to a wrong branch?

Merging is blocked. The base branch restricts merging to authorized users.


@Override
public String getName() {
return "consistent_parent_based_probability";
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would consistent_parentbased_probability work?

Copy link
Member

Choose a reason for hiding this comment

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

how about

  • consistent_always_on
  • consistent_always_off
  • consistent_probability
  • consistent_rate_limit
  • parentbased_consistent_always_on
  • parentbased_consistent_always_off
  • parentbased_consistent_probability
  • parentbased_consistent_rate_limit

(don't need to add them all in this PR, but trying to understand the naming pattern)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, updated to parentbased_consistent_probability

Copy link
Contributor

@laurit laurit Aug 18, 2023

Choose a reason for hiding this comment

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

could you also rename the sampler provider class to match the name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@laurit
Copy link
Contributor

laurit commented Aug 17, 2023

Not sure why, but I am seeing this, am I pointing to a wrong branch?

Merging is blocked. The base branch restricts merging to authorized users.

That is fine, only code owners can merge.


@Override
public Sampler createSampler(ConfigProperties config) {
double samplingProbability = config.getDouble("otel.traces.sampler.arg", 1.0d);
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you want to force the samplingProbability into the interval [0.0, 1.0]? If out of the range, an exception will be thrown by the statement below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ConsistentProbabilityBasedSampler is already throwing an IllegalArgumentException if it's not within the range.

https://github.com/open-telemetry/opentelemetry-java-contrib/blob/main/consistent-sampling/src/main/java/io/opentelemetry/contrib/sampler/consistent/ConsistentProbabilityBasedSampler.java#L31-L33

if (samplingProbability < 0.0 || samplingProbability > 1.0) {
  throw new IllegalArgumentException("Sampling probability must be in range [0.0, 1.0]!");
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Exactly my point. I just wondered if this is the behavior you want.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I misread your comment.

Yes and I believe that was @oertl's intention as well.
TraceIdRatioBasedSampler in java sdk also has the same behaviour.
We could default to 1.0, but I think failing here would probably be more explicit.

Copy link
Contributor

@PeterF778 PeterF778 left a comment

Choose a reason for hiding this comment

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

Looks good.

@trask trask merged commit 3af6cf3 into open-telemetry:main Aug 18, 2023
zeitlinger pushed a commit to zeitlinger/opentelemetry-java-contrib that referenced this pull request Aug 25, 2023
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.

6 participants