Package zipkin2.junit
Class ZipkinRule
java.lang.Object
zipkin2.junit.ZipkinRule
- All Implemented Interfaces:
- org.junit.rules.TestRule
public final class ZipkinRule extends Object implements org.junit.rules.TestRule
Starts up a local Zipkin server, listening for http requests on 
httpUrl().
 This can be used to test instrumentation. For example, you can POST spans directly to this server.
See http://openzipkin.github.io/zipkin-api/#/
- 
Constructor SummaryConstructors Constructor Description ZipkinRule()
- 
Method SummaryModifier and Type Method Description org.junit.runners.model.Statementapply(org.junit.runners.model.Statement base, org.junit.runner.Description description)InMemoryCollectorMetricscollectorMetrics()Use this to see how many spans or serialized bytes were collected on the http endpoint.ZipkinRuleenqueueFailure(HttpFailure failure)Adds a one-time failure to the http endpoint.List<DependencyLink>getDependencies()Retrieves all service links between traces this zipkin server has received.List<Span>getTrace(String traceId)Retrieves a trace by ID which zipkin server has received, or null if not present.List<List<Span>>getTraces()Retrieves all traces this zipkin server has received.inthttpRequestCount()Use this to see how many requests you've sent to any zipkin http endpoint.StringhttpUrl()Use this to connect.voidshutdown()Used to manually stop the server.voidstart(int httpPort)Used to manually start the server.ZipkinRulestoreSpans(List<Span> spans)Stores the given spans directly, to setup preconditions for a test.
- 
Constructor Details- 
ZipkinRulepublic ZipkinRule()
 
- 
- 
Method Details- 
httpUrlUse this to connect. The zipkin v1 interface will be under "/api/v1"
- 
httpRequestCountpublic int httpRequestCount()Use this to see how many requests you've sent to any zipkin http endpoint.
- 
collectorMetricsUse this to see how many spans or serialized bytes were collected on the http endpoint.
- 
storeSpansStores the given spans directly, to setup preconditions for a test.For example, if you are testing what happens when instrumentation adds a child to a trace, you'd add the parent here. 
- 
enqueueFailureAdds a one-time failure to the http endpoint.Ex. If you want to test that you don't repeatedly send bad data, you could send a 400 back. zipkin.enqueueFailure(sendErrorResponse(400, "bad format"));- Parameters:
- failure- type of failure the next call to the http endpoint responds with
 
- 
getTracesRetrieves all traces this zipkin server has received.
- 
getTraceRetrieves a trace by ID which zipkin server has received, or null if not present.
- 
getDependenciesRetrieves all service links between traces this zipkin server has received.
- 
startUsed to manually start the server.- Parameters:
- httpPort- choose 0 to select an available port
- Throws:
- IOException
 
- 
shutdownUsed to manually stop the server.- Throws:
- IOException
 
- 
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
 
 
-