mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Remove the derprecated API RawRegister from stability framework
This commit is contained in:
parent
81af5baff8
commit
214228f024
@ -328,7 +328,7 @@ func (s *Server) InstallDefaultHandlers(enableCAdvisorJSONEndpoints bool) {
|
|||||||
// prober metrics are exposed under a different endpoint
|
// prober metrics are exposed under a different endpoint
|
||||||
|
|
||||||
p := compbasemetrics.NewKubeRegistry()
|
p := compbasemetrics.NewKubeRegistry()
|
||||||
compbasemetrics.RegisterProcessStartTime(p.RawRegister)
|
_ = compbasemetrics.RegisterProcessStartTime(p.Register)
|
||||||
p.MustRegister(prober.ProberResults)
|
p.MustRegister(prober.ProberResults)
|
||||||
s.restfulCont.Handle(proberMetricsPath,
|
s.restfulCont.Handle(proberMetricsPath,
|
||||||
compbasemetrics.HandlerFor(p, compbasemetrics.HandlerOpts{ErrorHandling: compbasemetrics.ContinueOnError}),
|
compbasemetrics.HandlerFor(p, compbasemetrics.HandlerOpts{ErrorHandling: compbasemetrics.ContinueOnError}),
|
||||||
|
@ -65,15 +65,6 @@ func RawMustRegister(cs ...prometheus.Collector) {
|
|||||||
defaultRegistry.RawMustRegister(cs...)
|
defaultRegistry.RawMustRegister(cs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RawRegister registers a prometheus collector but uses the global registry, this
|
|
||||||
// bypasses the metric stability framework
|
|
||||||
//
|
|
||||||
// Deprecated
|
|
||||||
func RawRegister(c prometheus.Collector) error {
|
|
||||||
err := defaultRegistry.RawRegister(c)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// CustomRegister registers a custom collector but uses the global registry.
|
// CustomRegister registers a custom collector but uses the global registry.
|
||||||
func CustomRegister(c metrics.StableCollector) error {
|
func CustomRegister(c metrics.StableCollector) error {
|
||||||
err := defaultRegistry.CustomRegister(c)
|
err := defaultRegistry.CustomRegister(c)
|
||||||
|
@ -20,29 +20,24 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
|
||||||
"github.com/prometheus/procfs"
|
"github.com/prometheus/procfs"
|
||||||
|
|
||||||
"k8s.io/klog"
|
"k8s.io/klog"
|
||||||
)
|
)
|
||||||
|
|
||||||
var processStartTime = prometheus.NewGaugeVec(
|
var processStartTime = NewGaugeVec(
|
||||||
prometheus.GaugeOpts{
|
&GaugeOpts{
|
||||||
Name: "process_start_time_seconds",
|
Name: "process_start_time_seconds",
|
||||||
Help: "Start time of the process since unix epoch in seconds.",
|
Help: "Start time of the process since unix epoch in seconds.",
|
||||||
|
StabilityLevel: ALPHA,
|
||||||
},
|
},
|
||||||
[]string{},
|
[]string{},
|
||||||
)
|
)
|
||||||
|
|
||||||
// Registerer is an interface expected by RegisterProcessStartTime in order to register the metric
|
|
||||||
type Registerer interface {
|
|
||||||
Register(prometheus.Collector) error
|
|
||||||
}
|
|
||||||
|
|
||||||
// RegisterProcessStartTime registers the process_start_time_seconds to
|
// RegisterProcessStartTime registers the process_start_time_seconds to
|
||||||
// a prometheus registry. This metric needs to be included to ensure counter
|
// a prometheus registry. This metric needs to be included to ensure counter
|
||||||
// data fidelity.
|
// data fidelity.
|
||||||
func RegisterProcessStartTime(registrationFunc func(prometheus.Collector) error) error {
|
func RegisterProcessStartTime(registrationFunc func(Registerable) error) error {
|
||||||
start, err := getProcessStart()
|
start, err := getProcessStart()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("Could not get process start time, %v", err)
|
klog.Errorf("Could not get process start time, %v", err)
|
||||||
|
@ -97,8 +97,6 @@ type Registerable interface {
|
|||||||
// KubeRegistry is an interface which implements a subset of prometheus.Registerer and
|
// KubeRegistry is an interface which implements a subset of prometheus.Registerer and
|
||||||
// prometheus.Gatherer interfaces
|
// prometheus.Gatherer interfaces
|
||||||
type KubeRegistry interface {
|
type KubeRegistry interface {
|
||||||
// Deprecated
|
|
||||||
RawRegister(prometheus.Collector) error
|
|
||||||
// Deprecated
|
// Deprecated
|
||||||
RawMustRegister(...prometheus.Collector)
|
RawMustRegister(...prometheus.Collector)
|
||||||
CustomRegister(c StableCollector) error
|
CustomRegister(c StableCollector) error
|
||||||
@ -165,15 +163,6 @@ func (kr *kubeRegistry) CustomMustRegister(cs ...StableCollector) {
|
|||||||
kr.PromRegistry.MustRegister(collectors...)
|
kr.PromRegistry.MustRegister(collectors...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RawRegister takes a native prometheus.Collector and registers the collector
|
|
||||||
// to the registry. This bypasses metrics safety checks, so should only be used
|
|
||||||
// to register custom prometheus collectors.
|
|
||||||
//
|
|
||||||
// Deprecated
|
|
||||||
func (kr *kubeRegistry) RawRegister(c prometheus.Collector) error {
|
|
||||||
return kr.PromRegistry.Register(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
// RawMustRegister takes a native prometheus.Collector and registers the collector
|
// RawMustRegister takes a native prometheus.Collector and registers the collector
|
||||||
// to the registry. This bypasses metrics safety checks, so should only be used
|
// to the registry. This bypasses metrics safety checks, so should only be used
|
||||||
// to register custom prometheus collectors.
|
// to register custom prometheus collectors.
|
||||||
|
Loading…
Reference in New Issue
Block a user