use of com.twitter.zipkin.thriftjava.BinaryAnnotation in project jaeger-client-java by jaegertracing.
the class ThriftSpanConverterTest method testTracerTags.
@Test
@UseDataProvider("dataProviderTracerTags")
public void testTracerTags(SpanType spanType, Map<String, String> expectedTags) throws Exception {
InMemoryReporter spanReporter = new InMemoryReporter();
Tracer tracer = new Tracer.Builder("x", spanReporter, new ConstSampler(true)).withZipkinSharedRpcSpan().withTag("tag.str", "y").withTag("tag.bool", true).withTag("tag.num", 1).build();
Span span = (Span) tracer.buildSpan("root").startManual();
if (spanType == SpanType.CHILD) {
span = (Span) tracer.buildSpan("child").asChildOf(span).startManual();
} else if (spanType == SpanType.RPC_SERVER) {
span = (Span) tracer.buildSpan("rpc-server").asChildOf(span).withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER).startManual();
}
com.twitter.zipkin.thriftjava.Span zipkinSpan = ThriftSpanConverter.convertSpan(span);
List<BinaryAnnotation> annotations = zipkinSpan.getBinary_annotations();
for (Map.Entry<String, String> entry : expectedTags.entrySet()) {
String key = entry.getKey();
Object expectedValue = entry.getValue();
BinaryAnnotation anno = findBinaryAnnotation(annotations, key);
if (expectedValue.equals(UNDEF)) {
assertNull("Not expecting " + key + " for " + spanType, anno);
} else if (expectedValue.equals(ANY)) {
assertEquals(key, anno.getKey());
} else {
String actualValue = new String(anno.getValue(), StandardCharsets.UTF_8);
assertEquals("Expecting " + key + " for " + spanType, expectedValue, actualValue);
}
}
}
Aggregations