use of io.jaegertracing.internal.JaegerTracer in project jaeger-client-java by jaegertracing.
the class JaegerTracerResolverTest method canFindTracerFactory.
@Test
public void canFindTracerFactory() {
System.setProperty(Configuration.JAEGER_SERVICE_NAME, "canFindTracerFactory");
Tracer tracer = ServiceLoader.load(TracerFactory.class).iterator().next().getTracer();
assertNotNull(tracer);
assertTrue(tracer instanceof JaegerTracer);
}
use of io.jaegertracing.internal.JaegerTracer in project jaeger-client-java by jaegertracing.
the class ThriftSpanConverter method convertSpan.
public static com.twitter.zipkin.thriftjava.Span convertSpan(JaegerSpan jaegerSpan) {
JaegerTracer tracer = jaegerSpan.getTracer();
Endpoint host = new Endpoint(tracer.getIpv4(), (short) 0, tracer.getServiceName());
JaegerSpanContext context = jaegerSpan.context();
return new com.twitter.zipkin.thriftjava.Span(context.getTraceIdLow(), jaegerSpan.getOperationName(), context.getSpanId(), buildAnnotations(jaegerSpan, host), buildBinaryAnnotations(jaegerSpan, host)).setParent_id(context.getParentId()).setTrace_id_high(context.getTraceIdHigh()).setDebug(context.isDebug()).setTimestamp(jaegerSpan.getStart()).setDuration(jaegerSpan.getDuration());
}
use of io.jaegertracing.internal.JaegerTracer in project jaeger-client-java by jaegertracing.
the class V2SpanConverter method convertSpan.
public static zipkin2.Span convertSpan(JaegerSpan span) {
JaegerTracer tracer = span.getTracer();
zipkin2.Endpoint.Builder host = zipkin2.Endpoint.newBuilder().serviceName(tracer.getServiceName());
if (tracer.getIpv4() != 0) {
host.parseIp(convertIp(tracer.getIpv4()));
}
zipkin2.Endpoint peerEndpoint = extractPeerEndpoint(span.getTags());
JaegerSpanContext context = span.context();
zipkin2.Span.Builder builder = zipkin2.Span.newBuilder().id(Long.toHexString(context.getSpanId())).traceId(context.getTraceIdHigh(), context.getTraceIdLow()).name(span.getOperationName()).parentId(Long.toHexString(context.getParentId())).debug(context.isDebug()).localEndpoint(host.build()).remoteEndpoint(peerEndpoint).kind(convertKind(span.getTags().get(Tags.SPAN_KIND.getKey()))).timestamp(span.getStart()).duration(span.getDuration());
buildAnnotations(span, builder);
buildTags(span, builder);
return builder.build();
}
use of io.jaegertracing.internal.JaegerTracer in project jaeger-client-java by jaegertracing.
the class ThriftSpanConverterTest method dataProviderTracerTags.
@DataProvider
public static Object[][] dataProviderTracerTags() {
JaegerTracer tracer = new JaegerTracer.Builder("x").withReporter(null).withSampler(null).build();
Map<String, String> rootTags = new HashMap<>();
rootTags.put("tracer.jaeger.version", tracer.getVersion());
rootTags.put("tracer.hostname", ANY);
rootTags.put("tracer.tag.str", "y");
rootTags.put("tracer.tag.bool", "true");
rootTags.put("tracer.tag.num", "1");
rootTags.put("sampler.type", "const");
rootTags.put("sampler.param", "true");
Map<String, String> childTags = new HashMap<>();
childTags.put("tracer.jaeger.version", UNDEF);
childTags.put("tracer.hostname", UNDEF);
childTags.put("tracer.tag.str", UNDEF);
childTags.put("tracer.tag.bool", UNDEF);
childTags.put("tracer.tag.num", UNDEF);
childTags.put("sampler.type", UNDEF);
childTags.put("sampler.param", UNDEF);
Map<String, String> rpcTags = new HashMap<>();
rpcTags.put("tracer.jaeger.version", tracer.getVersion());
rpcTags.put("tracer.hostname", ANY);
rpcTags.put("tracer.tag.str", "y");
rpcTags.put("tracer.tag.bool", "true");
rpcTags.put("tracer.tag.num", "1");
rpcTags.put("sampler.type", UNDEF);
rpcTags.put("sampler.param", UNDEF);
return new Object[][] { { SpanType.ROOT, rootTags }, { SpanType.CHILD, childTags }, { SpanType.RPC_SERVER, rpcTags } };
}
use of io.jaegertracing.internal.JaegerTracer in project jaeger-client-java by jaegertracing.
the class V2SpanConverterTest 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();
}
zipkin2.Span zipkinSpan = V2SpanConverter.convertSpan(span);
Map<String, String> zipkinTags = zipkinSpan.tags();
for (Map.Entry<String, String> entry : expectedTags.entrySet()) {
String key = entry.getKey();
Object expectedValue = entry.getValue();
String tagValue = zipkinTags.get(key);
if (expectedValue.equals(UNDEF)) {
assertNull("Not expecting " + key + " for " + spanType, tagValue);
} else if (expectedValue.equals(ANY)) {
assertNotNull(key, tagValue);
} else {
assertEquals("Expecting " + key + " for " + spanType, expectedValue, tagValue);
}
}
}
Aggregations