Search in sources :

Example 21 with InMemoryReporter

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

the class V2SpanConverterTest method testAddsTracerIpAsLocalIpV4.

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

Example 22 with InMemoryReporter

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

the class V2SpanConverterTest 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();
    }
    zipkin2.Span zipkinSpan = V2SpanConverter.convertSpan(span);
    Map<String, String> zipkinTags = zipkinSpan.tags();
    for (Map.Entry<String, String> entry : expectedTags.entrySet()) {
        String key = entry.getKey();
        Object expectedValue = entry.getValue();
        String tagValue = zipkinTags.get(key);
        if (expectedValue.equals(UNDEF)) {
            assertNull("Not expecting " + key + " for " + spanType, tagValue);
        } else if (expectedValue.equals(ANY)) {
            assertNotNull(key, tagValue);
        } else {
            assertEquals("Expecting " + key + " for " + spanType, expectedValue, tagValue);
        }
    }
}
Also used : InMemoryReporter(io.jaegertracing.internal.reporters.InMemoryReporter) 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 23 with InMemoryReporter

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

the class InMemoryMetricsFactoryTest method emptyValueForTag.

@Test
public void emptyValueForTag() {
    InMemoryMetricsFactory metricsFactory = new InMemoryMetricsFactory();
    JaegerTracer tracer = new JaegerTracer.Builder("metricsFactoryTest").withReporter(new InMemoryReporter()).withSampler(new ConstSampler(true)).withMetrics(new Metrics(metricsFactory)).build();
    tracer.buildSpan("theoperation").start();
    assertEquals(-1, metricsFactory.getCounter("jaeger_tracer_started_spans", "sampled"));
    assertEquals(-1, metricsFactory.getCounter("jaeger_tracer_started_spans", ""));
}
Also used : InMemoryReporter(io.jaegertracing.internal.reporters.InMemoryReporter) ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) JaegerTracer(io.jaegertracing.internal.JaegerTracer) Test(org.junit.Test)

Example 24 with InMemoryReporter

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

the class InMemoryMetricsFactoryTest method canBeUsedWithMetrics.

@Test
public void canBeUsedWithMetrics() {
    InMemoryMetricsFactory metricsFactory = new InMemoryMetricsFactory();
    JaegerTracer tracer = new JaegerTracer.Builder("metricsFactoryTest").withReporter(new InMemoryReporter()).withSampler(new ConstSampler(true)).withMetrics(new Metrics(metricsFactory)).build();
    tracer.buildSpan("theoperation").start();
    assertEquals(1, metricsFactory.getCounter("jaeger_tracer_started_spans", "sampled=y"));
    assertEquals(0, metricsFactory.getCounter("jaeger_tracer_started_spans", "sampled=n"));
    assertEquals(1, metricsFactory.getCounter("jaeger_tracer_traces", "sampled=y,state=started"));
    assertEquals(0, metricsFactory.getCounter("jaeger_tracer_traces", "sampled=n,state=started"));
}
Also used : InMemoryReporter(io.jaegertracing.internal.reporters.InMemoryReporter) ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) JaegerTracer(io.jaegertracing.internal.JaegerTracer) Test(org.junit.Test)

Example 25 with InMemoryReporter

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

the class TraceContextCodecTest method testDebugIdWithTraceHeader.

@Test
public void testDebugIdWithTraceHeader() {
    Map<String, String> extractCarrier = new HashMap<>();
    TextMapAdapter textMap = new TextMapAdapter(extractCarrier);
    textMap.put(TRACE_PARENT, EXAMPLE_TRACE_PARENT);
    textMap.put(Constants.DEBUG_ID_HEADER_KEY, EXAMPLE_DEBUG_ID);
    JaegerSpanContext spanContext = traceContextCodec.extract(textMap);
    JaegerTracer tracer = new JaegerTracer.Builder("service").withReporter(new InMemoryReporter()).build();
    assertEquals("0000000000000001", spanContext.getTraceId());
    JaegerSpan child = tracer.buildSpan("span").asChildOf(spanContext).start();
    assertFalse(child.context().isDebug());
    child.finish();
    tracer.close();
}
Also used : InMemoryReporter(io.jaegertracing.internal.reporters.InMemoryReporter) HashMap(java.util.HashMap) JaegerSpan(io.jaegertracing.internal.JaegerSpan) TextMapAdapter(io.opentracing.propagation.TextMapAdapter) JaegerSpanContext(io.jaegertracing.internal.JaegerSpanContext) JaegerTracer(io.jaegertracing.internal.JaegerTracer) Test(org.junit.Test)

Aggregations

InMemoryReporter (io.jaegertracing.internal.reporters.InMemoryReporter)29 ConstSampler (io.jaegertracing.internal.samplers.ConstSampler)22 JaegerTracer (io.jaegertracing.internal.JaegerTracer)19 Test (org.junit.Test)17 Before (org.junit.Before)12 JaegerSpan (io.jaegertracing.internal.JaegerSpan)7 InMemoryMetricsFactory (io.jaegertracing.internal.metrics.InMemoryMetricsFactory)6 Metrics (io.jaegertracing.internal.metrics.Metrics)5 HashMap (java.util.HashMap)5 Builder (io.jaegertracing.internal.JaegerTracer.Builder)3 TextMap (io.opentracing.propagation.TextMap)3 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)2 JaegerSpanContext (io.jaegertracing.internal.JaegerSpanContext)2 TextMapAdapter (io.opentracing.propagation.TextMapAdapter)2 Map (java.util.Map)2 TreeMap (java.util.TreeMap)2 BinaryAnnotation (com.twitter.zipkin.thriftjava.BinaryAnnotation)1 EndToEndBehavior (io.jaegertracing.crossdock.resources.behavior.EndToEndBehavior)1 DefaultBaggageRestrictionManager (io.jaegertracing.internal.baggage.DefaultBaggageRestrictionManager)1 Clock (io.jaegertracing.internal.clock.Clock)1