feat: add new telemetry server (#254)

Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
This commit is contained in:
Márk Sági-Kazár
2020-12-18 09:01:19 +01:00
committed by GitHub
parent 65e6d5475f
commit 6d895843dc
5 changed files with 128 additions and 8 deletions

32
telemetry/router.go Normal file
View File

@@ -0,0 +1,32 @@
package telemetry
import (
"net/http"
"github.com/go-chi/chi"
"github.com/go-chi/chi/middleware"
"github.com/go-chi/render"
"github.com/drakkan/sftpgo/logger"
"github.com/drakkan/sftpgo/metrics"
)
func initializeRouter(enableProfiler bool) {
router = chi.NewRouter()
router.Use(middleware.Recoverer)
router.Group(func(r chi.Router) {
r.Get("/healthz", func(w http.ResponseWriter, r *http.Request) {
render.PlainText(w, r, "ok")
})
})
metrics.AddMetricsEndpoint(metricsPath, router)
if enableProfiler {
logger.InfoToConsole("enabling the built-in profiler")
logger.Info(logSender, "", "enabling the built-in profiler")
router.Mount(pprofBasePath, middleware.Profiler())
}
}