use of io.opentracing.propagation.TextMapInjectAdapter in project brave by openzipkin.
the class OpenTracingAdapterTest method injectTraceContext.
@Test
public void injectTraceContext() throws Exception {
TraceContext context = TraceContext.newBuilder().traceId(1L).spanId(2L).sampled(true).build();
Map<String, String> map = new LinkedHashMap<>();
TextMapInjectAdapter carrier = new TextMapInjectAdapter(map);
opentracing.inject(BraveSpanContext.wrap(context), Format.Builtin.HTTP_HEADERS, carrier);
assertThat(map).containsExactly(entry("X-B3-TraceId", "0000000000000001"), entry("X-B3-SpanId", "0000000000000002"), entry("X-B3-Sampled", "1"));
}
use of io.opentracing.propagation.TextMapInjectAdapter in project spring-cloud-sleuth by spring-cloud.
the class BraveTracerTest method injectTraceContext_baggage.
@Test
public void injectTraceContext_baggage() throws Exception {
BraveSpan span = opentracing.buildSpan("foo").start();
span.setBaggageItem("country-code", "FO");
Map<String, String> map = new LinkedHashMap<>();
TextMapInjectAdapter carrier = new TextMapInjectAdapter(map);
opentracing.inject(span.context(), Format.Builtin.HTTP_HEADERS, carrier);
assertThat(map).containsEntry("baggage-country-code", "FO");
}
use of io.opentracing.propagation.TextMapInjectAdapter in project opentracing-java by opentracing.
the class Client method send.
public void send() throws InterruptedException {
Message message = new Message();
try (Scope scope = tracer.buildSpan("send").withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT).withTag(Tags.COMPONENT.getKey(), "example-client").startActive(true)) {
tracer.inject(scope.span().context(), Builtin.TEXT_MAP, new TextMapInjectAdapter(message));
queue.put(message);
}
}
use of io.opentracing.propagation.TextMapInjectAdapter in project opentracing-java by opentracing.
the class MockTracerTest method testDefaultConstructor.
@Test
public void testDefaultConstructor() {
MockTracer mockTracer = new MockTracer();
Scope scope = mockTracer.buildSpan("foo").startActive(true);
assertEquals(scope, mockTracer.scopeManager().active());
Map<String, String> propag = new HashMap<>();
mockTracer.inject(scope.span().context(), Format.Builtin.TEXT_MAP, new TextMapInjectAdapter(propag));
assertFalse(propag.isEmpty());
}
use of io.opentracing.propagation.TextMapInjectAdapter in project jaeger-client-java by jaegertracing.
the class ThriftSpanConverterTest method testRpcChildSpanHasTheSameId.
@Test
public void testRpcChildSpanHasTheSameId() {
String expectedOperation = "parent";
Span client = (Span) tracer.buildSpan(expectedOperation).withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT).startManual();
Map<String, String> map = new HashMap<>();
TextMap carrier = new TextMapInjectAdapter(map);
tracer.inject(client.context(), Format.Builtin.TEXT_MAP, carrier);
carrier = new TextMapExtractAdapter(map);
SpanContext ctx = (SpanContext) tracer.extract(Format.Builtin.TEXT_MAP, carrier);
assertEquals(client.context().getSpanId(), ctx.getSpanId());
Span server = (Span) tracer.buildSpan("child").withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER).asChildOf(ctx).startManual();
assertEquals("client and server must have the same span ID", client.context().getSpanId(), server.context().getSpanId());
}
Aggregations