fix: add periodic flush and graceful shutdown for server-side telemetry

The TelemetryClient only flushed at 50 events, so the server silently
lost all queued telemetry on restart. Add startPeriodicFlush/stop methods
to TelemetryClient, wire up 60s periodic flush in server initTelemetry,
and flush on SIGTERM/SIGINT before exit.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
dotta 2026-03-31 12:02:36 -05:00
parent 34044cdfce
commit f16de6026d
4 changed files with 104 additions and 10 deletions

View file

@ -21,6 +21,7 @@ export function initTelemetry(fileConfig?: { enabled?: boolean }): TelemetryClie
() => loadOrCreateState(stateDir, serverVersion),
serverVersion,
);
client.startPeriodicFlush(60_000);
return client;
}