Search in sources :

Example 1 with ObservedSpan

use of io.jaegertracing.crossdock.api.ObservedSpan 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);
}
Also used : ObservedSpan(io.jaegertracing.crossdock.api.ObservedSpan) JaegerSpan(io.jaegertracing.internal.JaegerSpan) JaegerSpanContext(io.jaegertracing.internal.JaegerSpanContext)

Example 2 with ObservedSpan

use of io.jaegertracing.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);
    }
}
Also used : ObservedSpan(io.jaegertracing.crossdock.api.ObservedSpan) TraceResponse(io.jaegertracing.crossdock.api.TraceResponse)

Aggregations

ObservedSpan (io.jaegertracing.crossdock.api.ObservedSpan)2 TraceResponse (io.jaegertracing.crossdock.api.TraceResponse)1 JaegerSpan (io.jaegertracing.internal.JaegerSpan)1 JaegerSpanContext (io.jaegertracing.internal.JaegerSpanContext)1