Merge pull request #102801 from CKchen0726/remove_storage_metrics_in_1.21_release

remove storageOperationErrorMetric and storageOperationStatusMetric in release 1.21
This commit is contained in:
Kubernetes Prow Robot 2021-10-27 01:21:26 -07:00 committed by GitHub
commit 10988997f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 30 deletions

View File

@ -54,24 +54,6 @@ var storageOperationMetric = metrics.NewHistogramVec(
[]string{"volume_plugin", "operation_name", "status", "migrated"},
)
var storageOperationErrorMetric = metrics.NewCounterVec(
&metrics.CounterOpts{
Name: "storage_operation_errors_total",
Help: "Storage operation errors (Deprecated since 1.21.0)",
StabilityLevel: metrics.ALPHA,
},
[]string{"volume_plugin", "operation_name"},
)
var storageOperationStatusMetric = metrics.NewCounterVec(
&metrics.CounterOpts{
Name: "storage_operation_status_count",
Help: "Storage operation return statuses count (Deprecated since 1.21.0)",
StabilityLevel: metrics.ALPHA,
},
[]string{"volume_plugin", "operation_name", "status"},
)
var storageOperationEndToEndLatencyMetric = metrics.NewHistogramVec(
&metrics.HistogramOpts{
Name: "volume_operation_total_seconds",
@ -101,8 +83,6 @@ func registerMetrics() {
// legacyregistry is the internal k8s wrapper around the prometheus
// global registry, used specifically for metric stability enforcement
legacyregistry.MustRegister(storageOperationMetric)
legacyregistry.MustRegister(storageOperationErrorMetric)
legacyregistry.MustRegister(storageOperationStatusMetric)
legacyregistry.MustRegister(storageOperationEndToEndLatencyMetric)
legacyregistry.MustRegister(csiOperationsLatencyMetric)
}
@ -118,14 +98,12 @@ func OperationCompleteHook(plugin, operationName string) func(types.CompleteFunc
// TODO: Establish well-known error codes to be able to distinguish
// user configuration errors from system errors.
status = statusFailUnknown
storageOperationErrorMetric.WithLabelValues(plugin, operationName).Inc()
}
migrated := false
if c.Migrated != nil {
migrated = *c.Migrated
}
storageOperationMetric.WithLabelValues(plugin, operationName, status, strconv.FormatBool(migrated)).Observe(timeTaken)
storageOperationStatusMetric.WithLabelValues(plugin, operationName, status).Inc()
}
return opComplete
}

View File

@ -84,28 +84,29 @@ func TestOperationGenerator_GenerateUnmapVolumeFunc_PluginName(t *testing.T) {
t.Fatalf("Error occurred while generating unmapVolumeFunc: %v", e)
}
metricFamilyName := "storage_operation_status_count"
metricFamilyName := "storage_operation_duration_seconds"
labelFilter := map[string]string{
"migrated": "false",
"status": "success",
"operation_name": "unmap_volume",
"volume_plugin": expectedPluginName,
}
// compare the relative change of the metric because of the global state of the prometheus.DefaultGatherer.Gather()
storageOperationStatusCountMetricBefore := findMetricWithNameAndLabels(metricFamilyName, labelFilter)
storageOperationDurationSecondsMetricBefore := findMetricWithNameAndLabels(metricFamilyName, labelFilter)
var ee error
unmapVolumeFunc.CompleteFunc(volumetypes.CompleteFuncParam{Err: &ee})
storageOperationStatusCountMetricAfter := findMetricWithNameAndLabels(metricFamilyName, labelFilter)
if storageOperationStatusCountMetricAfter == nil {
storageOperationDurationSecondsMetricAfter := findMetricWithNameAndLabels(metricFamilyName, labelFilter)
if storageOperationDurationSecondsMetricAfter == nil {
t.Fatalf("Couldn't find the metric with name(%s) and labels(%v)", metricFamilyName, labelFilter)
}
if storageOperationStatusCountMetricBefore == nil {
assert.Equal(t, float64(1), *storageOperationStatusCountMetricAfter.Counter.Value, tc.name)
if storageOperationDurationSecondsMetricBefore == nil {
assert.Equal(t, uint64(1), *storageOperationDurationSecondsMetricAfter.Histogram.SampleCount, tc.name)
} else {
metricValueDiff := *storageOperationStatusCountMetricAfter.Counter.Value - *storageOperationStatusCountMetricBefore.Counter.Value
assert.Equal(t, float64(1), metricValueDiff, tc.name)
metricValueDiff := *storageOperationDurationSecondsMetricAfter.Histogram.SampleCount - *storageOperationDurationSecondsMetricBefore.Histogram.SampleCount
assert.Equal(t, uint64(1), metricValueDiff, tc.name)
}
}
}