com.github.strengthened.prometheus.healthchecks.HealthCheck Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of prometheus-healthchecks Show documentation
Show all versions of prometheus-healthchecks Show documentation
Metrics collector for Healthcheck system.
The newest version!
package com.github.strengthened.prometheus.healthchecks;
/**
* A health check for a component of your application.
*/
public abstract class HealthCheck {
/**
* Perform a check of the application component.
*
* @return if the component is healthy, a healthy {@link HealthStatus}; otherwise, an unhealthy
* {@link HealthStatus} with a descriptive error message or exception
* @throws Exception if there is an unhandled error during the health check; this will result in a
* failed health check
*/
protected abstract HealthStatus check() throws Exception;
/**
* Executes the health check, catching and handling any exceptions raised by {@link #check()}.
*
* @return if the component is healthy, a healthy {@link HealthStatus}; otherwise, an unhealthy
* {@link HealthStatus} with a descriptive error message or exception
*/
public HealthStatus execute() {
try {
return check();
} catch (Exception ignored) {
return HealthStatus.UNHEALTHY;
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy