use of io.opentracing.Scope in project jaeger-client-java by jaegertracing.
the class JaegerSubclassTest method testTracer.
@Test
public void testTracer() {
final CustomConfiguration config = new CustomConfiguration("test-service");
final CustomTracer.CustomBuilder builder = config.getTracerBuilder();
final CustomTracer tracer = builder.build();
final Span span = tracer.buildSpan("test-operation").start();
try (Scope scope = tracer.activateSpan(span)) {
Assert.assertNotNull(tracer.scopeManager().activeSpan());
Assert.assertTrue(tracer.scopeManager().activeSpan() instanceof CustomSpan);
Assert.assertTrue(tracer.scopeManager().activeSpan().context() instanceof CustomSpanContext);
}
config.closeTracer();
}
use of io.opentracing.Scope 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.Scope 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.Scope in project jaeger-client-java by jaegertracing.
the class MDCScopeManagerTest method testNestedSpans.
@Test
public void testNestedSpans() {
Span parentSpan = defaultTracer.buildSpan("parent").start();
try (Scope scope = defaultTracer.activateSpan(parentSpan)) {
assertSpanContextEqualsToMDC((JaegerSpanContext) parentSpan.context(), TRACE_ID, SPAN_ID, SAMPLED);
Span childSpan = defaultTracer.buildSpan("child").start();
try (Scope childScope = defaultTracer.activateSpan(childSpan)) {
assertSpanContextEqualsToMDC((JaegerSpanContext) childSpan.context(), TRACE_ID, SPAN_ID, SAMPLED);
}
assertSpanContextEqualsToMDC((JaegerSpanContext) parentSpan.context(), TRACE_ID, SPAN_ID, SAMPLED);
}
assertNullMDCKeys(TRACE_ID, SPAN_ID, SAMPLED);
}
use of io.opentracing.Scope in project jaeger-client-java by jaegertracing.
the class MDCScopeManagerTest method testDefaultCreation.
@Test
public void testDefaultCreation() {
Span span = defaultTracer.buildSpan("test Default").start();
Scope scope = defaultTracer.activateSpan(span);
assertSpanContextEqualsToMDC((JaegerSpanContext) span.context(), TRACE_ID, SPAN_ID, SAMPLED);
scope.close();
assertNullMDCKeys(TRACE_ID, SPAN_ID, SAMPLED);
}
Aggregations