use of com.uber.jaeger.samplers.ConstSampler in project jaeger-client-java by jaegertracing.
the class PropagationTest method testActiveSpanAutoFinishOnClose.
@Test
public void testActiveSpanAutoFinishOnClose() {
InMemoryReporter reporter = new InMemoryReporter();
Tracer tracer = new Tracer.Builder("test", reporter, new ConstSampler(true)).build();
tracer.buildSpan("parent").startActive(true).close();
assertEquals(1, reporter.getSpans().size());
}
use of com.uber.jaeger.samplers.ConstSampler in project jaeger-client-java by jaegertracing.
the class PropagationTest method testCustomScopeManager.
@Test
public void testCustomScopeManager() {
Scope scope = mock(Scope.class);
Tracer tracer = new Tracer.Builder("test", new InMemoryReporter(), new ConstSampler(true)).withScopeManager(new ScopeManager() {
@Override
public Scope activate(io.opentracing.Span span, boolean finishSpanOnClose) {
return scope;
}
@Override
public Scope active() {
return scope;
}
}).build();
assertEquals(scope, tracer.scopeManager().active());
}
use of com.uber.jaeger.samplers.ConstSampler in project jaeger-client-java by jaegertracing.
the class PropagationTest method testDebugCorrelationId.
@Test
public void testDebugCorrelationId() {
Tracer tracer = new Tracer.Builder("test", new InMemoryReporter(), new ConstSampler(true)).build();
Map<String, String> headers = new HashMap<>();
headers.put(Constants.DEBUG_ID_HEADER_KEY, "Coraline");
TextMap carrier = new TextMapExtractAdapter(headers);
SpanContext spanContext = (SpanContext) tracer.extract(Format.Builtin.TEXT_MAP, carrier);
assertTrue(spanContext.isDebugIdContainerOnly());
assertEquals("Coraline", spanContext.getDebugId());
Span span = (Span) tracer.buildSpan("span").asChildOf(spanContext).start();
spanContext = (SpanContext) span.context();
assertTrue(spanContext.isSampled());
assertTrue(spanContext.isDebug());
assertEquals("Coraline", span.getTags().get(Constants.DEBUG_ID_HEADER_KEY));
}
use of com.uber.jaeger.samplers.ConstSampler in project jaeger-client-java by jaegertracing.
the class PropagationTest method testActiveSpanNotAutoFinishOnClose.
@Test
public void testActiveSpanNotAutoFinishOnClose() {
InMemoryReporter reporter = new InMemoryReporter();
Tracer tracer = new Tracer.Builder("test", reporter, new ConstSampler(true)).build();
Scope scope = tracer.buildSpan("parent").startActive(false);
Span span = (Span) scope.span();
scope.close();
assertTrue(reporter.getSpans().isEmpty());
span.finish();
assertEquals(1, reporter.getSpans().size());
}
use of com.uber.jaeger.samplers.ConstSampler in project jaeger-client-java by jaegertracing.
the class PropagationTest method testActiveSpanAutoReference.
@Test
public void testActiveSpanAutoReference() {
InMemoryReporter reporter = new InMemoryReporter();
Tracer tracer = new Tracer.Builder("test", reporter, new ConstSampler(true)).build();
try (Scope parent = tracer.buildSpan("parent").startActive(true)) {
tracer.buildSpan("child").startActive(true).close();
}
assertEquals(2, reporter.getSpans().size());
Span childSpan = reporter.getSpans().get(0);
Span parentSpan = reporter.getSpans().get(1);
assertEquals("child", childSpan.getOperationName());
assertEquals(1, childSpan.getReferences().size());
assertEquals("parent", parentSpan.getOperationName());
assertTrue(parentSpan.getReferences().isEmpty());
assertEquals(References.CHILD_OF, childSpan.getReferences().get(0).getType());
assertEquals(parentSpan.context(), childSpan.getReferences().get(0).getSpanContext());
assertEquals(parentSpan.context().getTraceId(), childSpan.context().getTraceId());
assertEquals(parentSpan.context().getSpanId(), childSpan.context().getParentId());
}
Aggregations