Skip to content

Commit 101dd16

Browse files
authored
Rename ComposableTraceIdRatioBased to ComposableProbability (#7786)
1 parent c577156 commit 101dd16

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import java.util.List;
1313
import java.util.function.Function;
1414

15-
final class ComposableTraceIdRatioBasedSampler implements ComposableSampler {
15+
final class ComposableProbabilitySampler implements ComposableSampler {
1616
private static long calculateThreshold(double ratio) {
1717
return ImmutableSamplingIntent.MAX_THRESHOLD
1818
- Math.round(ratio * (double) ImmutableSamplingIntent.MAX_THRESHOLD);
@@ -21,7 +21,7 @@ private static long calculateThreshold(double ratio) {
2121
private final SamplingIntent intent;
2222
private final String description;
2323

24-
ComposableTraceIdRatioBasedSampler(double ratio) {
24+
ComposableProbabilitySampler(double ratio) {
2525
long threshold = calculateThreshold(ratio);
2626
String thresholdStr;
2727
if (threshold == ImmutableSamplingIntent.MAX_THRESHOLD) {

sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/trace/samplers/ComposableSampler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ static ComposableSampler alwaysOn() {
2424
}
2525

2626
/** Returns a {@link ComposableSampler} that samples each span with a fixed ratio. */
27-
static ComposableSampler traceIdRatioBased(double ratio) {
28-
return new ComposableTraceIdRatioBasedSampler(ratio);
27+
static ComposableSampler probability(double ratio) {
28+
return new ComposableProbabilitySampler(ratio);
2929
}
3030

3131
/**
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,21 @@
2121
import org.junit.jupiter.params.ParameterizedTest;
2222
import org.junit.jupiter.params.provider.CsvSource;
2323

24-
class ComposableTraceIdRatioBasedSamplerTest {
24+
class ComposableProbabilitySamplerTest {
2525
@Test
2626
void testDescription() {
27-
assertThat(ComposableSampler.traceIdRatioBased(1.0).getDescription())
27+
assertThat(ComposableSampler.probability(1.0).getDescription())
2828
.isEqualTo("ComposableTraceIdRatioBasedSampler{threshold=0, ratio=1.0}");
29-
assertThat(ComposableSampler.traceIdRatioBased(1.0))
29+
assertThat(ComposableSampler.probability(1.0))
3030
.hasToString("ComposableTraceIdRatioBasedSampler{threshold=0, ratio=1.0}");
3131

32-
assertThat(ComposableSampler.traceIdRatioBased(0.5).getDescription())
32+
assertThat(ComposableSampler.probability(0.5).getDescription())
3333
.isEqualTo("ComposableTraceIdRatioBasedSampler{threshold=8, ratio=0.5}");
34-
assertThat(ComposableSampler.traceIdRatioBased(0.25).getDescription())
34+
assertThat(ComposableSampler.probability(0.25).getDescription())
3535
.isEqualTo("ComposableTraceIdRatioBasedSampler{threshold=c, ratio=0.25}");
36-
assertThat(ComposableSampler.traceIdRatioBased(1e-300).getDescription())
36+
assertThat(ComposableSampler.probability(1e-300).getDescription())
3737
.isEqualTo("ComposableTraceIdRatioBasedSampler{threshold=max, ratio=1.0E-300}");
38-
assertThat(ComposableSampler.traceIdRatioBased(0).getDescription())
38+
assertThat(ComposableSampler.probability(0).getDescription())
3939
.isEqualTo("ComposableTraceIdRatioBasedSampler{threshold=max, ratio=0.0}");
4040
}
4141

@@ -53,7 +53,7 @@ void testDescription() {
5353
})
5454
void sampling(double ratio, long threshold) {
5555
Supplier<String> generator = traceIdGenerator();
56-
Sampler sampler = CompositeSampler.wrap(ComposableSampler.traceIdRatioBased(ratio));
56+
Sampler sampler = CompositeSampler.wrap(ComposableSampler.probability(ratio));
5757
int numSampled = 0;
5858
for (int i = 0; i < 10000; i++) {
5959
SamplingResult result =

sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/trace/samplers/CompositeSamplerTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ void testMinThresholdWithParentRandomValue() {
189189
void testMaxThreshold() {
190190
Input input = new Input();
191191

192-
Sampler sampler = CompositeSampler.wrap(ComposableSampler.traceIdRatioBased(0.0));
192+
Sampler sampler = CompositeSampler.wrap(ComposableSampler.probability(0.0));
193193

194194
Output output = sample(input, sampler);
195195

@@ -237,7 +237,7 @@ void testHalfThresholdNotSampled() {
237237
Input input = new Input();
238238
input.setParentRandomValue(0x7FFFFFFFFFFFFFL);
239239

240-
Sampler sampler = CompositeSampler.wrap(ComposableSampler.traceIdRatioBased(0.5));
240+
Sampler sampler = CompositeSampler.wrap(ComposableSampler.probability(0.5));
241241

242242
Output output = sample(input, sampler);
243243

@@ -251,7 +251,7 @@ void testHalfThresholdSampled() {
251251
Input input = new Input();
252252
input.setParentRandomValue(0x80000000000000L);
253253

254-
Sampler sampler = CompositeSampler.wrap(ComposableSampler.traceIdRatioBased(0.5));
254+
Sampler sampler = CompositeSampler.wrap(ComposableSampler.probability(0.5));
255255

256256
Output output = sample(input, sampler);
257257

@@ -268,7 +268,7 @@ void testParentViolatingInvariant() {
268268
input.setParentRandomValue(0x80000000000000L);
269269
input.setParentSampled(false);
270270

271-
Sampler sampler = CompositeSampler.wrap(ComposableSampler.traceIdRatioBased(1.0));
271+
Sampler sampler = CompositeSampler.wrap(ComposableSampler.probability(1.0));
272272
Output output = sample(input, sampler);
273273

274274
assertThat(output.samplingResult.getDecision()).isEqualTo(SamplingDecision.RECORD_AND_SAMPLE);

0 commit comments

Comments
 (0)