use of io.jaegertracing.internal.JaegerSpanContext in project jaeger-client-java by jaegertracing.
the class TraceContextCodecTest method testEmptyTraceStateNotPropagated.
@Test
public void testEmptyTraceStateNotPropagated() {
Map<String, String> extractCarrier = new HashMap<>();
TextMapAdapter textMap = new TextMapAdapter(extractCarrier);
textMap.put(TRACE_PARENT, EXAMPLE_TRACE_PARENT);
textMap.put(TRACE_STATE, "");
JaegerSpanContext spanContext = traceContextCodec.extract(textMap);
Map<String, String> injectCarrier = new HashMap<>();
traceContextCodec.inject(spanContext, new TextMapAdapter(injectCarrier));
assertEquals(1, injectCarrier.size());
assertEquals(EXAMPLE_TRACE_PARENT, injectCarrier.get(TRACE_PARENT));
}
use of io.jaegertracing.internal.JaegerSpanContext in project jaeger-client-java by jaegertracing.
the class TraceContextCodecTest method testDebugIdWithoutTraceHeader.
@Test
public void testDebugIdWithoutTraceHeader() {
Map<String, String> extractCarrier = new HashMap<>();
TextMapAdapter textMap = new TextMapAdapter(extractCarrier);
textMap.put(Constants.DEBUG_ID_HEADER_KEY, EXAMPLE_DEBUG_ID);
JaegerSpanContext spanContext = traceContextCodec.extract(textMap);
JaegerTracer tracer = new JaegerTracer.Builder("service").withReporter(new InMemoryReporter()).build();
JaegerSpan child = tracer.buildSpan("span").asChildOf(spanContext).start();
assertTrue(child.context().isDebug());
child.finish();
tracer.close();
}
use of io.jaegertracing.internal.JaegerSpanContext in project jaeger-client-java by jaegertracing.
the class TraceBehavior method observeSpan.
private ObservedSpan observeSpan() {
JaegerSpan span = (JaegerSpan) tracer.activeSpan();
if (tracer.activeSpan() == null) {
log.error("No span found");
return new ObservedSpan("no span found", false, "no span found");
}
JaegerSpanContext context = span.context();
String traceId = context.getTraceId();
boolean sampled = context.isSampled();
String baggage = span.getBaggageItem(Constants.BAGGAGE_KEY);
return new ObservedSpan(traceId, sampled, baggage);
}
use of io.jaegertracing.internal.JaegerSpanContext in project jaeger-client-java by jaegertracing.
the class B3TextMapCodecTest method testChangeBaggagePrefix.
@Test
public void testChangeBaggagePrefix() {
B3TextMapCodec b3Codec = new B3TextMapCodec.Builder().withBaggagePrefix("foo").build();
DelegatingTextMap entries = new DelegatingTextMap();
long traceIdLow = 1;
long spanId = 2;
long parentId = 3;
JaegerSpanContext spanContext = new JaegerSpanContext(0L, traceIdLow, spanId, parentId, (byte) 0).withBaggageItem("foo", "bar");
b3Codec.inject(spanContext, entries);
assertEquals(5, entries.delegate.size());
assertEquals("bar", entries.delegate.get("foofoo"));
}
use of io.jaegertracing.internal.JaegerSpanContext in project jaeger-client-java by jaegertracing.
the class TextMapCodecTest method testExtractSupportEncodedSpanContext.
@Test
public void testExtractSupportEncodedSpanContext() {
Map<String, String> headers = new HashMap<>();
headers.put("uber-trace-id", "2a%3A1%3A0%3A1");
TextMapCodec codec = new TextMapCodec(true);
JaegerSpanContext context = codec.extract(new TextMapAdapter(headers));
assertEquals(42, context.getTraceIdLow());
assertEquals(0L, context.getTraceIdHigh());
assertEquals(1L, context.getSpanId());
assertTrue(context.isSampled());
}
Aggregations