Package zipkin2.junit5
Class ZipkinExtension
java.lang.Object
zipkin2.junit5.ZipkinExtension
- All Implemented Interfaces:
org.junit.jupiter.api.extension.AfterEachCallback
,org.junit.jupiter.api.extension.BeforeEachCallback
,org.junit.jupiter.api.extension.Extension
public final class ZipkinExtension
extends Object
implements org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.AfterEachCallback
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
afterEach
(org.junit.jupiter.api.extension.ExtensionContext extensionContext) void
beforeEach
(org.junit.jupiter.api.extension.ExtensionContext extensionContext) Use this to see how many spans or serialized bytes were collected on the http endpoint.enqueueFailure
(HttpFailure failure) Adds a one-time failure to the http endpoint.Retrieves all service links between traces this zipkin server has received.Retrieves a trace by ID which Zipkin server has received, or null if not present.Retrieves all traces this zipkin server has received.int
Use this to see how many requests you've sent to any zipkin http endpoint.httpUrl()
Use this to connect.void
shutdown()
Used to manually stop the server.void
start
(int httpPort) Used to manually start the server.storeSpans
(List<Span> spans) Stores the given spans directly, to setup preconditions for a test.
-
Constructor Details
-
ZipkinExtension
public ZipkinExtension()
-
-
Method Details
-
httpUrl
Use this to connect. The zipkin v1 interface will be under "/api/v1" -
httpRequestCount
public int httpRequestCount()Use this to see how many requests you've sent to any zipkin http endpoint. -
collectorMetrics
Use this to see how many spans or serialized bytes were collected on the http endpoint. -
storeSpans
Stores 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.
-
enqueueFailure
Adds 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
-
getTraces
Retrieves all traces this zipkin server has received. -
getTrace
Retrieves a trace by ID which Zipkin server has received, or null if not present. -
getDependencies
Retrieves all service links between traces this zipkin server has received. -
start
Used to manually start the server.- Parameters:
httpPort
- choose 0 to select an available port- Throws:
IOException
-
shutdown
Used to manually stop the server.- Throws:
IOException
-
beforeEach
public void beforeEach(org.junit.jupiter.api.extension.ExtensionContext extensionContext) - Specified by:
beforeEach
in interfaceorg.junit.jupiter.api.extension.BeforeEachCallback
-
afterEach
public void afterEach(org.junit.jupiter.api.extension.ExtensionContext extensionContext) - Specified by:
afterEach
in interfaceorg.junit.jupiter.api.extension.AfterEachCallback
-