-
Notifications
You must be signed in to change notification settings - Fork 800
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
Actuator healthcheck #1103
base: master
Are you sure you want to change the base?
Actuator healthcheck #1103
Conversation
337738f
to
b5975ea
Compare
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.
I'm currently buzy with work, so reviews will take a while.
grpc-server-spring-boot-starter/src/main/java/net/devh/boot/grpc/server/config/HealthType.java
Outdated
Show resolved
Hide resolved
public void check(HealthCheckRequest request, StreamObserver<HealthCheckResponse> responseObserver) { | ||
|
||
if (!request.getService().isEmpty()) { | ||
var health = healthEndpoint.healthForPath(request.getService()); |
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.
The rest of our code doesn't use var
.
if (Objects.equals(org.springframework.boot.actuate.health.Status.UP.getCode(), status.getCode())) { | ||
return HealthCheckResponse.ServingStatus.SERVING; | ||
} | ||
if (Objects.equals(org.springframework.boot.actuate.health.Status.DOWN.getCode(), status.getCode()) || Objects | ||
.equals(org.springframework.boot.actuate.health.Status.OUT_OF_SERVICE.getCode(), status.getCode())) { | ||
return HealthCheckResponse.ServingStatus.NOT_SERVING; | ||
} | ||
return HealthCheckResponse.ServingStatus.UNKNOWN; |
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.
IMO these checks can be simplified to:
org.springframework.boot.actuate.health.Status.UP.equals(status)
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.
I changed to Status.UP.equals(status)
in the UP condition, but I am not sure if you meant just replacing the object equals comparing code to use the class equals, or not having the DOWN
and OUT_OF_SERVICE
cases and just returning NOT_SERVING
for everything else, can you clarify this part?
/** | ||
* Use the standard GRPC health service from io.grpc. | ||
*/ | ||
GRPC, | ||
/** | ||
* Uses a bridge to the Spring Boot Actuator health service. | ||
*/ | ||
ACTUATOR, |
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.
Maybe add @see
/ {@link}
links to the implementation classes.
@@ -228,6 +228,14 @@ public class GrpcServerProperties { | |||
*/ | |||
private boolean healthServiceEnabled = true; |
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.
maybe deprecate this in favor of HealthType.NONE
* @param healthServiceType The implementation of gRPC health service. | ||
* @return GRPC or Actuator. | ||
*/ | ||
private HealthType healthServiceType = HealthType.GRPC; |
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.
Question: Should we create a nested object for this?
That would give the potential later update frequency a place for its property.
If we don't plan to add it for now, we can leave it as is for now.
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.
That makes sense, maybe with Watch
a new property will be necessary for the interval between checks. I will change to a nested object
.../net/devh/boot/grpc/server/autoconfigure/GrpcHealthServiceTrueActuatorConfigurationTest.java
Show resolved
Hide resolved
...ring-boot-starter/src/test/java/net/devh/boot/grpc/server/health/ActuatorGrpcHealthTest.java
Show resolved
Hide resolved
var health = healthEndpoint.healthForPath(request.getService()); | ||
if (health == null) { | ||
responseObserver.onError(new StatusException( | ||
Status.NOT_FOUND.withDescription("unknown service " + request.getService()))); |
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.
Status is only used once here and maybe that can be avoided with statically importing NOT_FOUND
, then you could import org.springframework.boot.actuate.health.Status
instead and make it easier to read.
(I wish Java would support import aliasing)
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.
👍 Code changed accordingly
Co-authored-by: ST-DDT <ST-DDT@gmx.de>
Co-authored-by: ST-DDT <ST-DDT@gmx.de>
Co-authored-by: ST-DDT <ST-DDT@gmx.de>
…pc/server/autoconfigure/GrpcHealthServiceTrueActuatorConfigurationTest.java Co-authored-by: ST-DDT <ST-DDT@gmx.de>
…pc/server/health/ActuatorGrpcHealthTest.java Co-authored-by: ST-DDT <ST-DDT@gmx.de>
459c018
to
dc3e521
Compare
dc3e521
to
183c22b
Compare
fd3070e
to
259cec4
Compare
259cec4
to
65e8a1b
Compare
This is the initial work for #1091.
It is only implementing the
check
now, but watch will be added later by pushing metrics every 30s as @ST-DDT suggested.I was wondering if this should be the default behavior when the actuator is present, so I added a property to enable this instead of the GRPC standard health endpoint.