Search in sources :

Example 21 with InMemoryReporter

use of com.uber.jaeger.reporters.InMemoryReporter 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));
}
Also used : InMemoryReporter(com.uber.jaeger.reporters.InMemoryReporter) TextMapExtractAdapter(io.opentracing.propagation.TextMapExtractAdapter) HashMap(java.util.HashMap) ConstSampler(com.uber.jaeger.samplers.ConstSampler) TextMap(io.opentracing.propagation.TextMap) Test(org.junit.Test)

Example 22 with InMemoryReporter

use of com.uber.jaeger.reporters.InMemoryReporter 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());
}
Also used : InMemoryReporter(com.uber.jaeger.reporters.InMemoryReporter) Scope(io.opentracing.Scope) ConstSampler(com.uber.jaeger.samplers.ConstSampler) Test(org.junit.Test)

Example 23 with InMemoryReporter

use of com.uber.jaeger.reporters.InMemoryReporter 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());
}
Also used : InMemoryReporter(com.uber.jaeger.reporters.InMemoryReporter) Scope(io.opentracing.Scope) ConstSampler(com.uber.jaeger.samplers.ConstSampler) Test(org.junit.Test)

Example 24 with InMemoryReporter

use of com.uber.jaeger.reporters.InMemoryReporter in project jaeger-client-java by jaegertracing.

the class SpanTest method setUp.

@Before
public void setUp() {
    metricsFactory = new InMemoryMetricsFactory();
    reporter = new InMemoryReporter();
    clock = mock(Clock.class);
    metrics = new Metrics(metricsFactory);
    tracer = new Tracer.Builder("SamplerTest", reporter, new ConstSampler(true)).withMetrics(metrics).withClock(clock).withBaggageRestrictionManager(new DefaultBaggageRestrictionManager()).withExpandExceptionLogs().build();
    span = (Span) tracer.buildSpan("some-operation").start();
}
Also used : InMemoryReporter(com.uber.jaeger.reporters.InMemoryReporter) InMemoryMetricsFactory(com.uber.jaeger.metrics.InMemoryMetricsFactory) Metrics(com.uber.jaeger.metrics.Metrics) ConstSampler(com.uber.jaeger.samplers.ConstSampler) Clock(com.uber.jaeger.utils.Clock) DefaultBaggageRestrictionManager(com.uber.jaeger.baggage.DefaultBaggageRestrictionManager) Before(org.junit.Before)

Example 25 with InMemoryReporter

use of com.uber.jaeger.reporters.InMemoryReporter in project jaeger-client-java by jaegertracing.

the class TracerTagsTest method testDefaultHostTags.

@Test
public void testDefaultHostTags() throws Exception {
    InMemoryReporter spanReporter = new InMemoryReporter();
    Tracer tracer = new Tracer.Builder("x").withReporter(spanReporter).build();
    assertEquals(tracer.getHostName(), tracer.tags().get(Constants.TRACER_HOSTNAME_TAG_KEY));
    assertEquals(InetAddress.getLocalHost().getHostAddress(), tracer.tags().get(Constants.TRACER_IP_TAG_KEY));
    assertEquals(Utils.ipToInt(Inet4Address.getLocalHost().getHostAddress()), tracer.getIpv4());
}
Also used : InMemoryReporter(com.uber.jaeger.reporters.InMemoryReporter) Test(org.junit.Test)

Aggregations

InMemoryReporter (com.uber.jaeger.reporters.InMemoryReporter)30 ConstSampler (com.uber.jaeger.samplers.ConstSampler)26 Test (org.junit.Test)19 Before (org.junit.Before)10 Tracer (com.uber.jaeger.Tracer)7 Metrics (com.uber.jaeger.metrics.Metrics)5 Scope (io.opentracing.Scope)5 Builder (com.uber.jaeger.Tracer.Builder)4 InMemoryMetricsFactory (com.uber.jaeger.metrics.InMemoryMetricsFactory)4 InMemoryStatsReporter (com.uber.jaeger.metrics.InMemoryStatsReporter)3 TextMap (io.opentracing.propagation.TextMap)3 HashMap (java.util.HashMap)3 Tracer (io.opentracing.Tracer)2 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)1 BinaryAnnotation (com.twitter.zipkin.thriftjava.BinaryAnnotation)1 Span (com.uber.jaeger.Span)1 DefaultBaggageRestrictionManager (com.uber.jaeger.baggage.DefaultBaggageRestrictionManager)1 EndToEndBehavior (com.uber.jaeger.crossdock.resources.behavior.EndToEndBehavior)1 ClientFilter (com.uber.jaeger.filters.jaxrs2.ClientFilter)1 Sampler (com.uber.jaeger.samplers.Sampler)1