From 2da996a9806edaa18d2b3fb261f163fc0d48e040 Mon Sep 17 00:00:00 2001 From: ayanamist Date: Thu, 1 Sep 2022 13:47:56 +0800 Subject: [PATCH] Adds WithCustomRegistry method to the metrics pkg to allow reuse of an existing registry. --- metrics/metrics.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/metrics/metrics.go b/metrics/metrics.go index 3baab8ca7..e90de2c51 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -179,6 +179,13 @@ func WithProcessStartTime(registerProcessStartTime bool) MetricsManagerOption { } } +// WithCustomRegistry allow user to use custom pre-created registry instead of a new created one. +func WithCustomRegistry(registry metrics.KubeRegistry) MetricsManagerOption { + return func(cmm *csiMetricsManager) { + cmm.registry = registry + } +} + // NewCSIMetricsManagerForSidecar creates and registers metrics for CSI Sidecars and // returns an object that can be used to trigger the metrics. It uses "csi_sidecar" // as subsystem.