From 69021a5c8e236ae21a9cd6125f8ec8ca5bf6a275 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Sat, 11 Nov 2023 23:01:39 +0200 Subject: [PATCH] make metric buckets configurable --- src/MariaDB.ts | 5 +++-- src/MongoDB.ts | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/MariaDB.ts b/src/MariaDB.ts index 7aedabd..4d9cad3 100644 --- a/src/MariaDB.ts +++ b/src/MariaDB.ts @@ -26,7 +26,8 @@ export type MariaOptions = { credentials: Credentials, loggerOptions?: LoggerClientOptions, donorQuery?: boolean, - recordMetrics?: boolean + recordMetrics?: boolean, + metricsBuckets?: number[], } type MariaError = { @@ -247,7 +248,7 @@ class MariaDB MariaDB.#queryHistogram = new Prometheus.Histogram({ name: 'sql_queries', help: 'Tracks query duration in seconds and frequency', - buckets: Prometheus?.exponentialBuckets(0.005, 2, 10), + buckets: this.#config.metricsBuckets ?? Prometheus?.exponentialBuckets(0.005, 2, 10), labelNames: [ 'type' ] as const }); this.#server.registerMetric(MariaDB.#queryHistogram!); diff --git a/src/MongoDB.ts b/src/MongoDB.ts index 5f0742f..b80688f 100644 --- a/src/MongoDB.ts +++ b/src/MongoDB.ts @@ -22,7 +22,8 @@ export type MongoOptions = { loggerOptions?: LoggerClientOptions, client?: MongoClientOptions, load?: boolean, - recordMetrics?: boolean + recordMetrics?: boolean, + metricsBuckets?: number[], } type StringIndexable = {[key: string]: boolean | string | number | Document | object} @@ -151,7 +152,7 @@ class MongoDB MongoDB.#queryHistogram = new Prometheus.Histogram({ name: 'mongo_queries', help: 'Tracks query duration in seconds and frequency', - buckets: Prometheus?.exponentialBuckets(0.005, 2, 10), + buckets: this.#config.metricsBuckets ?? Prometheus?.exponentialBuckets(0.005, 2, 10), labelNames: [ 'type' ] as const }); this.#server.registerMetric(MongoDB.#queryHistogram!);