Add fallback handling for telemetry ingestion failures in broker and HTTP persistence check for control plane events

This commit is contained in:
Jeppe Bundgaard
2026-04-27 11:52:38 +02:00
parent 99a85878cd
commit c95fd3a23c
4 changed files with 89 additions and 4 deletions
+14 -2
View File
@@ -535,17 +535,29 @@ export function createBrokerServer(options = {}) {
if (message.type === "TELEMETRY") {
const payload = message.payload || {};
const ingested = await ingestTelemetry(String(ws.gatewayId), payload);
let ingested = null;
let ingestError = null;
try {
ingested = await ingestTelemetry(String(ws.gatewayId), payload);
} catch (error) {
ingestError = error instanceof Error ? error.message : String(error);
}
const fallbackStatistics = {
system_metrics: payload?.metadata?.system_metrics || {},
container_health: payload?.metadata?.container_health || {},
};
broadcastGatewayEvent(String(ws.gatewayId), {
type: "gateway.telemetry",
gatewayId: String(ws.gatewayId),
telemetry: payload,
gateway: ingested?.gateway || ingested || null,
error: ingestError,
});
broadcastGatewayEvent(String(ws.gatewayId), {
type: "stats.updated",
gatewayId: String(ws.gatewayId),
statistics: ingested?.statistics || ingested || null,
statistics: ingested?.statistics || ingested || fallbackStatistics,
error: ingestError,
});
return;
}