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