@christiangalsterer/mongodb-driver-prometheus-exporter
Version:
Prometheus exporter to monitor the MongoDB Node.js driver
43 lines • 1.71 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConsoleLogger = void 0;
exports.mergeLabelNamesWithStandardLabels = mergeLabelNamesWithStandardLabels;
exports.mergeLabelsWithStandardLabels = mergeLabelsWithStandardLabels;
/* eslint @typescript-eslint/class-methods-use-this: ["error", { "exceptMethods": ["info", "warn", "error"] }] */
class ConsoleLogger {
info(message) {
// eslint-disable-next-line no-console
console.log(message);
}
warn(message) {
// eslint-disable-next-line no-console
console.log(message);
}
error(message) {
// eslint-disable-next-line no-console
console.log(message);
}
}
exports.ConsoleLogger = ConsoleLogger;
/**
* Merges an array of label names with the label names of the default labels into a new array.
* @param labelNames array of label names to merge with the default labels
* @param defaultLabels default labels to merge with
* @returns array of merged label names
*/
function mergeLabelNamesWithStandardLabels(labelNames, defaultLabels = {}) {
return labelNames.concat(Object.keys(defaultLabels));
}
/**
* Merges Labels with default labels
* @param labels labels to merge with the default labels
* @param defaultLabels default labels to merge with
* @returns merged labels
*/
function mergeLabelsWithStandardLabels(labels, defaultLabels = {}) {
const filtered = Object.fromEntries(Object.entries(labels)
.filter(([key, value]) => value !== undefined && (typeof value === 'string' || typeof value === 'number'))
.map(([key, value]) => [key, value]));
return { ...filtered, ...defaultLabels };
}
//# sourceMappingURL=utils.js.map