mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-14 13:45:06 +00:00
Add NewLazyMetricWithTimestamp() API to stability framework.
This commit is contained in:
@@ -17,6 +17,8 @@ limitations under the License.
|
|||||||
package metrics
|
package metrics
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"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...)
|
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)
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user