-
Notifications
You must be signed in to change notification settings - Fork 160
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
Include failing/timed out check name in health/readiness check response #638
Conversation
I like the idea and I don't see a reason for not improving the message. |
a0b17d9
to
528ad78
Compare
Cool, thanks @renatocaval. This is ready for a review. |
@@ -33,14 +33,14 @@ abstract class HealthChecks { | |||
/** | |||
* Returns Future(true) if the system is ready to receive user traffic | |||
*/ | |||
def ready(): Future[Boolean] | |||
def ready(): Future[Either[String, Unit]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes the public API in a non-compatible way.
We'd have to add new methods and delegate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, that should be simple enough, I'll update when I have some time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we solve this with additional or improved logging instead of changing API?
@@ -30,16 +29,16 @@ final class HealthChecks(system: ExtendedActorSystem, settings: HealthCheckSetti | |||
/** | |||
* Returns CompletionStage(true) if the system is ready to receive user traffic | |||
*/ | |||
def ready(): CompletionStage[java.lang.Boolean] = | |||
delegate.ready().map(Boolean.box)(ExecutionContexts.sameThreadExecutionContext).toJava | |||
def ready(): CompletionStage[Either[String, Unit]] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we shouldn't use Either
in javadsl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point - ideas on what a good alternative would be for Java (if this PR goes forward)? Maybe Optional<String>
(plus delegated methods requested by @chbatey)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably a custom type is more idiomatic in Java
I'll look into it, but atm I'm not sure how unfortunately, as I think the majority of the utility is from having the messages directly in the HTTP response. Consider it may be a bit more difficult to obtain host logs than it is to hit an endpoint. |
I agree it will be very useful to have this in the error message so you can see it from the place doing the pinging of the health checks. If we can do it in an API compatible way I am +1 to doing this |
Okay, I've pushed an update to ensure the API remains compatible, let me know what y'all think. Thanks! |
This modifies the readiness/health check internals to ensure that when a check fails, for any reason, that the check's class name is included in the message to aid in debugging. Additionally, timeouts are now tracked on a per-check basis so that it's clear which check timed out.
/** | ||
* Returns CompletionStage(true) if the system is ready to receive user traffic | ||
*/ | ||
def ready(): CompletionStage[java.lang.Boolean] = | ||
delegate.ready().map(Boolean.box)(ExecutionContexts.sameThreadExecutionContext).toJava | ||
readyResult().thenApply(((r: CheckResult) => r.isSuccess).asJava) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Originally had .thenApply(_.iSuccess).asJava
but that failed to compile on 2.11:
[error] /Users/jlongshore/work/tubi/akka-management/management/src/main/scala/akka/management/javadsl/HealthChecks.scala:38:29: missing parameter type for expanded function ((x$2) => x$2.isSuccess)
[error] readyResult().thenApply(_.isSuccess)
[error] ^
[error] /Users/jlongshore/work/tubi/akka-management/management/src/main/scala/akka/management/javadsl/HealthChecks.scala:52:29: missing parameter type for expanded function ((x$4) => x$4.isSuccess)
[error] aliveResult().thenApply(_.isSuccess)
[error] ^
[error] two errors found
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for updating and sorry for the slow reviews
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Include failing check name in health/readiness check messages/responses
This modifies the readiness/health check internals to ensure that when a check fails, for any reason, that the check's class name is included in the message to aid in debugging. Additionally, timeouts are now tracked on a per-check basis so that it's clear which check timed out.
I haven't updated the tests yet -- if I could get some validation/assurance that such a chance would be accepted, then I'd be happy to get the tests passing.Ready for a review.
Example failure: