From df5250425844f6e5c758ab3a4f6f31869863a4ae Mon Sep 17 00:00:00 2001 From: James Telfer <792299+jamestelfer@users.noreply.github.com> Date: Thu, 16 May 2024 23:07:50 +1000 Subject: [PATCH] fix: exclude healthcheck from telemetry --- main.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 59f9f8f..b1fec88 100644 --- a/main.go +++ b/main.go @@ -24,7 +24,8 @@ import ( func configureServerRoutes(cfg config.Config) (http.Handler, error) { // wrap a mux such that HTTP telemetry is configured by default - mux := observe.NewMux(http.NewServeMux()) + muxWithoutTelemetry := http.NewServeMux() + mux := observe.NewMux(muxWithoutTelemetry) // configure middleware authorizer, err := jwt.Middleware(cfg.Authorization, jwtmiddleware.WithErrorHandler(jwt.LogErrorHandler())) @@ -58,7 +59,9 @@ func configureServerRoutes(cfg config.Config) (http.Handler, error) { mux.Handle("POST /token", authorized.Then(handlePostToken(tokenVendor))) mux.Handle("POST /git-credentials", authorized.Then(handlePostGitCredentials(tokenVendor))) - mux.Handle("GET /healthcheck", handleHealthCheck()) + + // healthchecks are not included in telemetry + muxWithoutTelemetry.Handle("GET /healthcheck", handleHealthCheck()) return mux, nil } @@ -138,7 +141,6 @@ func logBuildInfo() { } ev := log.Info() for _, v := range buildInfo.Settings { - if strings.HasPrefix(v.Key, "vcs.") || strings.HasPrefix(v.Key, "GO") || v.Key == "CGO_ENABLED" {