@kitten-science/kitten-analysts
Version:
25 lines • 1.02 kB
JavaScript
import { isNil, mustExist } from "@oliversalzburg/js-utils/data/nil.js";
import { Gauge } from "prom-client";
export const gaugeFactory = (instructions) => new Gauge({
help: instructions.help,
name: instructions.name,
labelNames: instructions.labelNames,
async collect() {
if (!instructions.cache.has(instructions.require)) {
instructions.cache.set(instructions.require, instructions.remote.sendMessage({ type: instructions.require }));
}
const response = await instructions.cache.get(instructions.require);
if (isNil(response)) {
return;
}
for (const clientResponse of response) {
if (clientResponse === null) {
continue;
}
for (const entity of mustExist(clientResponse.data)) {
instructions.extract(clientResponse.client_type, clientResponse.guid, clientResponse.location, entity, this);
}
}
},
});
//# sourceMappingURL=factory.js.map