use of io.opentracing.propagation.TextMapExtractAdapter 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 io.opentracing.propagation.TextMapExtractAdapter 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 io.opentracing.propagation.TextMapExtractAdapter 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 io.opentracing.propagation.TextMapExtractAdapter 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());
}
use of io.opentracing.propagation.TextMapExtractAdapter 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