Package brave.test
Class IntegrationTestSpanHandler
- java.lang.Object
- 
- brave.handler.SpanHandler
- 
- brave.test.IntegrationTestSpanHandler
 
 
- 
- All Implemented Interfaces:
- org.junit.rules.TestRule
 
 public final class IntegrationTestSpanHandler extends SpanHandler implements org.junit.rules.TestRule This is a special span reporter for remote integration tests.Ex. The following is similar to our base test class ITRemote:{@code- Since:
- 5.12
- See Also:
- TestSpanHandler
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from class brave.handler.SpanHandlerSpanHandler.Cause
 
- 
 - 
Field Summary- 
Fields inherited from class brave.handler.SpanHandlerNOOP
 
- 
 - 
Constructor SummaryConstructors Constructor Description IntegrationTestSpanHandler()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description org.junit.runners.model.Statementapply(org.junit.runners.model.Statement base, org.junit.runner.Description description)booleanbegin(TraceContext context, MutableSpan span, TraceContext parent)booleanend(TraceContext context, MutableSpan span, SpanHandler.Cause cause)booleanhandlesAbandoned()voidignoreAnySpans()Call this before throwing anAssumptionViolatedException, when there's a chance a span was finished.MutableSpantakeLocalSpan()Blocks until a local span was finished.MutableSpantakeRemoteSpan(Span.Kind kind)Blocks until a remote span was finished.MutableSpantakeRemoteSpanWithError(Span.Kind kind)Some frameworks swallow exceptions.MutableSpantakeRemoteSpanWithError(Span.Kind kind, Throwable error)LiketakeRemoteSpan(Kind)except aMutableSpan.error()must equal the given value.MutableSpantakeRemoteSpanWithErrorMessage(Span.Kind kind, String errorMessage)Use instead oftakeRemoteSpanWithError(Kind, Throwable)when you cannot catch a reference to the actual raised exception during a test.MutableSpantakeRemoteSpanWithErrorTag(Span.Kind kind, String errorTag)LiketakeRemoteSpan(Kind)except an error tag must match the given value.StringtoString()
 
- 
- 
- 
Method Detail- 
ignoreAnySpanspublic void ignoreAnySpans() Call this before throwing anAssumptionViolatedException, when there's a chance a span was finished.This was made for detecting features in HTTP server testing via 404. When 404 itself is instrumented, post-conditions would otherwise fail from not consuming the associated span. 
 - 
takeLocalSpanpublic MutableSpan takeLocalSpan() Blocks until a local span was finished. This does not verify errors.
 - 
takeRemoteSpanpublic MutableSpan takeRemoteSpan(Span.Kind kind) Blocks until a remote span was finished. We define a remote span as one with a timestamp, duration and kind.This will fail if there's an MutableSpan.error()or an "error" tag. If you expect a failure, usetakeRemoteSpanWithError(Kind, Throwable)ortakeRemoteSpanWithErrorTag(Kind, String)instead.
 - 
takeRemoteSpanWithErrorpublic MutableSpan takeRemoteSpanWithError(Span.Kind kind, Throwable error) LiketakeRemoteSpan(Kind)except aMutableSpan.error()must equal the given value.Note: This enforces there is no "error" tag. If your framework clarifies the "error" tag when there is also an unhandled exception, use takeRemoteSpanWithErrorTag(Kind, String)first, then check for error using normal assertions.
 - 
takeRemoteSpanWithErrorpublic MutableSpan takeRemoteSpanWithError(Span.Kind kind) Some frameworks swallow exceptions. This tests that either an "error" tag exists orMutableSpan.error()does, without regards to the value.
 - 
takeRemoteSpanWithErrorMessagepublic MutableSpan takeRemoteSpanWithErrorMessage(Span.Kind kind, String errorMessage) Use instead oftakeRemoteSpanWithError(Kind, Throwable)when you cannot catch a reference to the actual raised exception during a test.This is typically used when testing framework errors result in a finished span. 
 - 
takeRemoteSpanWithErrorTagpublic MutableSpan takeRemoteSpanWithErrorTag(Span.Kind kind, String errorTag) LiketakeRemoteSpan(Kind)except an error tag must match the given value.
 - 
beginpublic boolean begin(TraceContext context, MutableSpan span, @Nullable TraceContext parent) - Overrides:
- beginin class- SpanHandler
 
 - 
handlesAbandonedpublic boolean handlesAbandoned() - Overrides:
- handlesAbandonedin class- SpanHandler
 
 - 
endpublic boolean end(TraceContext context, MutableSpan span, SpanHandler.Cause cause) - Overrides:
- endin class- SpanHandler
 
 - 
applypublic org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)- Specified by:
- applyin interface- org.junit.rules.TestRule
 
 
- 
 
-