smallrye / smallrye-health

Home Page:https://smallrye.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dynamically register HealthGroups

AndreasScharfCPB opened this issue · comments

Hi there,

we would be interested in registering healthGroups. As stated here I am opening an issue : https://smallrye.io/docs/smallrye-health/3.0.1/health-registry.html

We have a distributed system and we would like to use smallrye-health in one service to register / forward other smallrye healthchecks of other services, some of which are written in other languages etc.
So that we can have one global health-ui instance

hmm, very interesting. But how would you generify what code should be executed in the health check? Would we define some preconfigured HealthCheck implementations that would be just configurable in the message? Also depends on what communication protocols we would use.

@AndreasScharfCPB can you please clarify my questions? We can implement this if we have a clear idea of what API is imagined.

Hi, sorry for the late response.

Well I am doing a custom implementation that registers the health checks of the other services as health checks in the main service. And while I am registering a new health check I would like to put it into a group.
My case is a bit special, but I guess it would be nice to be able to add a healthcheck to a group when registering it dynamically in your code.

No worries at all. This is already possible - https://github.com/smallrye/smallrye-health/blob/main/api/src/main/java/io/smallrye/health/api/HealthRegistry.java#L68. Is this what you mean? So no serialization over the network. Only a way to dynamically register/remove health checks in service A with a remote call from service B (so B -> register HC -> A).

EDIT: Just a few more links: documentation - https://smallrye.io/docs/smallrye-health/3.0.1/health-registry.html and custom health group registry can taken from https://github.com/smallrye/smallrye-health/blob/main/implementation/src/main/java/io/smallrye/health/registry/HealthRegistries.java#L57

Correct. I just want to register it dynamically.
I can already register health checks however it is not possible to assign them to Groups.

Hi, I came across this issue while trying to dynamically register health checks with a given group. I think the approach described above won't work if there isn't at least one bean annotated with @healthGroup(my-health-group).
Looking at the code I understand that SmallRyeHealthProcessor will first scan the beans looking for classes annotated with @HealthGroup/@HealthGroups (see here) and then add routes only for those groups (here). If my-health-group is created after the routes are initialized, there won't be any route for it and invoking /q/health/group/my-health-group will result in a 404.

@xstefank exactly. Is that new or did I just not see it? I have to give it a try.
@lorenzobenvenuti thanks for the clarification!

hi @lorenzobenvenuti that is correct and I noticed that also just while testing this issue. So if you would appreciate this functionality can you please file a new issue for it?

@Schoaf not new but it seems we forgot to add it the registries documentation. I will fix that! Glad that it's working.

I guess that is exactly the problem here:
I would not only like to dynamically add checks to "a" group but dynamically create new groups which is not possible if I have to use an annotation. So I would like to see an method where I can register a new healthGroup.

ok, I will implement the groups to be created on manual registration too.

awesome! thanks! :)