diff --git a/src/index.ts b/src/index.ts index ba89a06..0a0e7c4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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 @@ -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