Add fallback handling for telemetry ingestion failures in broker and HTTP persistence check for control plane events
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user