2

I'm using Wiremock 2.28.1 in a Scala 2.13 project and I would like to skip logging specific requests/responses in Wiremock because they are just liveness/readiness HTTP calls targeting health/ready and health/alive endpoints:

{
  "mappings": [
    {
      "request": {
        "method": "GET",
        "url": "/api/v1/health/ready"
      },
      "response": {
        "status": 200,
        "body": "",
        "headers": {
          "Content-Type": "text/plain"
        }
      }
    },
    {
      "request": {
        "method": "GET",
        "url": "/api/v1/health/alive"
      },
      "response": {
        "status": 200,
        "body": "",
        "headers": {
          "Content-Type": "text/plain"
        }
      }
    }
  ]
}

The WireMock server configuration is:

      new WireMockConfiguration()
        .bindAddress(configOptions.host)
        .port(configOptions.port)
        .stubCorsEnabled(configOptions.enableCors)
        .disableRequestJournal() // avoid JVM heap exhaustion for recorded requests
        .usingFilesUnderClasspath(s"$confBasePath/${configOptions.mappingsFolder}")
        .notifier(new ConsoleNotifier(configOptions.verboseNotifier))  // <-- TRUE
        .httpsPort(...)

Is there a way to tell WireMock to simply skip logging the /health/* API calls?

sentenza
  • 1,608
  • 3
  • 29
  • 51

1 Answers1

2

There are a couple of ways you could do this:

  1. Write your own Notifier implementation that filters messages based on their content and use this in place of ConsoleNotifier in your startup options.

  2. Make the healthcheck an admin API function by implementing AdminApiExtension and registering it in the startup options (this will mean the URL will have to be under /__admin/.

Tom
  • 3,471
  • 21
  • 14
  • Thanks for the reply @Tom. I will try to write my own Notifier implementation to skip all the `/health/*` calls – sentenza Jun 30 '21 at 08:28