Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package io.opentelemetry.contrib.sampler.consistent56;

import static io.opentelemetry.contrib.sampler.consistent56.ConsistentSamplingUtil.calculateSamplingProbability;
import static io.opentelemetry.contrib.sampler.consistent56.ConsistentSamplingUtil.calculateThreshold;
import static io.opentelemetry.contrib.sampler.consistent56.ConsistentSamplingUtil.checkThreshold;
import static io.opentelemetry.contrib.sampler.consistent56.ConsistentSamplingUtil.getInvalidThreshold;
import static io.opentelemetry.contrib.sampler.consistent56.ConsistentSamplingUtil.getMaxThreshold;
Expand All @@ -22,9 +23,20 @@ public class ConsistentFixedThresholdSampler extends ConsistentSampler {
private final String description;

protected ConsistentFixedThresholdSampler(long threshold) {
this.threshold = getThreshold(threshold);
this.description = getThresholdDescription(threshold);
}

protected ConsistentFixedThresholdSampler(double samplingProbability) {
this(calculateThreshold(samplingProbability));
}

private static long getThreshold(long threshold) {
checkThreshold(threshold);
this.threshold = threshold;
return threshold;
}

private static String getThresholdDescription(long threshold) {
String thresholdString;
if (threshold == getMaxThreshold()) {
thresholdString = "max";
Expand All @@ -35,12 +47,11 @@ protected ConsistentFixedThresholdSampler(long threshold) {
.toString();
}

this.description =
"ConsistentFixedThresholdSampler{threshold="
+ thresholdString
+ ", sampling probability="
+ calculateSamplingProbability(threshold)
+ "}";
return "ConsistentFixedThresholdSampler{threshold="
+ thresholdString
+ ", sampling probability="
+ calculateSamplingProbability(threshold)
+ "}";
}

@Override
Expand Down
Loading