Skip to content

Commit 65ad8e7

Browse files
committed
Remove getDescription
1 parent a6b79e4 commit 65ad8e7

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ final class ComposableRuleBasedSampler implements ComposableSampler {
2525
if (this.rules.length > 0) {
2626
for (SamplingRule rule : this.rules) {
2727
description.append('(');
28-
description.append(rule.predicate().getDescription());
28+
description.append(rule.predicate().toString());
2929
description.append(':');
3030
description.append(rule.sampler().getDescription());
3131
description.append(')');

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@
1111
import io.opentelemetry.sdk.trace.data.LinkData;
1212
import java.util.List;
1313

14-
/** A predicate for a composable sampler, indicating whether a set of sampling arguments matches. */
14+
/**
15+
* A predicate for a composable sampler, indicating whether a set of sampling arguments matches.
16+
*
17+
* <p>While this can be implemented with lambda expressions, it is recommended to implement {@link
18+
* Object#toString()} as well with an explanation of the predicate for rendering in {@link
19+
* io.opentelemetry.sdk.trace.samplers.Sampler#getDescription()}.
20+
*/
21+
@FunctionalInterface
1522
public interface SamplingPredicate {
1623
/** Returns whether this {@link SamplingPredicate} matches the given sampling arguments. */
1724
boolean matches(
@@ -21,10 +28,4 @@ boolean matches(
2128
SpanKind spanKind,
2229
Attributes attributes,
2330
List<LinkData> parentLinks);
24-
25-
/**
26-
* Returns a description of the {@link SamplingPredicate}. This may be displayed on debug pages or
27-
* in the logs.
28-
*/
29-
String getDescription();
3031
}

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,9 @@ public boolean matches(
4949
return "/health".equals(attributes.get(key));
5050
}
5151

52-
@Override
53-
public String getDescription() {
54-
return description;
55-
}
56-
5752
@Override
5853
public String toString() {
59-
return getDescription();
54+
return description;
6055
}
6156
}
6257

@@ -75,7 +70,7 @@ public boolean matches(
7570
}
7671

7772
@Override
78-
public String getDescription() {
73+
public String toString() {
7974
return "isRoot";
8075
}
8176
}

0 commit comments

Comments
 (0)