From 9a552307a98c77cd064a3bef99bf9349b780ae13 Mon Sep 17 00:00:00 2001 From: wallet77 Date: Mon, 11 Dec 2023 15:07:21 +0100 Subject: [PATCH] fix: add config to disable exemplar --- index.js | 3 +++ src/http_hook.js | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 5382354..f563d29 100644 --- a/index.js +++ b/index.js @@ -34,6 +34,9 @@ class APM { if (!Object.prototype.hasOwnProperty.call(config, 'HTTPHook')) { config.HTTPHook = true } + if (!Object.prototype.hasOwnProperty.call(config, 'enableExemplars')) { + config.enableExemplars = true + } } init () { diff --git a/src/http_hook.js b/src/http_hook.js index 57b5da1..8f96574 100644 --- a/src/http_hook.js +++ b/src/http_hook.js @@ -9,7 +9,7 @@ const init = function (client, config) { name: 'http_request_duration_seconds', help: 'request duration in seconds', labelNames: ['status', 'method', 'route'], - enableExemplars: true, + enableExemplars: config.enableExemplars, buckets: config.HTTP_DURATION_BUCKETS || [0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2] }, summary: { @@ -49,7 +49,12 @@ const init = function (client, config) { const value = delta[0] + delta[1] / 1e9 routeSum.observe(value) - routeHist.observe({ labels, value, exemplarLabels }) + + if (config.enableExemplars) { + routeHist.observe({ labels, value, exemplarLabels }) + } else { + routeHist.observe(labels, value) + } }) } return emit.apply(this, arguments)