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: AliyunContainerService#2429
  • Loading branch information
fengzixu committed Nov 6, 2018
1 parent bc76c24 commit 78e89a2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 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
19 changes: 9 additions & 10 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 create a custom resigtry of Prometheus.
func GetPrometheusRegistry() *prometheus.Registry {
return prometheusRegistry
}

// GetPrometheusHandler return the prometheus handler.
Expand Down

0 comments on commit 78e89a2

Please sign in to comment.