Skip to content
This repository has been archived by the owner on Aug 24, 2023. It is now read-only.

Commit

Permalink
feat: allow default metrics to be disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
wemeetagain committed Nov 20, 2022
1 parent ba33924 commit e839e97
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ export interface PrometheusMetricsInit {
collectDefaultMetrics?: boolean

/**
* prom-client options to pass to the `collectDefaultMetrics` function
* prom-client options to pass to the `collectDefaultMetrics` function.
* Set to `false` to disable `collectDefaultMetrics`.
*/
defaultMetrics?: DefaultMetricsCollectorConfiguration
defaultMetrics?: DefaultMetricsCollectorConfiguration | false

/**
* All metrics in prometheus are global so to prevent clashes in naming
Expand All @@ -40,9 +41,9 @@ class PrometheusMetrics implements Metrics {
register.clear()
}

if (init?.preserveExistingMetrics !== false) {
if (init?.preserveExistingMetrics !== false || init?.defaultMetrics === false) {
log('Collecting default metrics')
collectDefaultMetrics(init?.defaultMetrics)
collectDefaultMetrics(init?.defaultMetrics as DefaultMetricsCollectorConfiguration)
}

// holds global and per-protocol sent/received stats
Expand Down

0 comments on commit e839e97

Please sign in to comment.