Skip to content

Reactive health indicators do not log health check failure #17634

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
superlee007 opened this issue Jul 25, 2019 · 2 comments
Closed

Reactive health indicators do not log health check failure #17634

superlee007 opened this issue Jul 25, 2019 · 2 comments
Labels
status: superseded An issue that has been superseded by another type: bug A general bug

Comments

@superlee007
Copy link

Spring-boot 2.0.6 use lettuce as redis default client, and redis health check in actuator do not log the exception. If my redis host is wrong, the console log does not show exception message.
I can only get the cause by /actuator/health.
Why not log warn the exception in AbstractReactiveHealthIndicator.java in spring-boot-actuator like this:

public abstract class AbstractReactiveHealthIndicator implements ReactiveHealthIndicator {
    private static final String DEFAULT_MESSAGE = "Health check failed";

    private final Log logger = LogFactory.getLog(getClass());

    private final Function<Exception, String> healthCheckFailedMessage;

    protected AbstractReactiveHealthIndicator(String healthCheckFailedMessage) {
	this.healthCheckFailedMessage = (ex) -> healthCheckFailedMessage;
    }
    @Override
    public final Mono<Health> health() {
	try {
	    return doHealthCheck(new Health.Builder()).onErrorResume(this::handleFailure);
	}
	catch (Exception ex) {
            //log the exception
             if (this.logger.isWarnEnabled()) {
		String message = this.healthCheckFailedMessage.apply(ex);
		this.logger.warn(StringUtils.hasText(message) ? message : DEFAULT_MESSAGE, ex);
	    }
	    return handleFailure(ex);
	}
    }
    ···········
}
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 25, 2019
@snicoll snicoll changed the title Add logger.warn when AbstractReactiveHealthIndicator check redis health in springboot2 Reactive health indicators do not log health check failure Jul 25, 2019
@snicoll snicoll added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 25, 2019
@snicoll snicoll added this to the 2.1.x milestone Jul 25, 2019
@snicoll
Copy link
Member

snicoll commented Jul 25, 2019

Thanks, it's an oversight and inconsistent with what the imperative health indicators do.

@snicoll
Copy link
Member

snicoll commented Jul 29, 2019

Closing in favour of #17635

@snicoll snicoll closed this as completed Jul 29, 2019
@snicoll snicoll added the status: superseded An issue that has been superseded by another label Jul 29, 2019
@snicoll snicoll removed this from the 2.1.x milestone Jul 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: superseded An issue that has been superseded by another type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants