Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,8 @@ public boolean shouldDropSpan(
@Nullable
private Pair<String, String> convertToPair(String s) {
if (s != null && s.contains(COLON)) {
String[] parts = s.split(COLON);
if (parts.length == 2) {
return Pair.of(parts[0], parts[1]);
}
int colonIndex = s.indexOf(COLON);
return Pair.of(s.substring(0, colonIndex), s.substring(colonIndex + 1));
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,20 +153,49 @@ public void testDropSpanWithMultipleCriterion() {
"tenantIdTagKey",
"tenant-key",
"spanDropCriterion",
List.of("foo:bar,k1:v1", "k2:v2"))));
List.of("foo:bar,k1:v1", "k2:v2", "http.url:https://foo.bar"))));

JaegerSpanPreProcessor jaegerSpanPreProcessor =
new JaegerSpanPreProcessor(ConfigFactory.parseMap(configs));
Process process = Process.newBuilder().setServiceName("testService").build();
Span span =
Span.newBuilder()
.setProcess(process)
.addTags(KeyValue.newBuilder().setKey("tenant-key").setVStr(tenantId).build())
.addTags(KeyValue.newBuilder().setKey("foo").setVStr("bar").build())
.addTags(KeyValue.newBuilder().setKey("k2").setVStr("v2").build())
.build();
PreProcessedSpan preProcessedSpan = jaegerSpanPreProcessor.preProcessSpan(span);
Assertions.assertNull(preProcessedSpan);
{
Span span =
Span.newBuilder()
.setProcess(process)
.addTags(KeyValue.newBuilder().setKey("tenant-key").setVStr(tenantId).build())
.addTags(KeyValue.newBuilder().setKey("foo").setVStr("bar").build())
.addTags(KeyValue.newBuilder().setKey("k2").setVStr("v2").build())
.build();
PreProcessedSpan preProcessedSpan = jaegerSpanPreProcessor.preProcessSpan(span);
// Span dropped due to matching condition: k2:v2
Assertions.assertNull(preProcessedSpan);
}

{
Span span =
Span.newBuilder()
.setProcess(process)
.addTags(KeyValue.newBuilder().setKey("tenant-key").setVStr(tenantId).build())
.addTags(KeyValue.newBuilder().setKey("foo").setVStr("bar").build())
.addTags(KeyValue.newBuilder().setKey("http.url").setVStr("https://foo.bar").build())
.build();
PreProcessedSpan preProcessedSpan = jaegerSpanPreProcessor.preProcessSpan(span);
// Span dropped due to matching condition: http.url:https://foo.bar
Assertions.assertNull(preProcessedSpan);
}

{
Span span =
Span.newBuilder()
.setProcess(process)
.addTags(KeyValue.newBuilder().setKey("tenant-key").setVStr(tenantId).build())
.addTags(KeyValue.newBuilder().setKey("foo").setVStr("bar").build())
.addTags(KeyValue.newBuilder().setKey("http.url").setVStr("https://valid").build())
.build();
PreProcessedSpan preProcessedSpan = jaegerSpanPreProcessor.preProcessSpan(span);
// Span not dropped since there is no matching condition
Assertions.assertNotNull(preProcessedSpan);
}
}

@Test
Expand Down