-
Notifications
You must be signed in to change notification settings - Fork 0
how it works health checks
Shaylen Reddy edited this page Jun 15, 2024
·
2 revisions
Since the subsystems provide a mindmap for each dependency, it isn't necessary to discuss it here
What's important is to provide liveness and health check samples, as well as a diagram demonstrating the flow of the calls from the health checks ui
Health checks are added to IHealthChecksBuilder
and added to the services collection
// This isn't exactly how it's added in this codebase and is here for demonstration purposes
builder.Services.AddHealthChecks()
.AddCheck(
name: "self",
check: () => HealthCheckResult.Healthy(),
tags: new[] { "self" });
Two endpoints are mapped for health checks, one for liveness
[check on self] and one for health
[check on self and all dependencies]
public static WebApplication MapCommonHealthChecks(this WebApplication app)
{
app.MapHealthChecks(app.Configuration["HealthCheckEndpoint"]!, new HealthCheckOptions
{
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
});
app.MapHealthChecks(app.Configuration["LivenessCheckEndpoint"]!, new HealthCheckOptions
{
Predicate = healthCheckRegistration => healthCheckRegistration.Tags.Contains("self"),
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
});
return app;
}
These are from the Mvc Frontend
{
"status": "Healthy",
"totalDuration": "00:00:00.0001447",
"entries": {
"self": {
"data": {},
"duration": "00:00:00.0000154",
"status": "Healthy",
"tags": [
"self"
]
}
}
}
{
"status": "Healthy",
"totalDuration": "00:00:00.0237445",
"entries": {
"self": {
"data": {},
"duration": "00:00:00.0000061",
"status": "Healthy",
"tags": [
"self"
]
},
"identityServer": {
"data": {},
"duration": "00:00:00.0236168",
"status": "Healthy",
"tags": []
},
"gateway": {
"data": {},
"duration": "00:00:00.0174471",
"status": "Healthy",
"tags": []
}
}
}
One thing I wished was the case with the health checks ui is that it did the checks in parallel, but unfortunately it does it one after the other in the order it's defined in app settings
sequenceDiagram
participant healthchecksui as Health Checks UI
participant mvc as Mvc Frontend
participant webbff as Web Backend-For-Frontend
participant addressservice as Address Service
participant addressworker as Address Worker
participant identityservice as Identity Service
participant orderservice as Order Service
participant orderworker as Order Worker
participant tyresservice as Tyres Service
loop Every 30 seconds
healthchecksui ->> mvc: /health/liveness
mvc -->> healthchecksui: 200 OK
healthchecksui ->> webbff: /health/liveness
webbff -->> healthchecksui: 200 OK
healthchecksui ->> addressservice: /health/liveness
addressservice -->> healthchecksui: 200 OK
healthchecksui ->> addressworker: /health/liveness
addressworker -->> healthchecksui: 200 OK
healthchecksui ->> identityservice: /health/liveness
identityservice -->> healthchecksui: 200 OK
healthchecksui ->> orderservice: /health/liveness
orderservice -->> healthchecksui: 200 OK
healthchecksui ->> orderworker: /health/liveness
orderworker -->> healthchecksui: 200 OK
healthchecksui ->> tyresservice: /health/liveness
tyresservice -->> healthchecksui: 200 OK
healthchecksui ->> mvc: /health
mvc -->> healthchecksui: 200 OK
healthchecksui ->> webbff: /health
webbff -->> healthchecksui: 200 OK
healthchecksui ->> addressservice: /health
addressservice -->> healthchecksui: 200 OK
healthchecksui ->> addressworker: /health
addressworker -->> healthchecksui: 200 OK
healthchecksui ->> identityservice: /health
identityservice -->> healthchecksui: 200 OK
healthchecksui ->> orderservice: /health
orderservice -->> healthchecksui: 200 OK
healthchecksui ->> orderworker: /health
orderworker -->> healthchecksui: 200 OK
healthchecksui ->> tyresservice: /health
tyresservice -->> healthchecksui: 200 OK
end
- Health Checks UI
- Mvc Frontend
- Web Backend-For-Frontend
- Address Service
- Address Worker
- Identity Service
- Order Service
- Order Worker
- Tyres Service