Skip to content

Commit 3d60ed1

Browse files
committed
Adding a built-in predicate hasLocalParent.
1 parent da0ee57 commit 3d60ed1

File tree

1 file changed

+11
-0
lines changed
  • consistent-sampling/src/main/java/io/opentelemetry/contrib/sampler/consistent56

1 file changed

+11
-0
lines changed

consistent-sampling/src/main/java/io/opentelemetry/contrib/sampler/consistent56/Predicate.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ static Predicate isRootSpan() {
3838
};
3939
}
4040

41+
/*
42+
* Return a Predicate that will only match Spans with local parent
43+
*/
44+
static Predicate hasLocalParent() {
45+
return (parentContext, name, spanKind, attributes, parentLinks) -> {
46+
Span parentSpan = Span.fromContext(parentContext);
47+
SpanContext parentSpanContext = parentSpan.getSpanContext();
48+
return !parentSpanContext.isValid() || !parentSpanContext.isRemote();
49+
};
50+
}
51+
4152
/*
4253
* Return a Predicate that matches all Spans
4354
*/

0 commit comments

Comments
 (0)