use of io.jaegertracing.internal.JaegerSpan in project jaeger-client-java by jaegertracing.
the class ZipkinSenderTest method testAppend128BitTraceId.
@Test
public void testAppend128BitTraceId() throws Exception {
JaegerSpan expectedSpan = tracer128.buildSpan("raza").start();
sender.append(expectedSpan);
sender.flush();
List<List<zipkin2.Span>> traces = zipkinRule.getTraces();
assertEquals(traces.size(), 1);
assertEquals(traces.get(0).size(), 1);
zipkin2.Span actualSpan = traces.get(0).get(0);
JaegerSpanContext context = expectedSpan.context();
assertNotEquals(context.getTraceIdHigh(), 0L);
assertTrue(actualSpan.traceId().length() > 16);
assertEquals(context.getTraceIdLow(), HexCodec.lowerHexToUnsignedLong(actualSpan.traceId()));
assertEquals(context.getTraceIdHigh(), HexCodec.lowerHexToUnsignedLong(actualSpan.traceId().substring(0, 16)));
}
use of io.jaegertracing.internal.JaegerSpan in project jaeger-client-java by jaegertracing.
the class ThriftSpanConverterTest method testSpanDetectsIsServer.
@Test
public void testSpanDetectsIsServer() {
JaegerSpan span = tracer.buildSpan("test-service-operation").start();
Tags.SPAN_KIND.set(span, Tags.SPAN_KIND_SERVER);
assertTrue(ConverterUtil.isRpc(span));
assertFalse(ConverterUtil.isRpcClient(span));
}
use of io.jaegertracing.internal.JaegerSpan in project jaeger-client-java by jaegertracing.
the class ThriftSpanConverterTest method testTracerTags.
@Test
@UseDataProvider("dataProviderTracerTags")
public void testTracerTags(SpanType spanType, Map<String, String> expectedTags) {
InMemoryReporter spanReporter = new InMemoryReporter();
JaegerTracer tracer = new JaegerTracer.Builder("x").withReporter(spanReporter).withSampler(new ConstSampler(true)).withZipkinSharedRpcSpan().withTag("tag.str", "y").withTag("tag.bool", true).withTag("tag.num", 1).build();
JaegerSpan span = tracer.buildSpan("root").start();
if (spanType == SpanType.CHILD) {
span = tracer.buildSpan("child").asChildOf(span).start();
} else if (spanType == SpanType.RPC_SERVER) {
span = tracer.buildSpan("rpc-server").asChildOf(span).withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER).start();
}
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);
}
}
}
use of io.jaegertracing.internal.JaegerSpan in project jaeger-client-java by jaegertracing.
the class ThriftSpanConverterTest method testExpectedLocalComponentNameUsed.
@Test
public void testExpectedLocalComponentNameUsed() {
String expectedComponentName = "local-name";
JaegerSpan span = tracer.buildSpan("operation-name").start();
Tags.COMPONENT.set(span, expectedComponentName);
com.twitter.zipkin.thriftjava.Span zipkinSpan = ThriftSpanConverter.convertSpan(span);
String actualComponent = new String(zipkinSpan.getBinary_annotations().get(3).getValue(), StandardCharsets.UTF_8);
assertEquals(expectedComponentName, actualComponent);
}
use of io.jaegertracing.internal.JaegerSpan in project jaeger-client-java by jaegertracing.
the class ThriftSpanConverterTest method testSpanKindClientCreatesAnnotations.
@Test
public void testSpanKindClientCreatesAnnotations() {
JaegerSpan span = tracer.buildSpan("operation-name").start();
Tags.SPAN_KIND.set(span, Tags.SPAN_KIND_CLIENT);
com.twitter.zipkin.thriftjava.Span zipkinSpan = ThriftSpanConverter.convertSpan(span);
List<Annotation> annotations = zipkinSpan.getAnnotations();
boolean clientReceiveFound = false;
boolean clientSendFound = false;
for (Annotation anno : annotations) {
if (anno.getValue().equals(zipkincoreConstants.CLIENT_RECV)) {
clientReceiveFound = true;
}
if (anno.getValue().equals(zipkincoreConstants.CLIENT_SEND)) {
clientSendFound = true;
}
}
assertTrue(clientReceiveFound);
assertTrue(clientSendFound);
}
Aggregations