Skip to content

Commit

Permalink
fix: exclude healthcheck from telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
jamestelfer committed May 16, 2024
1 parent e4df38d commit df52504
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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" {
Expand Down

0 comments on commit df52504

Please sign in to comment.