Created
November 9, 2023 15:59
-
-
Save motlin/bd74215ad4db51b588d7daceaf58126c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void registerHealthChecks(@Nonnull Environment environment) | |
{ | |
super.registerHealthChecks(environment); | |
environment.healthChecks().register("healthy", new HealthCheck() | |
{ | |
@Override | |
protected Result check() | |
{ | |
return Result.healthy(); | |
} | |
}); | |
environment.healthChecks().register("unhealthy", new HealthCheck() | |
{ | |
@Override | |
protected Result check() | |
{ | |
return Result.unhealthy("I am unhealthy"); | |
} | |
}); | |
environment.healthChecks().register("throwing", new HealthCheck() | |
{ | |
@Override | |
protected Result check() | |
{ | |
throw new RuntimeException("I am unhealthy"); | |
} | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"deadlocks": { | |
"healthy": true, | |
"duration": 10, | |
"timestamp": "2023-11-09T10:50:37.643-05:00" | |
}, | |
"healthy": { | |
"healthy": true, | |
"duration": 0, | |
"timestamp": "2023-11-09T10:50:37.631-05:00" | |
}, | |
"unhealthy": { | |
"healthy": false, | |
"message": "I am unhealthy", | |
"duration": 0, | |
"timestamp": "2023-11-09T10:50:37.631-05:00" | |
}, | |
"throwing": { | |
"healthy": false, | |
"message": "I am unhealthy", | |
"error": { | |
"type": "java.lang.RuntimeException", | |
"message": "I am unhealthy", | |
"stack": [ | |
"Application$3.check(Application.java:123)", | |
"com.codahale.metrics.health.HealthCheck.execute(HealthCheck.java:374)", | |
"com.codahale.metrics.health.HealthCheckRegistry.runHealthChecks(HealthCheckRegistry.java:184)", | |
"com.codahale.metrics.servlets.HealthCheckServlet.runHealthChecks(HealthCheckServlet.java:177)", | |
"com.codahale.metrics.servlets.HealthCheckServlet.doGet(HealthCheckServlet.java:146)", | |
"javax.servlet.http.HttpServlet.service(HttpServlet.java:687)", | |
"javax.servlet.http.HttpServlet.service(HttpServlet.java:790)", | |
"com.codahale.metrics.servlets.AdminServlet.service(AdminServlet.java:153)", | |
"javax.servlet.http.HttpServlet.service(HttpServlet.java:790)", | |
"org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:799)", | |
"org.eclipse.jetty.servlet.ServletHandler$ChainEnd.doFilter(ServletHandler.java:1656)", | |
"io.dropwizard.jersey.filter.AllowedMethodsFilter.handle(AllowedMethodsFilter.java:47)", | |
"io.dropwizard.jersey.filter.AllowedMethodsFilter.doFilter(AllowedMethodsFilter.java:41)", | |
"org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193)", | |
"org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1626)", | |
"org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:552)", | |
"org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)", | |
"org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:560)", | |
"org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)", | |
"org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235)", | |
"org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1440)", | |
"org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)", | |
"org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:505)", | |
"org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)", | |
"org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1355)", | |
"org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)", | |
"io.dropwizard.jetty.RoutingHandler.handle(RoutingHandler.java:52)", | |
"org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:772)", | |
"io.dropwizard.jetty.ZipExceptionHandlingGzipHandler.handle(ZipExceptionHandlingGzipHandler.java:26)", | |
"org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:54)", | |
"org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:181)", | |
"org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)", | |
"org.eclipse.jetty.server.Server.handle(Server.java:516)", | |
"org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:487)", | |
"org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:732)", | |
"org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:479)", | |
"org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277)", | |
"org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)", | |
"org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)", | |
"org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)", | |
"org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:338)", | |
"org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:315)", | |
"org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:173)", | |
"org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131)", | |
"org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:409)", | |
"org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883)", | |
"org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034)", | |
"java.base/java.lang.Thread.run(Thread.java:1583)" | |
] | |
}, | |
"duration": 0, | |
"timestamp": "2023-11-09T10:50:37.631-05:00" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
❯ curl -I -H "Accept: application/json" http://localhost:8081/healthcheck\?pretty\=true | |
HTTP/1.1 500 Server Error | |
Date: Thu, 09 Nov 2023 15:52:45 GMT | |
Content-Type: application/json | |
Cache-Control: must-revalidate,no-cache,no-store | |
Content-Length: 4804 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment