Skip to content

Commit

Permalink
Merge pull request #1895 from DataDog/fricounet/upstream/fix-panic
Browse files Browse the repository at this point in the history
[metrics] Fix panic during metrics manager startup
  • Loading branch information
k8s-ci-robot authored Jan 2, 2025
2 parents 13bf655 + 7407af0 commit c29a4ee
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
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()
}

0 comments on commit c29a4ee

Please sign in to comment.