diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go index 52955fcbb..600a1b2f0 100644 --- a/pkg/metrics/metrics.go +++ b/pkg/metrics/metrics.go @@ -39,11 +39,6 @@ const ( ) var ( - gkeComponentVersion *metrics.GaugeVec - pdcsiOperationErrorsMetric *metrics.CounterVec -) - -func initMetrics() { // This metric is exposed only from the controller driver component when GKE_PDCSI_VERSION env variable is set. gkeComponentVersion = metrics.NewGaugeVec(&metrics.GaugeOpts{ Name: "component_version", @@ -58,7 +53,7 @@ func initMetrics() { StabilityLevel: metrics.ALPHA, }, []string{"driver_name", "method_name", "grpc_status_code", "disk_type", "enable_confidential_storage", "enable_storage_pools"}) -} +) type MetricsManager struct { registry metrics.KubeRegistry diff --git a/pkg/metrics/metrics_test_util.go b/pkg/metrics/metrics_test_util.go index c77142413..ce0d13d95 100644 --- a/pkg/metrics/metrics_test_util.go +++ b/pkg/metrics/metrics_test_util.go @@ -19,5 +19,6 @@ package metrics // Test-only method used for resetting metric counts. func (mm *MetricsManager) ResetMetrics() { // Re-initialize metrics - initMetrics() + gkeComponentVersion.Reset() + pdcsiOperationErrorsMetric.Reset() }