mirror of
https://github.com/k3s-io/k3s.git
synced 2026-05-28 04:34:19 -04:00
16 lines
353 B
Go
16 lines
353 B
Go
package metrics
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
)
|
|
|
|
func ObserveWithStatus(vec *prometheus.HistogramVec, start time.Time, err error, labels ...string) {
|
|
status := "success"
|
|
if err != nil {
|
|
status = "error"
|
|
}
|
|
labels = append(labels, status)
|
|
vec.WithLabelValues(labels...).Observe(time.Since(start).Seconds())
|
|
}
|