Search in sources :

Example 21 with JaegerTracer

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

the class JaegerTracerTagsTest method testDeclaredHostTags.

@Test
public void testDeclaredHostTags() {
    InMemoryReporter spanReporter = new InMemoryReporter();
    String hostname = "myhost";
    String ip = "1.1.1.1";
    JaegerTracer tracer = new JaegerTracer.Builder("x").withReporter(spanReporter).withTag(Constants.TRACER_HOSTNAME_TAG_KEY, hostname).withTag(Constants.TRACER_IP_TAG_KEY, ip).build();
    assertEquals(hostname, tracer.tags().get(Constants.TRACER_HOSTNAME_TAG_KEY));
    assertEquals(ip, tracer.tags().get(Constants.TRACER_IP_TAG_KEY));
    assertEquals(Utils.ipToInt(ip), tracer.getIpv4());
}
Also used : InMemoryReporter(io.jaegertracing.internal.reporters.InMemoryReporter) JaegerTracer(io.jaegertracing.internal.JaegerTracer) Test(org.junit.Test)

Example 22 with JaegerTracer

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

the class ConfigurationTest method testPropagationB3Only.

@Test
public void testPropagationB3Only() {
    System.setProperty(Configuration.JAEGER_PROPAGATION, "b3");
    System.setProperty(Configuration.JAEGER_SERVICE_NAME, "Test");
    long traceIdLow = 1234L;
    long spanId = 5678L;
    TestTextMap textMap = new TestTextMap();
    JaegerSpanContext spanContext = new JaegerSpanContext(0, traceIdLow, spanId, 0, (byte) 0);
    JaegerTracer tracer = Configuration.fromEnv().getTracer();
    tracer.inject(spanContext, Format.Builtin.TEXT_MAP, textMap);
    assertNotNull(textMap.get("X-B3-TraceId"));
    assertNotNull(textMap.get("X-B3-SpanId"));
    assertNull(textMap.get("uber-trace-id"));
    JaegerSpanContext extractedContext = tracer.extract(Format.Builtin.TEXT_MAP, textMap);
    assertEquals(traceIdLow, extractedContext.getTraceIdLow());
    assertEquals(0, extractedContext.getTraceIdHigh());
    assertEquals(spanId, extractedContext.getSpanId());
}
Also used : JaegerSpanContext(io.jaegertracing.internal.JaegerSpanContext) JaegerTracer(io.jaegertracing.internal.JaegerTracer) Test(org.junit.Test)

Example 23 with JaegerTracer

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

the class ConfigurationTest method testTracerTagsSubstitutionSpecified.

@Test
public void testTracerTagsSubstitutionSpecified() {
    System.setProperty(Configuration.JAEGER_SERVICE_NAME, "Test");
    System.setProperty(TEST_PROPERTY, "goodbye");
    System.setProperty(Configuration.JAEGER_TAGS, "testTag1=${" + TEST_PROPERTY + ":hello}");
    JaegerTracer tracer = Configuration.fromEnv().getTracer();
    assertEquals("goodbye", tracer.tags().get("testTag1"));
}
Also used : JaegerTracer(io.jaegertracing.internal.JaegerTracer) Test(org.junit.Test)

Example 24 with JaegerTracer

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

the class ConfigurationTest method testFromEnvWithExplicitServiceName.

@Test
public void testFromEnvWithExplicitServiceName() {
    // prepare
    String serviceName = "testFromEnvWithExplicitServiceName";
    System.setProperty(Configuration.JAEGER_SERVICE_NAME, "not" + serviceName);
    // test
    JaegerTracer tracer = Configuration.fromEnv(serviceName).getTracer();
    // check
    assertEquals(serviceName, tracer.getServiceName());
}
Also used : JaegerTracer(io.jaegertracing.internal.JaegerTracer) Test(org.junit.Test)

Example 25 with JaegerTracer

use of io.jaegertracing.internal.JaegerTracer 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);
}
Also used : Tracer(io.opentracing.Tracer) JaegerTracer(io.jaegertracing.internal.JaegerTracer) 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