Skip to content

Commit

Permalink
Merge pull request #85446 from RainbowMango/pr_remove_RawRegister
Browse files Browse the repository at this point in the history
Remove the derprecated API RawRegister from stability framework
  • Loading branch information
k8s-ci-robot authored Dec 10, 2019
2 parents bbd48e9 + 214228f commit c7a65ca
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 32 deletions.
2 changes: 1 addition & 1 deletion pkg/kubelet/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 6 additions & 11 deletions staging/src/k8s.io/component-base/metrics/processstarttime.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 0 additions & 11 deletions staging/src/k8s.io/component-base/metrics/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit c7a65ca

Please sign in to comment.