use of brave.handler.MutableSpan in project brave by openzipkin.
the class IntegrationTestSpanHandler method takeRemoteSpanWithErrorMessage.
/**
* Use instead of {@link #takeRemoteSpanWithError(Kind, Throwable)} when you cannot catch a
* reference to the actual raised exception during a test.
*
* <p>This is typically used when testing framework errors result in a finished span.
*
* @see #takeRemoteSpanWithError(Kind, Throwable)
* @see #takeRemoteSpanWithError(Kind)
* @see #takeRemoteSpanWithErrorTag(Kind, String)
*/
public MutableSpan takeRemoteSpanWithErrorMessage(Kind kind, String errorMessage) {
MutableSpan result = doTakeSpan(null, errorMessage, null, false);
assertRemoteSpan(result, kind);
return result;
}
use of brave.handler.MutableSpan in project brave by openzipkin.
the class IntegrationTestSpanHandler method assertSpansConsumed.
/**
* On close, we check that all spans have been verified by the test. This ensures bad behavior
* such as duplicate reporting doesn't occur. The impact is that every span must at least be
* {@link #doTakeSpan(Throwable, String, String, boolean)} before the end of each method.
*/
// only check success path to avoid masking assertion errors or exceptions
void assertSpansConsumed() {
if (ignoreAnySpans)
return;
try {
MutableSpan span = spans.poll(100, TimeUnit.MILLISECONDS);
assertThat(span).withFailMessage("Span remaining in queue. Check for redundant reporting: %s", span).isNull();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new AssertionError(e);
}
}
use of brave.handler.MutableSpan in project brave by openzipkin.
the class IntegrationTestSpanHandler method takeRemoteSpanWithErrorTag.
/**
* Like {@link #takeRemoteSpan(Kind)} except an error tag must match the given value.
*
* @see #takeRemoteSpanWithError(Kind, Throwable)
* @see #takeRemoteSpanWithError(Kind)
* @see #takeRemoteSpanWithErrorMessage(Kind, String)
*/
public MutableSpan takeRemoteSpanWithErrorTag(Kind kind, String errorTag) {
MutableSpan result = doTakeSpan(null, null, errorTag, false);
assertRemoteSpan(result, kind);
return result;
}
use of brave.handler.MutableSpan in project brave by openzipkin.
the class IntegrationTestSpanHandler method takeRemoteSpan.
/**
* Blocks until a remote span was finished. We define a remote span as one with a timestamp,
* duration and kind.
*
* <p>This will fail if there's an {@link MutableSpan#error()} or an "error" tag. If you expect a
* failure, use {@link #takeRemoteSpanWithError(Kind, Throwable)} or {@link
* #takeRemoteSpanWithErrorTag(Kind, String)} instead.
*/
public MutableSpan takeRemoteSpan(Kind kind) {
MutableSpan result = doTakeSpan(null, null, null, false);
assertRemoteSpan(result, kind);
return result;
}
use of brave.handler.MutableSpan in project brave by openzipkin.
the class IntegrationTestSpanHandler method takeRemoteSpanWithError.
/**
* Some frameworks swallow exceptions. This tests that either an "error" tag exists or {@link
* MutableSpan#error()} does, without regards to the value.
*
* @see #takeRemoteSpanWithError(Kind, Throwable)
* @see #takeRemoteSpanWithErrorMessage(Kind, String)
* @see #takeRemoteSpanWithErrorTag(Kind, String)
*/
public MutableSpan takeRemoteSpanWithError(Kind kind) {
MutableSpan result = doTakeSpan(null, null, ANY_STRING, false);
assertRemoteSpan(result, kind);
return result;
}
Aggregations