use of brave.opentracing.BraveSpanContext in project spring-cloud-sleuth by spring-cloud.
the class BraveTracerTest method extractTraceContextTextMap.
@Test
public void extractTraceContextTextMap() throws Exception {
Map<String, String> map = new LinkedHashMap<>();
map.put("X-B3-TraceId", "0000000000000001");
map.put("X-B3-SpanId", "0000000000000002");
map.put("X-B3-Sampled", "1");
BraveSpanContext openTracingContext = (BraveSpanContext) opentracing.extract(Format.Builtin.TEXT_MAP, new TextMapExtractAdapter(map));
assertThat(openTracingContext.unwrap()).isEqualTo(TraceContext.newBuilder().traceId(1L).spanId(2L).sampled(true).build());
}
use of brave.opentracing.BraveSpanContext in project spring-cloud-sleuth by spring-cloud.
the class BraveTracerTest method extractTraceContext.
@Test
public void extractTraceContext() throws Exception {
Map<String, String> map = new LinkedHashMap<>();
map.put("X-B3-TraceId", "0000000000000001");
map.put("X-B3-SpanId", "0000000000000002");
map.put("X-B3-Sampled", "1");
BraveSpanContext openTracingContext = (BraveSpanContext) opentracing.extract(Format.Builtin.HTTP_HEADERS, new TextMapExtractAdapter(map));
assertThat(openTracingContext.unwrap()).isEqualTo(TraceContext.newBuilder().traceId(1L).spanId(2L).sampled(true).build());
}
use of brave.opentracing.BraveSpanContext in project spring-cloud-sleuth by spring-cloud.
the class BraveTracerTest method extractBaggage.
@Test
public void extractBaggage() throws Exception {
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("baggage-country-code", "FO");
BraveSpanContext openTracingContext = opentracing.extract(Format.Builtin.HTTP_HEADERS, new TextMapExtractAdapter(map));
assertThat(openTracingContext.baggageItems()).containsExactly(entry("country-code", "FO"));
}
use of brave.opentracing.BraveSpanContext in project spring-cloud-sleuth by spring-cloud.
the class BraveTracerTest method extractTraceContextCaseInsensitive.
@Test
public void extractTraceContextCaseInsensitive() throws Exception {
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("other", "1");
BraveSpanContext openTracingContext = (BraveSpanContext) opentracing.extract(Format.Builtin.HTTP_HEADERS, new TextMapExtractAdapter(map));
assertThat(openTracingContext.unwrap()).isEqualTo(TraceContext.newBuilder().traceId(1L).spanId(2L).sampled(true).build());
}
Aggregations