use of io.opentracing.Tracer in project jaeger-client-java by jaegertracing.
the class JaegerTracerResolverTest method testResolveTracerDefault.
@Test
public void testResolveTracerDefault() {
System.setProperty(Configuration.JAEGER_SERVICE_NAME, "MyService");
Tracer tracer = TracerResolver.resolveTracer();
assertNotNull(tracer);
assertTrue(tracer instanceof JaegerTracer);
}
use of io.opentracing.Tracer 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.opentracing.Tracer in project jaeger-client-java by jaegertracing.
the class MDCScopeManagerTest method testCustomAndDefaultKeysCreation.
@Test
public void testCustomAndDefaultKeysCreation() {
ScopeManager mdcScopeManager = new MDCScopeManager.Builder().withMDCSampledKey("customSampled").withMDCSpanIdKey("customSpanId").build();
Tracer tracer = createTracer(mdcScopeManager);
Span span = tracer.buildSpan("testCustomAndDefaultKeysCreation").start();
Scope scope = tracer.activateSpan(span);
assertSpanContextEqualsToMDC((JaegerSpanContext) span.context(), TRACE_ID, "customSpanId", "customSampled");
scope.close();
assertNullMDCKeys(TRACE_ID, "customSpanId", "customSampled");
}
use of io.opentracing.Tracer in project jaeger-client-java by jaegertracing.
the class MDCScopeManagerTest method testCustomKeysCreation.
@Test
public void testCustomKeysCreation() {
ScopeManager mdcScopeManager = new MDCScopeManager.Builder().withMDCTraceIdKey("CustomTraceId").withMDCSampledKey("customSampled").withMDCSpanIdKey("customSpanId").build();
Tracer tracer = createTracer(mdcScopeManager);
Span span = tracer.buildSpan("testCustomKeysCreation").start();
Scope scope = tracer.activateSpan(span);
assertSpanContextEqualsToMDC((JaegerSpanContext) span.context(), "CustomTraceId", "customSpanId", "customSampled");
scope.close();
assertNullMDCKeys("CustomTraceId", "customSampled", "customSpanId");
}
use of io.opentracing.Tracer in project jaeger-client-java by jaegertracing.
the class EndToEndBehavior method generateTraces.
public void generateTraces(CreateTracesRequest request) {
String samplerType = request.getType();
Tracer tracer = tracers.get(samplerType);
for (int i = 0; i < request.getCount(); i++) {
Tracer.SpanBuilder builder = tracer.buildSpan(request.getOperation());
if (request.getTags() != null) {
for (Map.Entry<String, String> kv : request.getTags().entrySet()) {
builder.withTag(kv.getKey(), kv.getValue());
}
}
Span span = builder.start();
span.finish();
}
}
Aggregations