mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #85446 from RainbowMango/pr_remove_RawRegister
Remove the derprecated API RawRegister from stability framework
This commit is contained in:
commit
c7a65ca0c3
@ -328,7 +328,7 @@ func (s *Server) InstallDefaultHandlers(enableCAdvisorJSONEndpoints bool) {
|
||||
// prober metrics are exposed under a different endpoint
|
||||
|
||||
p := compbasemetrics.NewKubeRegistry()
|
||||
compbasemetrics.RegisterProcessStartTime(p.RawRegister)
|
||||
_ = compbasemetrics.RegisterProcessStartTime(p.Register)
|
||||
p.MustRegister(prober.ProberResults)
|
||||
s.restfulCont.Handle(proberMetricsPath,
|
||||
compbasemetrics.HandlerFor(p, compbasemetrics.HandlerOpts{ErrorHandling: compbasemetrics.ContinueOnError}),
|
||||
|
@ -65,15 +65,6 @@ func RawMustRegister(cs ...prometheus.Collector) {
|
||||
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.
|
||||
func CustomRegister(c metrics.StableCollector) error {
|
||||
err := defaultRegistry.CustomRegister(c)
|
||||
|
@ -20,29 +20,24 @@ import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/procfs"
|
||||
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
var processStartTime = prometheus.NewGaugeVec(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "process_start_time_seconds",
|
||||
Help: "Start time of the process since unix epoch in seconds.",
|
||||
var processStartTime = NewGaugeVec(
|
||||
&GaugeOpts{
|
||||
Name: "process_start_time_seconds",
|
||||
Help: "Start time of the process since unix epoch in seconds.",
|
||||
StabilityLevel: ALPHA,
|
||||
},
|
||||
[]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
|
||||
// a prometheus registry. This metric needs to be included to ensure counter
|
||||
// data fidelity.
|
||||
func RegisterProcessStartTime(registrationFunc func(prometheus.Collector) error) error {
|
||||
func RegisterProcessStartTime(registrationFunc func(Registerable) error) error {
|
||||
start, err := getProcessStart()
|
||||
if err != nil {
|
||||
klog.Errorf("Could not get process start time, %v", err)
|
||||
|
@ -113,8 +113,6 @@ type Registerable interface {
|
||||
// KubeRegistry is an interface which implements a subset of prometheus.Registerer and
|
||||
// prometheus.Gatherer interfaces
|
||||
type KubeRegistry interface {
|
||||
// Deprecated
|
||||
RawRegister(prometheus.Collector) error
|
||||
// Deprecated
|
||||
RawMustRegister(...prometheus.Collector)
|
||||
CustomRegister(c StableCollector) error
|
||||
@ -193,15 +191,6 @@ func (kr *kubeRegistry) CustomMustRegister(cs ...StableCollector) {
|
||||
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
|
||||
// to the registry. This bypasses metrics safety checks, so should only be used
|
||||
// to register custom prometheus collectors.
|
||||
|
Loading…
Reference in New Issue
Block a user