Use csi-lib-utils v0.10.0
This commit is contained in:
18
vendor/github.com/kubernetes-csi/csi-lib-utils/metrics/metrics.go
generated
vendored
18
vendor/github.com/kubernetes-csi/csi-lib-utils/metrics/metrics.go
generated
vendored
@@ -47,6 +47,9 @@ const (
|
||||
labelGrpcStatusCode = "grpc_status_code"
|
||||
unknownCSIDriverName = "unknown-driver"
|
||||
|
||||
// LabelMigrated is the Label that indicate whether this is a CSI migration operation
|
||||
LabelMigrated = "migrated"
|
||||
|
||||
// CSI Operation Latency with status code total - Histogram Metric
|
||||
operationsLatencyMetricName = "operations_seconds"
|
||||
operationsLatencyHelp = "Container Storage Interface operation duration with gRPC error code status total"
|
||||
@@ -83,6 +86,10 @@ type CSIMetricsManager interface {
|
||||
// and then accumulates values.
|
||||
WithLabelValues(labels map[string]string) (CSIMetricsManager, error)
|
||||
|
||||
// HaveAdditionalLabel can be used to check if the additional label
|
||||
// value is defined in the metrics manager
|
||||
HaveAdditionalLabel(name string) bool
|
||||
|
||||
// SetDriverName is called to update the CSI driver name. This should be done
|
||||
// as soon as possible, otherwise metrics recorded by this manager will be
|
||||
// recorded with an "unknown-driver" driver_name.
|
||||
@@ -149,6 +156,13 @@ func WithLabels(labels map[string]string) MetricsManagerOption {
|
||||
}
|
||||
}
|
||||
|
||||
// WithMigration adds the migrated field to the current metrics label
|
||||
func WithMigration() MetricsManagerOption {
|
||||
return func(cmm *csiMetricsManager) {
|
||||
cmm.additionalLabelNames = append(cmm.additionalLabelNames, LabelMigrated)
|
||||
}
|
||||
}
|
||||
|
||||
// WithProcessStartTime controlls whether process_start_time_seconds is registered
|
||||
// in the registry of the metrics manager. It's enabled by default out of convenience
|
||||
// (no need to do anything special in most sidecars) but should be disabled in more
|
||||
@@ -316,7 +330,7 @@ func (cmmv *csiMetricsManagerWithValues) WithLabelValues(labels map[string]strin
|
||||
}
|
||||
// Now add all new values.
|
||||
for name, value := range labels {
|
||||
if !extended.haveAdditionalLabel(name) {
|
||||
if !extended.HaveAdditionalLabel(name) {
|
||||
return nil, fmt.Errorf("label %q was not defined via WithLabelNames", name)
|
||||
}
|
||||
if v, ok := extended.additionalValues[name]; ok {
|
||||
@@ -327,7 +341,7 @@ func (cmmv *csiMetricsManagerWithValues) WithLabelValues(labels map[string]strin
|
||||
return extended, nil
|
||||
}
|
||||
|
||||
func (cmm *csiMetricsManager) haveAdditionalLabel(name string) bool {
|
||||
func (cmm *csiMetricsManager) HaveAdditionalLabel(name string) bool {
|
||||
for _, n := range cmm.additionalLabelNames {
|
||||
if n == name {
|
||||
return true
|
||||
|
Reference in New Issue
Block a user