use of com.uber.jaeger.SpanContext in project jaeger-client-java by jaegertracing.
the class TraceBehavior method observeSpan.
private ObservedSpan observeSpan() {
com.uber.jaeger.context.TraceContext traceContext = TracingUtils.getTraceContext();
if (traceContext.isEmpty()) {
log.error("No span found");
return new ObservedSpan("no span found", false, "no span found");
}
Span span = (Span) traceContext.getCurrentSpan();
if (span == null) {
log.error("No span found");
return new ObservedSpan("no span found", false, "no span found");
}
SpanContext context = span.context();
String traceId = String.format("%x", context.getTraceId());
boolean sampled = context.isSampled();
String baggage = span.getBaggageItem(Constants.BAGGAGE_KEY);
return new ObservedSpan(traceId, sampled, baggage);
}
use of com.uber.jaeger.SpanContext in project jaeger-client-java by jaegertracing.
the class B3TextMapCodecTest method testInject_rootSpan.
@Test
public void testInject_rootSpan() throws Exception {
DelegatingTextMap textMap = new DelegatingTextMap();
b3Codec.inject(new SpanContext(1, 1, 0, SAMPLED), textMap);
TraceData data = takeRequestFromTextMap(textMap);
assertEquals(1, data.getSpanId().traceId);
assertEquals(null, data.getSpanId().nullableParentId());
assertEquals(1, data.getSpanId().spanId);
assertEquals(Boolean.TRUE, data.getSample());
}
use of com.uber.jaeger.SpanContext in project jaeger-client-java by jaegertracing.
the class B3TextMapCodecTest method testInject_childSpan.
@Test
public void testInject_childSpan() throws Exception {
DelegatingTextMap textMap = new DelegatingTextMap();
b3Codec.inject(new SpanContext(1, 2, 1, SAMPLED), textMap);
TraceData data = takeRequestFromTextMap(textMap);
assertEquals(1, data.getSpanId().traceId);
assertEquals(Long.valueOf(1), data.getSpanId().nullableParentId());
assertEquals(2, data.getSpanId().spanId);
assertEquals(Boolean.TRUE, data.getSample());
}
use of com.uber.jaeger.SpanContext in project jaeger-client-java by jaegertracing.
the class B3TextMapCodecTest method testExtract_unsampled.
@Test
public void testExtract_unsampled() throws Exception {
TextMap textMap = makeRequestWithSpanId(null);
SpanContext context = b3Codec.extract(textMap);
assertEquals(null, context);
}
Aggregations