feat(telemetry): rollups, alerts, scheduler, health checks, admin server fns

- pure rollup accumulators with tests; daily upserts keyed date/metric/dim
- alert checks with db-backed cooldown and push to admin players
- in-process scheduler started from health probes
- health endpoint checks pb + supertokens, stale-while-revalidate, always 200
- sse connection counter moved to emitter
- telemetry feature server fns: events/errors/groups/rollups/alerts/status
This commit is contained in:
2026-08-25 21:38:08 -07:00
parent e2863c1f6c
commit 06fe1f4ed7
12 changed files with 1009 additions and 11 deletions
+11 -5
View File
@@ -1,19 +1,25 @@
import { createFileRoute } from "@tanstack/react-router";
import { ensureTelemetryScheduler } from "@/lib/telemetry/scheduler.server";
import { getHealthSnapshot } from "@/lib/telemetry/health.server";
export const Route = createFileRoute("/api/health")({
server: {
handlers: {
GET: () => {
GET: async () => {
ensureTelemetryScheduler();
const snapshot = await getHealthSnapshot();
// Always 200: a PB/SuperTokens outage must not fail the k8s probes;
// restarting the app pod cannot fix a dependency.
return new Response(
JSON.stringify({
status: "ok",
status: snapshot.status,
checks: snapshot.checks,
timestamp: new Date().toISOString(),
}),
{
status: 200,
headers: {
"Content-Type": "application/json",
},
headers: { "Content-Type": "application/json" },
}
);
},