in internal/oraclemetrics/oraclemetrics.go [236:268]
func checkDatabaseHealth(ctx context.Context, connections map[string]*sql.DB) map[string]*ServiceHealth {
statusData := make(map[string]*ServiceHealth)
for serviceName, db := range connections {
rows, err := db.QueryContext(ctx, healthQuery)
if err != nil {
statusData[serviceName] = &ServiceHealth{
Status: Unhealthy,
LastChecked: time.Now(),
Message: fmt.Sprintf("query execution failed: %v", err.Error()),
}
continue
}
defer rows.Close()
var result int
for rows.Next() {
if err := rows.Scan(&result); err != nil {
statusData[serviceName] = &ServiceHealth{
Status: Unhealthy,
LastChecked: time.Now(),
Message: fmt.Sprintf("query returned no rows: %v", err.Error()),
}
} else {
statusData[serviceName] = &ServiceHealth{
Status: Healthy,
LastChecked: time.Now(),
}
}
}
}
return statusData
}