fix: expose ai health component errors

This commit is contained in:
Grendgi
2026-06-17 16:35:47 +03:00
parent 22d85ce646
commit aad905c2c8

View File

@@ -19,7 +19,7 @@ type healthDetailResponse struct {
type healthComponent struct {
Name string `json:"name"`
Status string `json:"status"`
Message string `json:"message,omitempty"`
Error string `json:"error,omitempty"`
Data map[string]any `json:"data,omitempty"`
}
@@ -36,7 +36,7 @@ func (s *Server) handleHealthDetail(w http.ResponseWriter, r *http.Request) {
resp.Components = append(resp.Components, healthComponent{
Name: "postgres",
Status: "down",
Message: err.Error(),
Error: err.Error(),
})
resp.Status = worseHealthStatus(resp.Status, "down")
writeJSON(w, http.StatusServiceUnavailable, resp)
@@ -49,7 +49,7 @@ func (s *Server) handleHealthDetail(w http.ResponseWriter, r *http.Request) {
resp.Components = append(resp.Components, healthComponent{
Name: "queue",
Status: "down",
Message: err.Error(),
Error: err.Error(),
})
resp.Status = worseHealthStatus(resp.Status, "down")
writeJSON(w, http.StatusServiceUnavailable, resp)
@@ -103,7 +103,7 @@ func (s *Server) healthProviders(ctx context.Context) healthComponent {
return healthComponent{
Name: "providers",
Status: status,
Message: strings.Join(messages, "; "),
Error: strings.Join(messages, "; "),
Data: map[string]any{
"providers": providers,
},
@@ -133,7 +133,7 @@ func healthQueue(stats *model.Stats) healthComponent {
return healthComponent{
Name: "queue",
Status: status,
Message: message,
Error: message,
Data: map[string]any{
"pending": pending,
"running": running,
@@ -162,7 +162,7 @@ func healthErrors(stats *model.Stats) healthComponent {
return healthComponent{
Name: "errors",
Status: status,
Message: message,
Error: message,
Data: map[string]any{
"failed_total": failedTotal,
"failed_24h": failed24h,
@@ -203,7 +203,7 @@ func healthThroughput(stats *model.Stats) healthComponent {
return healthComponent{
Name: "throughput",
Status: status,
Message: message,
Error: message,
Data: map[string]any{
"done_24h": done24h,
"retried_24h": retried24h,
@@ -223,7 +223,7 @@ func healthInfra(infra infraStatusResponse) healthComponent {
return healthComponent{
Name: "infra",
Status: status,
Message: message,
Error: message,
Data: map[string]any{
"sidecar": infra.Sidecar,
},