mirror of https://github.com/k3s-io/k3s
Instrument transformer.go with latency metrics.
parent
e54864f53d
commit
04a6613fb5
|
@ -31,7 +31,7 @@ var (
|
||||||
TransformerOperationalLatencies = prometheus.NewSummaryVec(
|
TransformerOperationalLatencies = prometheus.NewSummaryVec(
|
||||||
prometheus.SummaryOpts{
|
prometheus.SummaryOpts{
|
||||||
Subsystem: valueSubsystem,
|
Subsystem: valueSubsystem,
|
||||||
Name: "storage_transformation_latency_microseconds",
|
Name: "apiserver_storage_transformation_latency_microseconds",
|
||||||
Help: "Latency in microseconds of value transformation operations.",
|
Help: "Latency in microseconds of value transformation operations.",
|
||||||
},
|
},
|
||||||
[]string{"transformation_type"},
|
[]string{"transformation_type"},
|
||||||
|
@ -47,9 +47,9 @@ func RegisterMetrics() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func RecordTransformation(transformationType string, start time.Time) {
|
func RecordTransformation(transformationType string, start time.Time) {
|
||||||
TransformerOperationalLatencies.WithLabelValues(transformationType).Observe(sinceInMicroseconds(start))
|
TransformerOperationalLatencies.WithLabelValues(transformationType).Observe(float64(sinceInMicroseconds(start)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func sinceInMicroseconds(start time.Time) float64 {
|
func sinceInMicroseconds(start time.Time) time.Duration {
|
||||||
return float64(time.Since(start).Nanoseconds() / time.Microsecond.Nanoseconds())
|
return time.Since(start) / time.Microsecond
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ const (
|
||||||
encryptionConfigFileName = "encryption.conf"
|
encryptionConfigFileName = "encryption.conf"
|
||||||
testNamespace = "secret-encryption-test"
|
testNamespace = "secret-encryption-test"
|
||||||
testSecret = "test-secret"
|
testSecret = "test-secret"
|
||||||
latencySummaryMetricsFamily = "value_storage_transformation_latency_microseconds"
|
latencySummaryMetricsFamily = "value_apiserver_storage_transformation_latency_microseconds"
|
||||||
)
|
)
|
||||||
|
|
||||||
type unSealSecret func(cipherText []byte, ctx value.Context, config encryptionconfig.ProviderConfig) ([]byte, error)
|
type unSealSecret func(cipherText []byte, ctx value.Context, config encryptionconfig.ProviderConfig) ([]byte, error)
|
||||||
|
@ -241,6 +241,7 @@ func (e *transformTest) readRawRecordFromETCD(path string) (*clientv3.GetRespons
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *transformTest) printMetrics() error {
|
func (e *transformTest) printMetrics() error {
|
||||||
|
e.logger.Logf("Transformation Metrics:")
|
||||||
metrics, err := prometheus.DefaultGatherer.Gather()
|
metrics, err := prometheus.DefaultGatherer.Gather()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to gather metrics: %s", err)
|
return fmt.Errorf("failed to gather metrics: %s", err)
|
||||||
|
|
Loading…
Reference in New Issue