From b2a06d5e733d95998e622e6df1848923091c7e73 Mon Sep 17 00:00:00 2001 From: pur Date: Mon, 2 Nov 2020 11:55:04 +0700 Subject: [PATCH] set buckets as optional in histogram --- lib/common/prom.utils.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/common/prom.utils.ts b/lib/common/prom.utils.ts index 871fe1e..e082f30 100644 --- a/lib/common/prom.utils.ts +++ b/lib/common/prom.utils.ts @@ -76,12 +76,15 @@ export function findOrCreateMetric({ if (metric && metric instanceof client.Histogram) { return metric; } - return new client.Histogram({ + const histogramConfig = { name: name, help: help || `${name} ${type}`, labelNames, - buckets, - }); + }; + if (buckets) { + histogramConfig['buckets'] = buckets; + } + return new client.Histogram(histogramConfig); case "Summary": if (metric && metric instanceof client.Summary) { return metric;