Example usage for org.springframework.boot.actuate.health Health.Builder unknown

List of usage examples for org.springframework.boot.actuate.health Health.Builder unknown

Introduction

In this page you can find the example usage for org.springframework.boot.actuate.health Health.Builder unknown.

Prototype

public static Builder unknown() 

Source Link

Document

Create a new Builder instance with an Status#UNKNOWN status.

Usage

From source file:com.netflix.spinnaker.echo.pipelinetriggers.health.MonitoredPollerHealth.java

private void polledRecently(Health.Builder builder) {
    Instant lastPollTimestamp = poller.getLastPollTimestamp();
    if (lastPollTimestamp == null) {
        builder.unknown();
    } else {/*from  ww w  . j  a  v a2s .co m*/
        val timeSinceLastPoll = Duration.between(lastPollTimestamp, now());
        builder.withDetail("last.polled",
                formatDurationWords(timeSinceLastPoll.toMillis(), true, true) + " ago");
        builder.withDetail("last.polled.at",
                ISO_LOCAL_DATE_TIME.format(lastPollTimestamp.atZone(ZoneId.systemDefault())));
        if (timeSinceLastPoll.compareTo(Duration.of(poller.getPollingIntervalSeconds() * 2, SECONDS)) <= 0) {
            builder.up();
        } else {
            builder.down();
        }
    }
}