Package io.micrometer.core.instrument
Class HttpServerTimingInstrumentationVerificationTests
java.lang.Object
io.micrometer.core.instrument.HttpServerTimingInstrumentationVerificationTests
@Incubating(since="1.8.9")
@ExtendWith(io.micrometer.core.instrument.InstrumentationVerificationTests.AfterBeforeParameterResolver.class)
public abstract class HttpServerTimingInstrumentationVerificationTests
extends Object
Verify the instrumentation of an HTTP server has the minimum expected results. See
startInstrumentedWithMetricsServer() for the required specification the
instrumented HTTP server must handle.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classClass containing constants that can be used for implementing the HTTP routes that the instrumented server needs to serve to pass theHttpServerTimingInstrumentationVerificationTests. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected io.micrometer.observation.tck.TestObservationRegistryHelper method for creating aTestObservationRegistryto run the tests also using the Observation API.protected io.micrometer.observation.tck.TestObservationRegistryprotected io.micrometer.core.instrument.MeterRegistryMeterRegistryto use for instrumentation verification tests.protected io.micrometer.observation.docs.ObservationDocumentationIf aObservationDocumentationis provided the tests run will check that the produced instrumentation matches the givenObservationDocumentation.protected abstract URIStart the instrumented HTTP server to be tested.protected abstract URIStart the instrumented HTTP server to be tested.protected abstract voidStop the instrumented server that was started withstartInstrumentedWithMetricsServer().protected StringA default is provided that should be preferred by new instrumentations.
-
Constructor Details
-
HttpServerTimingInstrumentationVerificationTests
public HttpServerTimingInstrumentationVerificationTests()
-
-
Method Details
-
timerName
A default is provided that should be preferred by new instrumentations. Existing instrumentations that use a different value to maintain backwards compatibility may override this method to run tests with a different name used in assertions.- Returns:
- name of the Timer meter produced from the timing instrumentation under test
-
startInstrumentedWithMetricsServer
Start the instrumented HTTP server to be tested. The server will be instrumented using theMeterRegistryonly. No request body or query parameters will be sent, and any response body will be ignored. The server MUST serve the routes described byHttpServerTimingInstrumentationVerificationTests.InstrumentedRoutes. Constants are available in that class for the routes that will have requests sent to them as part of the TCK. The server MUST NOT have a route for the following:GET /notFound(returns 404 response)
- Returns:
- base URI where the instrumented server is receiving requests. Must end with a slash (/).
- Throws:
Exception- See Also:
-
startInstrumentedWithObservationsServer
Start the instrumented HTTP server to be tested. The server will be instrumented using theObservationRegistry. No request body or query parameters will be sent, and any response body will be ignored. The server MUST serve the routes described byHttpServerTimingInstrumentationVerificationTests.InstrumentedRoutes. Constants are available in that class for the routes that will have requests sent to them as part of the TCK. The server MUST NOT have a route for the following:GET /notFound(returns 404 response)
- Returns:
- base URI where the instrumented server is receiving requests. Must end with
a slash (/) or
nullif you don't support observations - Throws:
Exception- See Also:
-
stopInstrumentedServer
Stop the instrumented server that was started withstartInstrumentedWithMetricsServer().- Throws:
Exception
-
createObservationRegistryWithMetrics
protected io.micrometer.observation.tck.TestObservationRegistry createObservationRegistryWithMetrics()Helper method for creating aTestObservationRegistryto run the tests also using the Observation API.- Returns:
- a
TestObservationRegistrywith aDefaultMeterObservationHandlerregistered
-
observationDocumentation
@Nullable protected io.micrometer.observation.docs.ObservationDocumentation observationDocumentation()If aObservationDocumentationis provided the tests run will check that the produced instrumentation matches the givenObservationDocumentation.- Returns:
- the documented observation to compare results against, or null to do nothing
-
getRegistry
protected io.micrometer.core.instrument.MeterRegistry getRegistry()MeterRegistryto use for instrumentation verification tests.- Returns:
- registry to use
-
getObservationRegistry
protected io.micrometer.observation.tck.TestObservationRegistry getObservationRegistry()
-