Search in sources :

Example 16 with JaegerTracer

use of io.jaegertracing.internal.JaegerTracer in project jaeger-client-java by jaegertracing.

the class ThriftSenderTest method appendFail.

@Test(expected = SenderException.class)
public void appendFail() throws Exception {
    int size = 0;
    ThriftSender sender = new ThriftSender(ProtocolType.Compact, 0) {

        @Override
        public void send(Process process, List<Span> spans) throws SenderException {
            throw new SenderException("", null, spans.size());
        }
    };
    JaegerTracer tracer = new JaegerTracer.Builder("failure").build();
    sender.append(tracer.buildSpan("flush-fail").start());
    sender.flush();
}
Also used : Process(io.jaegertracing.thriftjava.Process) List(java.util.List) SenderException(io.jaegertracing.internal.exceptions.SenderException) JaegerTracer(io.jaegertracing.internal.JaegerTracer) Test(org.junit.Test)

Example 17 with JaegerTracer

use of io.jaegertracing.internal.JaegerTracer in project jaeger-client-java by jaegertracing.

the class ThriftSenderTest method flushFail.

@Test(expected = SenderException.class)
public void flushFail() throws Exception {
    ThriftSender sender = new ThriftSender(ProtocolType.Compact, 0) {

        @Override
        public void send(Process process, List<Span> spans) throws SenderException {
            throw new SenderException("", null, spans.size());
        }
    };
    JaegerTracer tracer = new JaegerTracer.Builder("failure").build();
    sender.append(tracer.buildSpan("flush-fail").start());
    sender.flush();
}
Also used : Process(io.jaegertracing.thriftjava.Process) List(java.util.List) SenderException(io.jaegertracing.internal.exceptions.SenderException) JaegerTracer(io.jaegertracing.internal.JaegerTracer) Test(org.junit.Test)

Example 18 with JaegerTracer

use of io.jaegertracing.internal.JaegerTracer in project jaeger-client-java by jaegertracing.

the class JaegerTracerResolverTest method canFindTracerResolver.

@Test
public void canFindTracerResolver() {
    System.setProperty(Configuration.JAEGER_SERVICE_NAME, "canFindTracerResolver");
    TracerResolver tracerResolver = ServiceLoader.load(TracerResolver.class).iterator().next();
    assertNotNull(tracerResolver);
    assertTrue(tracerResolver instanceof JaegerTracerResolver);
    JaegerTracer tracer = ((JaegerTracerResolver) tracerResolver).resolve();
    assertNotNull(tracer);
}
Also used : TracerResolver(io.opentracing.contrib.tracerresolver.TracerResolver) JaegerTracer(io.jaegertracing.internal.JaegerTracer) Test(org.junit.Test)

Example 19 with JaegerTracer

use of io.jaegertracing.internal.JaegerTracer in project jaeger-client-java by jaegertracing.

the class JaegerTracerTagsTest method testTracerTags.

@Test
public void testTracerTags() {
    InMemoryReporter spanReporter = new InMemoryReporter();
    JaegerTracer tracer = new JaegerTracer.Builder("x").withReporter(spanReporter).withSampler(new ConstSampler(true)).withZipkinSharedRpcSpan().withTag("tracer.tag.str", "y").build();
    JaegerSpan jaegerSpan = tracer.buildSpan("root").start();
    // span should only contain sampler tags and no tracer tags
    assertEquals(2, jaegerSpan.getTags().size());
    assertEquals(true, jaegerSpan.getTags().containsKey("sampler.type"));
    assertEquals(true, jaegerSpan.getTags().containsKey("sampler.param"));
    assertEquals(false, jaegerSpan.getTags().containsKey("tracer.tag.str"));
}
Also used : InMemoryReporter(io.jaegertracing.internal.reporters.InMemoryReporter) JaegerSpan(io.jaegertracing.internal.JaegerSpan) ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) JaegerTracer(io.jaegertracing.internal.JaegerTracer) Test(org.junit.Test)

Example 20 with JaegerTracer

use of io.jaegertracing.internal.JaegerTracer in project jaeger-client-java by jaegertracing.

the class JaegerTracerTagsTest method testEmptyDeclaredIpTag.

@Test
public void testEmptyDeclaredIpTag() {
    InMemoryReporter spanReporter = new InMemoryReporter();
    String ip = "";
    JaegerTracer tracer = new JaegerTracer.Builder("x").withReporter(spanReporter).withTag(Constants.TRACER_IP_TAG_KEY, ip).build();
    assertEquals(0, tracer.getIpv4());
}
Also used : InMemoryReporter(io.jaegertracing.internal.reporters.InMemoryReporter) JaegerTracer(io.jaegertracing.internal.JaegerTracer) Test(org.junit.Test)

Aggregations

JaegerTracer (io.jaegertracing.internal.JaegerTracer)33 Test (org.junit.Test)29 InMemoryReporter (io.jaegertracing.internal.reporters.InMemoryReporter)12 ConstSampler (io.jaegertracing.internal.samplers.ConstSampler)8 JaegerSpan (io.jaegertracing.internal.JaegerSpan)7 JaegerSpanContext (io.jaegertracing.internal.JaegerSpanContext)7 HashMap (java.util.HashMap)7 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)4 List (java.util.List)3 Map (java.util.Map)3 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)2 Configuration (io.jaegertracing.Configuration)2 SenderException (io.jaegertracing.internal.exceptions.SenderException)2 Sampler (io.jaegertracing.spi.Sampler)2 Process (io.jaegertracing.thriftjava.Process)2 Tracer (io.opentracing.Tracer)2 TextMap (io.opentracing.propagation.TextMap)2 TextMapAdapter (io.opentracing.propagation.TextMapAdapter)2 TreeMap (java.util.TreeMap)2 BinaryAnnotation (com.twitter.zipkin.thriftjava.BinaryAnnotation)1