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
@@ -109,6 +109,7 @@ func run(configPath string) error {
}
recoveryContext, cancelRecovery := context.WithCancel(context.Background())
defer cancelRecovery()
go publishServerTelemetry(recoveryContext, persistence, health)
// Recovery is deliberately asynchronous: liveness and incident inspection
// remain available while committed-range checks run. Readiness becomes
// true only after the real SQLite/segment recovery completes.
@@ -239,3 +240,24 @@ func run(configPath string) error {
return httpErr
}
}
func publishServerTelemetry(ctx context.Context, persistence *store.Store, health *observability.Health) {
ticker := time.NewTicker(10 * time.Second)
defer ticker.Stop()
for {
sampleContext, cancel := context.WithTimeout(ctx, time.Second)
telemetry, err := persistence.Telemetry(sampleContext)
cancel()
if err != nil {
health.Inc("telemetry_read_failure")
} else {
health.SetGauge("queue_depth", float64(telemetry.QueuedCommands))
health.SetGauge("server_charged_bytes", float64(telemetry.ChargedBytes))
}
select {
case <-ctx.Done():
return
case <-ticker.C:
}
}
}
+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),