Skip to content

Commit

Permalink
+++
Browse files Browse the repository at this point in the history
  • Loading branch information
yalosev committed Oct 30, 2023
1 parent 959a35b commit 92fc9c4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
4 changes: 3 additions & 1 deletion pkg/shell-operator/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 1 addition & 7 deletions pkg/shell-operator/http_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, `<html>
<head><title>Shell operator</title></head>
Expand All @@ -125,10 +125,4 @@ func registerDefaultRoutes(op *ShellOperator) {
</body>
</html>`, 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)
}
})
}
4 changes: 1 addition & 3 deletions pkg/shell-operator/metrics_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": ""})
Expand Down

0 comments on commit 92fc9c4

Please sign in to comment.