Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[metrics] Fix panic during metrics manager startup #1895

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion pkg/metrics/metrics_test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}