Skip to content

Commit e108751

Browse files
committed
./gradlew spotlessApply
1 parent 34c9d5f commit e108751

File tree

1 file changed

+35
-37
lines changed

1 file changed

+35
-37
lines changed

samplers/src/main/java/io/opentelemetry/contrib/sampler/LinksBasedSampler.java

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import io.opentelemetry.sdk.trace.data.LinkData;
1212
import io.opentelemetry.sdk.trace.samplers.Sampler;
1313
import io.opentelemetry.sdk.trace.samplers.SamplingResult;
14-
1514
import java.util.List;
1615

1716
/**
@@ -20,44 +19,43 @@
2019
* links, this Sampler will use the "root" sampler that it is built with.
2120
*/
2221
public final class LinksBasedSampler implements Sampler {
23-
private final Sampler root;
24-
25-
private LinksBasedSampler(Sampler root) {
26-
this.root = root;
27-
}
28-
29-
public static LinksBasedSampler create(
30-
Sampler root) {
31-
return new LinksBasedSampler(root);
32-
}
33-
34-
@Override
35-
public SamplingResult shouldSample(
36-
Context parentContext,
37-
String traceId,
38-
String name,
39-
SpanKind spanKind,
40-
Attributes attributes,
41-
List<LinkData> parentLinks) {
42-
if (parentLinks.size() > 0) {
43-
for (LinkData linkData : parentLinks) {
44-
if (linkData.getSpanContext().isSampled()) {
45-
return SamplingResult.recordAndSample();
46-
}
47-
}
48-
return SamplingResult.drop();
22+
private final Sampler root;
23+
24+
private LinksBasedSampler(Sampler root) {
25+
this.root = root;
26+
}
27+
28+
public static LinksBasedSampler create(Sampler root) {
29+
return new LinksBasedSampler(root);
30+
}
31+
32+
@Override
33+
public SamplingResult shouldSample(
34+
Context parentContext,
35+
String traceId,
36+
String name,
37+
SpanKind spanKind,
38+
Attributes attributes,
39+
List<LinkData> parentLinks) {
40+
if (parentLinks.size() > 0) {
41+
for (LinkData linkData : parentLinks) {
42+
if (linkData.getSpanContext().isSampled()) {
43+
return SamplingResult.recordAndSample();
4944
}
50-
51-
return this.root.shouldSample(parentContext, traceId, name, spanKind, attributes, parentLinks);
45+
}
46+
return SamplingResult.drop();
5247
}
5348

54-
@Override
55-
public String getDescription() {
56-
return String.format("LinksBased{root:%s}", this.root.getDescription());
57-
}
49+
return this.root.shouldSample(parentContext, traceId, name, spanKind, attributes, parentLinks);
50+
}
5851

59-
@Override
60-
public String toString() {
61-
return getDescription();
62-
}
52+
@Override
53+
public String getDescription() {
54+
return String.format("LinksBased{root:%s}", this.root.getDescription());
55+
}
56+
57+
@Override
58+
public String toString() {
59+
return getDescription();
60+
}
6361
}

0 commit comments

Comments
 (0)