Skip to content

Commit

Permalink
Signed-off-by: fengzixu <[email protected]>
Browse files Browse the repository at this point in the history
feature: modify the function name about prometheus registry

1. change function name `GetCustomPrometheusRegistry` to `GetPrometheusRegistry`

Related to: #2429
  • Loading branch information
fengzixu committed Nov 6, 2018
1 parent bc76c24 commit c1e9086
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
4 changes: 2 additions & 2 deletions apis/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ var registerMetrics sync.Once

// Register all metrics.
func Register() {
// Get a custom prometheus registry.
registry := util_metrics.GetCustomPrometheusRegistry()
// Get a prometheus registry.
registry := util_metrics.GetPrometheusRegistry()
registerMetrics.Do(func() {
// Register the custom metrics.
registry.MustRegister(ImagePullSummary)
Expand Down
4 changes: 2 additions & 2 deletions cri/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ var registerMetrics sync.Once

// Register all metrics.
func Register() {
// Get a custom prometheus registry.
registry := util_metrics.GetCustomPrometheusRegistry()
// Get a prometheus registry.
registry := util_metrics.GetPrometheusRegistry()
registerMetrics.Do(func() {
// Register the custom metrics.
registry.MustRegister(PodActionsCounter)
Expand Down
21 changes: 10 additions & 11 deletions pkg/utils/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@ const (
namespace = "engine"
)

// CustomPrometheusRegistry creates a custom prometheus registry.
var (
customPrometheusRegistry *prometheus.Registry
prometheusHandler http.Handler
registerMetrics sync.Once
prometheusRegistry *prometheus.Registry
prometheusHandler http.Handler
registerMetrics sync.Once
)

func init() {
customPrometheusRegistry = prometheus.NewRegistry()
prometheusHandler = promhttp.HandlerFor(customPrometheusRegistry, promhttp.HandlerOpts{})
registerDefaultMetrics(customPrometheusRegistry)
prometheusRegistry = prometheus.NewRegistry()
prometheusHandler = promhttp.HandlerFor(prometheusRegistry, promhttp.HandlerOpts{})
registerDefaultMetrics(prometheusRegistry)
}

// SinceInMicroseconds gets the time since the specified start in microseconds.
Expand Down Expand Up @@ -81,9 +80,9 @@ func NewLabelTimer(subsystem, name, help string, labels ...string) *prometheus.H
}, labels)
}

// GetCustomPrometheusRegistry create a custom resigtry of Prometheus.
func GetCustomPrometheusRegistry() *prometheus.Registry {
return customPrometheusRegistry
// GetPrometheusRegistry return a resigtry of Prometheus.
func GetPrometheusRegistry() *prometheus.Registry {
return prometheusRegistry
}

// GetPrometheusHandler return the prometheus handler.
Expand All @@ -92,7 +91,7 @@ func GetPrometheusHandler() http.Handler {
}

func registerDefaultMetrics(registry *prometheus.Registry) {
//Register the default metrics to the custom registry in prometheus.
//Register the default metrics to the registry in prometheus.
registerMetrics.Do(func() {
registry.MustRegister(prometheus.NewProcessCollector(os.Getpid(), ""))
registry.MustRegister(prometheus.NewGoCollector())
Expand Down

0 comments on commit c1e9086

Please sign in to comment.