mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Add NewLazyMetricWithTimestamp() API to stability framework.
This commit is contained in:
parent
1016b8b58a
commit
2f7c9fcd26
@ -17,6 +17,8 @@ limitations under the License.
|
||||
package metrics
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
@ -44,3 +46,15 @@ func NewLazyConstMetric(desc *Desc, valueType ValueType, value float64, labelVal
|
||||
}
|
||||
return prometheus.MustNewConstMetric(desc.toPrometheusDesc(), valueType.toPromValueType(), value, labelValues...)
|
||||
}
|
||||
|
||||
// NewLazyMetricWithTimestamp is a helper of NewMetricWithTimestamp.
|
||||
//
|
||||
// Warning: the Metric 'm' must be the one created by NewLazyConstMetric(),
|
||||
// otherwise, no stability guarantees would be offered.
|
||||
func NewLazyMetricWithTimestamp(t time.Time, m Metric) Metric {
|
||||
if m == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return prometheus.NewMetricWithTimestamp(t, m)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user