Search in sources :

Example 21 with TextMap

use of io.opentracing.propagation.TextMap in project jaeger-client-java by jaegertracing.

the class B3TextMapCodecTest method testExtract_unsampled.

@Test
public void testExtract_unsampled() throws Exception {
    TextMap textMap = makeRequestWithSpanId(null);
    SpanContext context = b3Codec.extract(textMap);
    assertEquals(null, context);
}
Also used : SpanContext(com.uber.jaeger.SpanContext) TextMap(io.opentracing.propagation.TextMap) Test(org.junit.Test)

Example 22 with TextMap

use of io.opentracing.propagation.TextMap in project jaeger-client-java by jaegertracing.

the class Configuration method getTracerBuilder.

public Tracer.Builder getTracerBuilder() {
    if (reporterConfig == null) {
        reporterConfig = new ReporterConfiguration();
    }
    if (samplerConfig == null) {
        samplerConfig = new SamplerConfiguration();
    }
    if (codecConfig == null) {
        codecConfig = new CodecConfiguration(Collections.<Format<?>, List<Codec<TextMap>>>emptyMap());
    }
    if (metricsFactory == null) {
        metricsFactory = new NoopMetricsFactory();
    }
    Metrics metrics = new Metrics(metricsFactory);
    Reporter reporter = reporterConfig.getReporter(metrics);
    Sampler sampler = samplerConfig.createSampler(serviceName, metrics);
    Tracer.Builder builder = new Tracer.Builder(serviceName).withSampler(sampler).withReporter(reporter).withMetrics(metrics).withTags(tracerTags);
    codecConfig.apply(builder);
    return builder;
}
Also used : Reporter(com.uber.jaeger.reporters.Reporter) LoggingReporter(com.uber.jaeger.reporters.LoggingReporter) CompositeReporter(com.uber.jaeger.reporters.CompositeReporter) RemoteReporter(com.uber.jaeger.reporters.RemoteReporter) Metrics(com.uber.jaeger.metrics.Metrics) NumberFormat(java.text.NumberFormat) Format(io.opentracing.propagation.Format) RemoteControlledSampler(com.uber.jaeger.samplers.RemoteControlledSampler) RateLimitingSampler(com.uber.jaeger.samplers.RateLimitingSampler) Sampler(com.uber.jaeger.samplers.Sampler) ConstSampler(com.uber.jaeger.samplers.ConstSampler) ProbabilisticSampler(com.uber.jaeger.samplers.ProbabilisticSampler) LinkedList(java.util.LinkedList) List(java.util.List) TextMap(io.opentracing.propagation.TextMap) NoopMetricsFactory(com.uber.jaeger.metrics.NoopMetricsFactory)

Example 23 with TextMap

use of io.opentracing.propagation.TextMap in project jaeger-client-java by jaegertracing.

the class ThriftSpanConverterTest method testRpcChildSpanHasTheSameId.

@Test
public void testRpcChildSpanHasTheSameId() {
    String expectedOperation = "parent";
    JaegerSpan client = tracer.buildSpan(expectedOperation).withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT).start();
    Map<String, String> map = new HashMap<>();
    TextMap carrier = new TextMapAdapter(map);
    tracer.inject(client.context(), Format.Builtin.TEXT_MAP, carrier);
    JaegerSpanContext ctx = tracer.extract(Format.Builtin.TEXT_MAP, carrier);
    JaegerSpanContext clientCtx = client.context();
    assertEquals(clientCtx.getSpanId(), ctx.getSpanId());
    JaegerSpan server = tracer.buildSpan("child").withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER).asChildOf(ctx).start();
    JaegerSpanContext serverCtx = server.context();
    assertEquals("client and server must have the same span ID", clientCtx.getSpanId(), serverCtx.getSpanId());
}
Also used : HashMap(java.util.HashMap) JaegerSpan(io.jaegertracing.internal.JaegerSpan) TextMap(io.opentracing.propagation.TextMap) TextMapAdapter(io.opentracing.propagation.TextMapAdapter) JaegerSpanContext(io.jaegertracing.internal.JaegerSpanContext) Test(org.junit.Test)

Example 24 with TextMap

use of io.opentracing.propagation.TextMap in project jaeger-client-java by jaegertracing.

the class V2SpanConverterTest method testRpcChildSpanHasTheSameId.

@Test
@SuppressWarnings("Duplicates")
public void testRpcChildSpanHasTheSameId() {
    String expectedOperation = "parent";
    JaegerSpan client = tracer.buildSpan(expectedOperation).withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT).start();
    Map<String, String> map = new HashMap<>();
    TextMap carrier = new TextMapAdapter(map);
    tracer.inject(client.context(), Format.Builtin.TEXT_MAP, carrier);
    JaegerSpanContext ctx = tracer.extract(Format.Builtin.TEXT_MAP, carrier);
    JaegerSpanContext clientCtx = client.context();
    assertEquals(clientCtx.getSpanId(), ctx.getSpanId());
    JaegerSpan server = tracer.buildSpan("child").withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER).asChildOf(ctx).start();
    JaegerSpanContext serverCtx = server.context();
    assertEquals("client and server must have the same span ID", clientCtx.getSpanId(), serverCtx.getSpanId());
}
Also used : HashMap(java.util.HashMap) JaegerSpan(io.jaegertracing.internal.JaegerSpan) TextMap(io.opentracing.propagation.TextMap) TextMapAdapter(io.opentracing.propagation.TextMapAdapter) JaegerSpanContext(io.jaegertracing.internal.JaegerSpanContext) Test(org.junit.Test)

Example 25 with TextMap

use of io.opentracing.propagation.TextMap in project jaeger-client-java by jaegertracing.

the class JaegerTracerTest method testRegisterInjector.

@Test
public void testRegisterInjector() {
    @SuppressWarnings("unchecked") Injector<TextMap> injector = mock(Injector.class);
    JaegerTracer tracer = new JaegerTracer.Builder("TracerTestService").withReporter(new InMemoryReporter()).withSampler(new ConstSampler(true)).withMetrics(new Metrics(new InMemoryMetricsFactory())).registerInjector(Format.Builtin.TEXT_MAP, injector).build();
    JaegerSpan span = tracer.buildSpan("leela").start();
    TextMap carrier = mock(TextMap.class);
    tracer.inject(span.context(), Format.Builtin.TEXT_MAP, carrier);
    verify(injector).inject(any(JaegerSpanContext.class), any(TextMap.class));
}
Also used : InMemoryReporter(io.jaegertracing.internal.reporters.InMemoryReporter) Metrics(io.jaegertracing.internal.metrics.Metrics) InMemoryMetricsFactory(io.jaegertracing.internal.metrics.InMemoryMetricsFactory) Builder(io.jaegertracing.internal.JaegerTracer.Builder) ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) TextMap(io.opentracing.propagation.TextMap) Test(org.junit.Test)

Aggregations

TextMap (io.opentracing.propagation.TextMap)29 Test (org.junit.Test)16 HashMap (java.util.HashMap)14 Map (java.util.Map)7 SpanContext (com.uber.jaeger.SpanContext)6 JaegerSpanContext (io.jaegertracing.internal.JaegerSpanContext)6 ConstSampler (com.uber.jaeger.samplers.ConstSampler)3 Format (io.opentracing.propagation.Format)3 TextMapAdapter (io.opentracing.propagation.TextMapAdapter)3 SpanId (com.github.kristofa.brave.SpanId)2 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)2 Metrics (com.uber.jaeger.metrics.Metrics)2 InMemoryReporter (com.uber.jaeger.reporters.InMemoryReporter)2 RequestTraceSpanContext (fish.payara.notification.requesttracing.RequestTraceSpanContext)2 JaegerSpan (io.jaegertracing.internal.JaegerSpan)2 TextMapExtractAdapter (io.opentracing.propagation.TextMapExtractAdapter)2 MultiMap (io.vertx.core.MultiMap)2 ByteBuffer (java.nio.ByteBuffer)2 Iterator (java.util.Iterator)2 Entry (java.util.Map.Entry)2