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);
}
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;
}
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());
}
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());
}
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));
}
Aggregations