@@ -26,12 +26,10 @@ import (
26
26
"k8s.io/client-go/rest"
27
27
"k8s.io/client-go/tools/clientcmd"
28
28
29
+ "github.com/project-codeflare/multi-cluster-app-dispatcher/cmd/kar-controllers/app/metrics"
29
30
"github.com/project-codeflare/multi-cluster-app-dispatcher/cmd/kar-controllers/app/options"
30
31
"github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/controller/queuejob"
31
32
"github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/health"
32
- "github.com/prometheus/client_golang/prometheus"
33
- "github.com/prometheus/client_golang/prometheus/collectors"
34
- "github.com/prometheus/client_golang/prometheus/promhttp"
35
33
36
34
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
37
35
@@ -40,8 +38,6 @@ import (
40
38
"github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/config"
41
39
)
42
40
43
- // Global Prometheus Registry
44
- var globalPromRegistry = prometheus .NewRegistry ()
45
41
46
42
func buildConfig (master , kubeconfig string ) (* rest.Config , error ) {
47
43
if master != "" || kubeconfig != "" {
@@ -87,20 +83,6 @@ func Run(ctx context.Context, opt *options.ServerOption) error {
87
83
return nil
88
84
}
89
85
90
- // metricsHandler returns a http.Handler that serves the prometheus metrics
91
- func prometheusHandler () http.Handler {
92
- // Add Go module build info.
93
- globalPromRegistry .MustRegister (collectors .NewBuildInfoCollector ())
94
- globalPromRegistry .MustRegister (collectors .NewGoCollector ())
95
- globalPromRegistry .MustRegister (collectors .NewProcessCollector (collectors.ProcessCollectorOpts {}))
96
-
97
- handlerOpts := promhttp.HandlerOpts {
98
- ErrorHandling : promhttp .HTTPErrorOnError ,
99
- }
100
-
101
- return promhttp .HandlerFor (globalPromRegistry , handlerOpts )
102
- }
103
-
104
86
func healthHandler () http.Handler {
105
87
healthHandler := http .NewServeMux ()
106
88
healthHandler .Handle ("/healthz" , & health.Handler {})
@@ -112,7 +94,7 @@ func startHealthAndMetricsServers(ctx context.Context, opt *options.ServerOption
112
94
g , ctx := errgroup .WithContext (ctx )
113
95
114
96
// metrics server
115
- metricsServer , err := NewServer (opt .MetricsListenPort , "/metrics" , prometheusHandler ())
97
+ metricsServer , err := NewServer (opt .MetricsListenPort , "/metrics" , metrics . PrometheusHandler ())
116
98
if err != nil {
117
99
return err
118
100
}
0 commit comments