Class HealthCheck.Result

java.lang.Object
io.dropwizard.metrics5.health.HealthCheck.Result
Enclosing interface:
HealthCheck

public static class HealthCheck.Result extends Object
The result of a HealthCheck being run. It can be healthy (with an optional message and optional details) or unhealthy (with either an error message or a thrown exception and optional details).
  • Method Details

    • healthy

      public static HealthCheck.Result healthy()
      Returns a healthy HealthCheck.Result with no additional message.
      Returns:
      a healthy HealthCheck.Result with no additional message
    • healthy

      public static HealthCheck.Result healthy(String message)
      Returns a healthy HealthCheck.Result with an additional message.
      Parameters:
      message - an informative message
      Returns:
      a healthy HealthCheck.Result with an additional message
    • healthy

      public static HealthCheck.Result healthy(String message, Object... args)
      Returns a healthy HealthCheck.Result with a formatted message.

      Message formatting follows the same rules as String.format(String, Object...).

      Parameters:
      message - a message format
      args - the arguments apply to the message format
      Returns:
      a healthy HealthCheck.Result with an additional message
      See Also:
    • unhealthy

      public static HealthCheck.Result unhealthy(String message)
      Returns an unhealthy HealthCheck.Result with the given message.
      Parameters:
      message - an informative message describing how the health check failed
      Returns:
      an unhealthy HealthCheck.Result with the given message
    • unhealthy

      public static HealthCheck.Result unhealthy(String message, Object... args)
      Returns an unhealthy HealthCheck.Result with a formatted message.

      Message formatting follows the same rules as String.format(String, Object...).

      Parameters:
      message - a message format
      args - the arguments apply to the message format
      Returns:
      an unhealthy HealthCheck.Result with an additional message
      See Also:
    • unhealthy

      public static HealthCheck.Result unhealthy(Throwable error)
      Returns an unhealthy HealthCheck.Result with the given error.
      Parameters:
      error - an exception thrown during the health check
      Returns:
      an unhealthy HealthCheck.Result with the given error
    • builder

      public static HealthCheck.ResultBuilder builder()
      Returns:
      the HealthCheck.ResultBuilder
    • isHealthy

      public boolean isHealthy()
      Returns true if the result indicates the component is healthy; false otherwise.
      Returns:
      true if the result indicates the component is healthy
    • getMessage

      public String getMessage()
      Returns any additional message for the result, or null if the result has no message.
      Returns:
      any additional message for the result, or null
    • getError

      public Throwable getError()
      Returns any exception for the result, or null if the result has no exception.
      Returns:
      any exception for the result, or null
    • getTimestamp

      public String getTimestamp()
      Returns the timestamp when the result was created as a formatted String.
      Returns:
      a formatted timestamp
    • getTime

      public long getTime()
      Returns the time when the result was created, in milliseconds since Epoch
      Returns:
      the time when the result was created
    • getDuration

      public long getDuration()
      Returns the duration in milliseconds that the healthcheck took to run
      Returns:
      the duration
    • setDuration

      public void setDuration(long duration)
      Sets the duration in milliseconds. This will indicate the time it took to run the individual healthcheck
      Parameters:
      duration - The duration in milliseconds
    • getDetails

      public Map<String,Object> getDetails()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object