feat: publish durable queue and spool gauges
This commit is contained in:
@@ -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:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user