-
Notifications
You must be signed in to change notification settings - Fork 130
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.contrib.sampler.consistent; | ||
|
||
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; | ||
import io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSamplerProvider; | ||
import io.opentelemetry.sdk.trace.samplers.Sampler; | ||
|
||
public final class ConsistentParentBasedProbabilitySamplerProvider | ||
implements ConfigurableSamplerProvider { | ||
|
||
@Override | ||
public Sampler createSampler(ConfigProperties config) { | ||
double samplingProbability = config.getDouble("otel.traces.sampler.arg", 1.0d); | ||
return ConsistentSampler.parentBased(ConsistentSampler.probabilityBased(samplingProbability)); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "consistent_parent_based_probability"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. samplers in java sdk use a different naming scheme https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk-extensions/autoconfigure/README.md#sampler There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how about
(don't need to add them all in this PR, but trying to understand the naming pattern) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good, updated to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you also rename the sampler provider class to match the name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
io.opentelemetry.contrib.sampler.consistent.ConsistentParentBasedProbabilitySamplerProvider |
There was a problem hiding this comment.
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.There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.