Skip to content

Commit 34c9d5f

Browse files
committed
Test auto spotless workflow
1 parent 11c3dda commit 34c9d5f

File tree

1 file changed

+37
-35
lines changed

1 file changed

+37
-35
lines changed

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

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
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+
1415
import java.util.List;
1516

1617
/**
@@ -19,43 +20,44 @@
1920
* links, this Sampler will use the "root" sampler that it is built with.
2021
*/
2122
public final class LinksBasedSampler implements Sampler {
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();
44-
}
45-
}
46-
return SamplingResult.drop();
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);
4732
}
4833

49-
return this.root.shouldSample(parentContext, traceId, name, spanKind, attributes, parentLinks);
50-
}
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();
49+
}
5150

52-
@Override
53-
public String getDescription() {
54-
return String.format("LinksBased{root:%s}", this.root.getDescription());
55-
}
51+
return this.root.shouldSample(parentContext, traceId, name, spanKind, attributes, parentLinks);
52+
}
5653

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

0 commit comments

Comments
 (0)