feat: publish durable queue and spool gauges

This commit is contained in:
2026-09-11 09:28:54 +00:00
parent ea8a4d8846
commit 0e18af02bb
7 changed files with 178 additions and 0 deletions
+22
View File
@@ -180,6 +180,7 @@ func runClientDaemon(ctx context.Context, configPath string, diagnostics io.Writ
return fmt.Errorf("open client durable state: %w", err)
}
defer state.Close()
go publishClientTelemetry(ctx, state, health)
if diagnostics != nil {
_, _ = fmt.Fprintf(diagnostics, "rvbox client service initialized for %s\n", configured.Client.ServerURL)
}
@@ -250,6 +251,27 @@ func runClientDaemon(ctx context.Context, configPath string, diagnostics io.Writ
return nil
}
func publishClientTelemetry(ctx context.Context, state *spool.Store, health *observability.Health) {
ticker := time.NewTicker(10 * time.Second)
defer ticker.Stop()
for {
sampleContext, cancel := context.WithTimeout(ctx, time.Second)
telemetry, err := state.Telemetry(sampleContext)
cancel()
if err != nil {
health.Inc("telemetry_read_failure")
} else {
health.SetGauge("queue_depth", float64(telemetry.QueuedCommands))
health.SetGauge("client_spool_bytes", float64(telemetry.ChargedBytes))
}
select {
case <-ctx.Done():
return
case <-ticker.C:
}
}
}
func clientJobProfiles(profiles config.Profiles) map[string]clientwindows.JobProfile {
return map[string]clientwindows.JobProfile{
rvboxv1.ExecutionProfile_EXECUTION_PROFILE_LIGHT.String(): toJobProfile(profiles.Light),