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.
  • Constructor Details

    • HttpServerTimingInstrumentationVerificationTests

      public HttpServerTimingInstrumentationVerificationTests()
  • Method Details

    • timerName

      protected String 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

      protected abstract URI startInstrumentedWithMetricsServer() throws Exception
      Start the instrumented HTTP server to be tested. The server will be instrumented using the MeterRegistry only. No request body or query parameters will be sent, and any response body will be ignored. The server MUST serve the routes described by HttpServerTimingInstrumentationVerificationTests.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

      @Nullable protected abstract URI startInstrumentedWithObservationsServer() throws Exception
      Start the instrumented HTTP server to be tested. The server will be instrumented using the ObservationRegistry. No request body or query parameters will be sent, and any response body will be ignored. The server MUST serve the routes described by HttpServerTimingInstrumentationVerificationTests.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 null if you don't support observations
      Throws:
      Exception
      See Also:
    • stopInstrumentedServer

      protected abstract void stopInstrumentedServer() throws Exception
      Stop the instrumented server that was started with startInstrumentedWithMetricsServer().
      Throws:
      Exception
    • createObservationRegistryWithMetrics

      protected io.micrometer.observation.tck.TestObservationRegistry createObservationRegistryWithMetrics()
      Helper method for creating a TestObservationRegistry to run the tests also using the Observation API.
      Returns:
      a TestObservationRegistry with a DefaultMeterObservationHandler registered
    • observationDocumentation

      @Nullable protected io.micrometer.observation.docs.ObservationDocumentation observationDocumentation()
      If a ObservationDocumentation is provided the tests run will check that the produced instrumentation matches the given ObservationDocumentation.
      Returns:
      the documented observation to compare results against, or null to do nothing
    • getRegistry

      protected io.micrometer.core.instrument.MeterRegistry getRegistry()
      MeterRegistry to use for instrumentation verification tests.
      Returns:
      registry to use
    • getObservationRegistry

      protected io.micrometer.observation.tck.TestObservationRegistry getObservationRegistry()