diff --git a/pkg/shell-operator/bootstrap.go b/pkg/shell-operator/bootstrap.go index 98d232ae..0ff6ea46 100644 --- a/pkg/shell-operator/bootstrap.go +++ b/pkg/shell-operator/bootstrap.go @@ -111,7 +111,9 @@ func (op *ShellOperator) AssembleCommonOperator(listenAddress, listenPort string // - kubernetes events manager // - schedule manager func (op *ShellOperator) assembleShellOperator(hooksDir string, tempDir string, debugServer *debug.Server, runtimeConfig *config.Config) (err error) { - registerDefaultRoutes(op) + registerRootRoute(op) + // for shell-operator only + registerHookMetrics(op.HookMetricStorage) op.RegisterDebugQueueRoutes(debugServer) op.RegisterDebugHookRoutes(debugServer) diff --git a/pkg/shell-operator/http_server.go b/pkg/shell-operator/http_server.go index 529279c2..2d145fad 100644 --- a/pkg/shell-operator/http_server.go +++ b/pkg/shell-operator/http_server.go @@ -109,7 +109,7 @@ func newBaseHTTPServer(address, port string) *baseHTTPServer { return srv } -func registerDefaultRoutes(op *ShellOperator) { +func registerRootRoute(op *ShellOperator) { op.APIServer.RegisterRoute(http.MethodGet, "/", func(writer http.ResponseWriter, request *http.Request) { _, _ = fmt.Fprintf(writer, ` Shell operator @@ -125,10 +125,4 @@ func registerDefaultRoutes(op *ShellOperator) { `, app.ListenPort) }) - - op.APIServer.RegisterRoute(http.MethodGet, "/metrics", func(writer http.ResponseWriter, request *http.Request) { - if op.MetricStorage != nil { - op.MetricStorage.Handler().ServeHTTP(writer, request) - } - }) } diff --git a/pkg/shell-operator/metrics_hooks.go b/pkg/shell-operator/metrics_hooks.go index 3c2754bb..b0af5c19 100644 --- a/pkg/shell-operator/metrics_hooks.go +++ b/pkg/shell-operator/metrics_hooks.go @@ -10,15 +10,13 @@ import ( func (op *ShellOperator) setupHookMetricStorage() { metricStorage := metric_storage.NewMetricStorage(op.ctx, app.PrometheusMetricsPrefix, true) - registerHookMetrics(metricStorage) - op.APIServer.RegisterRoute(http.MethodGet, "/metrics/hooks", metricStorage.Handler().ServeHTTP) // create new metric storage for hooks // register scrape handler op.HookMetricStorage = metricStorage } -// specific metrics for HookManager +// specific metrics for shell-operator HookManager func registerHookMetrics(metricStorage *metric_storage.MetricStorage) { // Metrics for enable kubernetes bindings. metricStorage.RegisterGauge("{PREFIX}hook_enable_kubernetes_bindings_seconds", map[string]string{"hook": ""})