Search in sources :

Example 11 with ConstSampler

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

the class ThriftSpanConverterTest method setUp.

@Before
public void setUp() {
    final JaegerTracer.Builder tracerBuilder = new JaegerTracer.Builder("test-service-name").withReporter(new InMemoryReporter()).withSampler(new ConstSampler(true)).withZipkinSharedRpcSpan();
    tracer = tracerBuilder.build();
    tracer128 = tracerBuilder.withTraceId128Bit().build();
}
Also used : InMemoryReporter(io.jaegertracing.internal.reporters.InMemoryReporter) ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) JaegerTracer(io.jaegertracing.internal.JaegerTracer) Before(org.junit.Before)

Example 12 with ConstSampler

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

the class ThriftSpanConverterTest method testTracerTags.

@Test
@UseDataProvider("dataProviderTracerTags")
public void testTracerTags(SpanType spanType, Map<String, String> expectedTags) {
    InMemoryReporter spanReporter = new InMemoryReporter();
    JaegerTracer tracer = new JaegerTracer.Builder("x").withReporter(spanReporter).withSampler(new ConstSampler(true)).withZipkinSharedRpcSpan().withTag("tag.str", "y").withTag("tag.bool", true).withTag("tag.num", 1).build();
    JaegerSpan span = tracer.buildSpan("root").start();
    if (spanType == SpanType.CHILD) {
        span = tracer.buildSpan("child").asChildOf(span).start();
    } else if (spanType == SpanType.RPC_SERVER) {
        span = tracer.buildSpan("rpc-server").asChildOf(span).withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER).start();
    }
    com.twitter.zipkin.thriftjava.Span zipkinSpan = ThriftSpanConverter.convertSpan(span);
    List<BinaryAnnotation> annotations = zipkinSpan.getBinary_annotations();
    for (Map.Entry<String, String> entry : expectedTags.entrySet()) {
        String key = entry.getKey();
        Object expectedValue = entry.getValue();
        BinaryAnnotation anno = findBinaryAnnotation(annotations, key);
        if (expectedValue.equals(UNDEF)) {
            assertNull("Not expecting " + key + " for " + spanType, anno);
        } else if (expectedValue.equals(ANY)) {
            assertEquals(key, anno.getKey());
        } else {
            String actualValue = new String(anno.getValue(), StandardCharsets.UTF_8);
            assertEquals("Expecting " + key + " for " + spanType, expectedValue, actualValue);
        }
    }
}
Also used : InMemoryReporter(io.jaegertracing.internal.reporters.InMemoryReporter) BinaryAnnotation(com.twitter.zipkin.thriftjava.BinaryAnnotation) JaegerSpan(io.jaegertracing.internal.JaegerSpan) ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) HashMap(java.util.HashMap) Map(java.util.Map) TextMap(io.opentracing.propagation.TextMap) TreeMap(java.util.TreeMap) JaegerTracer(io.jaegertracing.internal.JaegerTracer) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 13 with ConstSampler

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

the class V2SpanConverterTest method testDoesntAddUnknownTracerIpAsLocalIpV4.

@Test
public void testDoesntAddUnknownTracerIpAsLocalIpV4() {
    tracer = new JaegerTracer.Builder("test-service-name").withReporter(new InMemoryReporter()).withSampler(new ConstSampler(true)).withZipkinSharedRpcSpan().withTag(Constants.TRACER_IP_TAG_KEY, "").build();
    JaegerSpan span = tracer.buildSpan("operation-name").start();
    zipkin2.Span zipkinSpan = V2SpanConverter.convertSpan(span);
    assertNull(zipkinSpan.localEndpoint().ipv4());
}
Also used : InMemoryReporter(io.jaegertracing.internal.reporters.InMemoryReporter) JaegerSpan(io.jaegertracing.internal.JaegerSpan) ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) Test(org.junit.Test)

Example 14 with ConstSampler

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

the class JaegerThriftSpanConverterTest method setUp.

@Before
public void setUp() {
    final JaegerTracer.Builder tracerBuilder = new JaegerTracer.Builder("test-service-name").withReporter(new InMemoryReporter()).withSampler(new ConstSampler(true));
    tracer = tracerBuilder.build();
    tracer128 = tracerBuilder.withTraceId128Bit().build();
}
Also used : InMemoryReporter(io.jaegertracing.internal.reporters.InMemoryReporter) ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) JaegerTracer(io.jaegertracing.internal.JaegerTracer) Before(org.junit.Before)

Example 15 with ConstSampler

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

the class EndToEndBehaviorResourceTest method setUp.

@Before
public void setUp() throws Exception {
    reporter = new InMemoryReporter();
    Tracer tracer = new JaegerTracer.Builder("crossdock-java").withReporter(reporter).withSampler(new ConstSampler(true)).build();
    Map<String, Tracer> tracers = new HashMap<>();
    tracers.put("const", tracer);
    resource = new EndToEndBehaviorResource(new EndToEndBehavior(tracers));
}
Also used : InMemoryReporter(io.jaegertracing.internal.reporters.InMemoryReporter) EndToEndBehavior(io.jaegertracing.crossdock.resources.behavior.EndToEndBehavior) HashMap(java.util.HashMap) Tracer(io.opentracing.Tracer) JaegerTracer(io.jaegertracing.internal.JaegerTracer) ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) JaegerTracer(io.jaegertracing.internal.JaegerTracer) Before(org.junit.Before)

Aggregations

ConstSampler (io.jaegertracing.internal.samplers.ConstSampler)33 InMemoryReporter (io.jaegertracing.internal.reporters.InMemoryReporter)22 JaegerTracer (io.jaegertracing.internal.JaegerTracer)21 Test (org.junit.Test)19 Before (org.junit.Before)13 InMemoryMetricsFactory (io.jaegertracing.internal.metrics.InMemoryMetricsFactory)9 Metrics (io.jaegertracing.internal.metrics.Metrics)7 JaegerSpan (io.jaegertracing.internal.JaegerSpan)6 Builder (io.jaegertracing.internal.reporters.RemoteReporter.Builder)5 InMemorySender (io.jaegertracing.internal.senders.InMemorySender)4 Builder (io.jaegertracing.internal.JaegerTracer.Builder)3 TextMap (io.opentracing.propagation.TextMap)3 HashMap (java.util.HashMap)3 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)2 DefaultBaggageRestrictionManager (io.jaegertracing.internal.baggage.DefaultBaggageRestrictionManager)2 SenderException (io.jaegertracing.internal.exceptions.SenderException)2 Sampler (io.jaegertracing.spi.Sampler)2 Map (java.util.Map)2 TreeMap (java.util.TreeMap)2 CountDownLatch (java.util.concurrent.CountDownLatch)2