Search in sources :

Example 26 with TextMapAdapter

use of io.opentracing.propagation.TextMapAdapter in project brave by openzipkin.

the class OpenTracingAdapterTest method extractTraceContext.

@Test
public void extractTraceContext() {
    Map<String, String> map = new LinkedHashMap<>();
    map.put("X-B3-TraceId", "0000000000000001");
    map.put("X-B3-SpanId", "0000000000000002");
    map.put("X-B3-Sampled", "1");
    map.put("User-Id", "sammy");
    BraveSpanContext openTracingContext = opentracing.extract(Format.Builtin.HTTP_HEADERS, new TextMapAdapter(map));
    assertThat(openTracingContext.context).isEqualTo(TraceContext.newBuilder().traceId(1L).spanId(2L).sampled(true).build());
    assertThat(openTracingContext.baggageItems()).containsExactly(entry(BAGGAGE_FIELD.name(), "sammy"));
}
Also used : TextMapAdapter(io.opentracing.propagation.TextMapAdapter) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Aggregations

TextMapAdapter (io.opentracing.propagation.TextMapAdapter)26 Test (org.junit.Test)23 JaegerSpanContext (io.jaegertracing.internal.JaegerSpanContext)19 HashMap (java.util.HashMap)16 JaegerSpan (io.jaegertracing.internal.JaegerSpan)4 TextMap (io.opentracing.propagation.TextMap)3 LinkedHashMap (java.util.LinkedHashMap)3 JaegerTracer (io.jaegertracing.internal.JaegerTracer)2 InMemoryReporter (io.jaegertracing.internal.reporters.InMemoryReporter)2 Span (io.opentracing.Span)2 TraceContext (brave.propagation.TraceContext)1 Scope (io.opentracing.Scope)1 SpanContext (io.opentracing.SpanContext)1 Map (java.util.Map)1