Skip to content

Commit

Permalink
fix: add config to disable exemplar
Browse files Browse the repository at this point in the history
  • Loading branch information
wallet77 committed Dec 11, 2023
1 parent 78055fd commit 9a55230
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
9 changes: 7 additions & 2 deletions src/http_hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 9a55230

Please sign in to comment.