use of io.jaegertracing.internal.JaegerSpan in project jaeger-client-java by jaegertracing.
the class ThriftSpanConverterTest method testSpanDetectsEndpointTags.
@Test
public void testSpanDetectsEndpointTags() {
int expectedIp = (127 << 24) | 1;
int expectedPort = 8080;
String expectedServiceName = "some-peer-service";
JaegerSpan span = tracer.buildSpan("test-service-operation").start();
Tags.PEER_HOST_IPV4.set(span, expectedIp);
Tags.PEER_PORT.set(span, expectedPort);
Tags.PEER_SERVICE.set(span, expectedServiceName);
assertEquals(expectedIp, ThriftSpanConverter.extractPeerEndpoint(span.getTags()).getIpv4());
assertEquals(expectedPort, ThriftSpanConverter.extractPeerEndpoint(span.getTags()).getPort());
assertEquals(expectedServiceName, ThriftSpanConverter.extractPeerEndpoint(span.getTags()).getService_name());
}
use of io.jaegertracing.internal.JaegerSpan in project jaeger-client-java by jaegertracing.
the class V2SpanConverterTest method testAddsTracerIpAsLocalIpV4.
@Test
public void testAddsTracerIpAsLocalIpV4() {
tracer = new JaegerTracer.Builder("test-service-name").withReporter(new InMemoryReporter()).withSampler(new ConstSampler(true)).withZipkinSharedRpcSpan().withTag(Constants.TRACER_IP_TAG_KEY, "1.2.3.4").build();
JaegerSpan span = tracer.buildSpan("operation-name").start();
zipkin2.Span zipkinSpan = V2SpanConverter.convertSpan(span);
assertEquals(zipkinSpan.localEndpoint().ipv4(), "1.2.3.4");
}
use of io.jaegertracing.internal.JaegerSpan in project jaeger-client-java by jaegertracing.
the class V2SpanConverterTest method testRpcChildSpanHasTheSameId.
@Test
@SuppressWarnings("Duplicates")
public void testRpcChildSpanHasTheSameId() {
String expectedOperation = "parent";
JaegerSpan client = tracer.buildSpan(expectedOperation).withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT).start();
Map<String, String> map = new HashMap<>();
TextMap carrier = new TextMapAdapter(map);
tracer.inject(client.context(), Format.Builtin.TEXT_MAP, carrier);
JaegerSpanContext ctx = tracer.extract(Format.Builtin.TEXT_MAP, carrier);
JaegerSpanContext clientCtx = client.context();
assertEquals(clientCtx.getSpanId(), ctx.getSpanId());
JaegerSpan server = tracer.buildSpan("child").withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER).asChildOf(ctx).start();
JaegerSpanContext serverCtx = server.context();
assertEquals("client and server must have the same span ID", clientCtx.getSpanId(), serverCtx.getSpanId());
}
use of io.jaegertracing.internal.JaegerSpan in project jaeger-client-java by jaegertracing.
the class V2SpanConverterTest method testSpanLogsCreateAnnotations.
@Test
public void testSpanLogsCreateAnnotations() {
JaegerSpan span = tracer.buildSpan("span-with-logs").start();
span.log("event");
// use sorted map for consistent ordering in test
Map<String, Object> fields = new TreeMap<String, Object>();
fields.put("event", "structured data");
fields.put("string", "something");
fields.put("number", 42);
fields.put("boolean", true);
span.log(fields);
zipkin2.Span zipkinSpan = V2SpanConverter.convertSpan(span);
List<String> annotationValues = new ArrayList<String>();
for (Annotation annotation : zipkinSpan.annotations()) {
annotationValues.add(annotation.value());
}
List<String> expectedValues = new ArrayList<String>();
expectedValues.add("event");
expectedValues.add("{\"boolean\":true,\"event\":\"structured data\",\"number\":42,\"string\":\"something\"}");
assertEquals("zipkin span should contain matching annotations for span logs", expectedValues, annotationValues);
}
use of io.jaegertracing.internal.JaegerSpan in project jaeger-client-java by jaegertracing.
the class V2SpanConverterTest method testExpectedLocalComponentNameUsed.
@Test
public void testExpectedLocalComponentNameUsed() {
String expectedComponentName = "local-name";
JaegerSpan span = tracer.buildSpan("operation-name").start();
Tags.COMPONENT.set(span, expectedComponentName);
zipkin2.Span zipkinSpan = V2SpanConverter.convertSpan(span);
String actualComponent = zipkinSpan.tags().get(Tags.COMPONENT.getKey());
assertEquals(expectedComponentName, actualComponent);
}
Aggregations