mirror of
https://github.com/mudler/LocalAI.git
synced 2026-09-29 17:44:30 -04:00
Warm local targets are pinned in the watchdog and preloaded. Switches and target health are exported as metrics, skipped attempts as traces. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
24 lines
578 B
Go
24 lines
578 B
Go
package failover
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/mudler/LocalAI/core/trace"
|
|
)
|
|
|
|
// RecordAttemptTrace shows in the Traces UI why a target was skipped.
|
|
func RecordAttemptTrace(enabled bool, chain, target string, err error) {
|
|
if !enabled || err == nil {
|
|
return
|
|
}
|
|
trace.RecordBackendTrace(trace.BackendTrace{
|
|
Timestamp: time.Now(),
|
|
Type: trace.BackendTraceFailover,
|
|
ModelName: target,
|
|
Summary: fmt.Sprintf("failover chain %s: %s failed, trying the next target", chain, target),
|
|
Error: err.Error(),
|
|
Data: map[string]any{"chain": chain},
|
|
})
|
|
}
|