feat: include date in metrics for aggregations
Code Analysis / SonarQube (push) Failing after 19s
Node.js CI / Lint and Test (push) Successful in 44s

This commit is contained in:
2025-10-07 16:02:54 -07:00
parent 3c9f6fa41a
commit d49f1b2479
+29 -19
View File
@@ -87,26 +87,36 @@ export const instantiateServer = async(): Promise<void> => {
return; return;
} }
const { application, name, value, metadata } = request.body; const { application, name, value, metadata } = request.body;
await fetch(`https://telemetry.nhcarrigan.com/api/33kzMoHcYaaEyqCFsauKPhTvEtx/ingest/metrics/_json`, { await fetch(
body: JSON.stringify([ { `https://telemetry.nhcarrigan.com/api/33kzMoHcYaaEyqCFsauKPhTvEtx/ingest/metrics/_json`,
// eslint-disable-next-line @typescript-eslint/naming-convention -- Needs to match API's structure. {
__name__: "metrics", body: JSON.stringify([
// eslint-disable-next-line @typescript-eslint/naming-convention -- Needs to match API's structure. {
__type__: "count", // eslint-disable-next-line @typescript-eslint/naming-convention -- Needs to match API's structure.
app: application, __name__: "metrics",
metadata: metadata ?? {}, // eslint-disable-next-line @typescript-eslint/naming-convention -- Needs to match API's structure.
name: name, __type__: "count",
timestamp: Date.now(), app: application,
value: value, date: new Date().toLocaleDateString("en-GB", {
} ]), day: "numeric",
headers: { month: "long",
// eslint-disable-next-line @typescript-eslint/naming-convention -- Standard header. year: "numeric",
"Authorization": `Basic ${process.env.TELEMETRY_TOKEN ?? ""}`, }),
// eslint-disable-next-line @typescript-eslint/naming-convention -- Standard header. metadata: metadata ?? {},
"Content-Type": "application/json", name: name,
timestamp: Date.now(),
value: value,
},
]),
headers: {
// eslint-disable-next-line @typescript-eslint/naming-convention -- Standard header.
"Authorization": `Basic ${process.env.TELEMETRY_TOKEN ?? ""}`,
// eslint-disable-next-line @typescript-eslint/naming-convention -- Standard header.
"Content-Type": "application/json",
},
method: "POST",
}, },
method: "POST", );
});
} catch (error) { } catch (error) {
await errorHandler(error, "Metric Webhook"); await errorHandler(error, "Metric Webhook");
await response.status(500).send({ success: false }); await response.status(500).send({ success: false });