use of com.uber.jaeger.crossdock.api.ObservedSpan 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.crossdock.api.ObservedSpan in project jaeger-client-java by jaegertracing.
the class TraceBehaviorResourceTest method validateTraceResponse.
private void validateTraceResponse(TraceResponse response, String expectedTraceId, String expectedBaggage, int expectedDownstream) {
ObservedSpan span = response.getSpan();
assertEquals(expectedTraceId, span.getTraceId());
assertEquals(expectedBaggage, span.getBaggage());
assertEquals(expectedSampled, span.isSampled());
TraceResponse downstream = response.getDownstream();
if (expectedDownstream > 0) {
assertNotNull(downstream);
validateTraceResponse(downstream, expectedTraceId, expectedBaggage, expectedDownstream - 1);
} else {
assertNull(downstream);
}
}
Aggregations