Skip to content
Permalink
Browse files

Add transformation_operations_total to transformer metrics.

  • Loading branch information...
immutableT committed Nov 6, 2018
1 parent 8dcdec0 commit 190c9e383ab1f18886b5410d7f65e1b5aba2ecd9
Showing with 18 additions and 4 deletions.
  1. +18 −4 staging/src/k8s.io/apiserver/pkg/storage/value/metrics.go
@@ -41,12 +41,22 @@ var (
},
[]string{"transformation_type"},
)
transformerFailuresTotal = prometheus.NewCounterVec(
transformerOperationsTotal = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "transformation_operations_total",
Help: "Total number of transformations.",
},
[]string{"transformation_type", "status"},
)
// Deprecated, use transformerOperationsTotal instead.
deprecatedTransformerFailuresTotal = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "transformation_failures_total",
Help: "Total number of failed transformation operations.",
Help: "Deprecated, use transformerOperationsTotal instead. Total number of failed transformation operations.",
},
[]string{"transformation_type"},
)
@@ -84,20 +94,24 @@ var registerMetrics sync.Once
func RegisterMetrics() {
registerMetrics.Do(func() {
prometheus.MustRegister(transformerLatencies)
prometheus.MustRegister(transformerFailuresTotal)
prometheus.MustRegister(deprecatedTransformerFailuresTotal)
prometheus.MustRegister(envelopeTransformationCacheMissTotal)
prometheus.MustRegister(dataKeyGenerationLatencies)
prometheus.MustRegister(dataKeyGenerationFailuresTotal)
prometheus.MustRegister(transformerOperationsTotal)
})
}

// RecordTransformation records latencies and count of TransformFromStorage and TransformToStorage operations.
// Note that transformation_failures_total metric is deprecated, use transformation_operations_total instead.
func RecordTransformation(transformationType string, start time.Time, err error) {
if err != nil {
transformerFailuresTotal.WithLabelValues(transformationType).Inc()
deprecatedTransformerFailuresTotal.WithLabelValues(transformationType).Inc()
transformerOperationsTotal.WithLabelValues(transformationType, "failure").Inc()
return
}

transformerOperationsTotal.WithLabelValues(transformationType, "success").Inc()
since := sinceInMicroseconds(start)
transformerLatencies.WithLabelValues(transformationType).Observe(float64(since))
}

0 comments on commit 190c9e3

Please sign in to comment.
You can’t perform that action at this time.