Selaa lähdekoodia

Remove traces from healthchecks (#3226)

Stefan McShane 2 vuotta sitten
vanhempi
sitoutus
07a0b236df
1 muutettua tiedostoa jossa 12 lisäystä ja 2 poistoa
  1. 12 2
      api/server/router/router.go

+ 12 - 2
api/server/router/router.go

@@ -63,7 +63,12 @@ func NewAPIRouter(config *config.Config) *chi.Mux {
 
 	r.Route("/api", func(r chi.Router) {
 		r.Use(
-			otelchi.Middleware("porter-server-middleware", otelchi.WithRequestMethodInSpanName(true), otelchi.WithChiRoutes(r)),
+			otelchi.Middleware("porter-server-middleware", otelchi.WithRequestMethodInSpanName(true), otelchi.WithChiRoutes(r), otelchi.WithFilter(func(r *http.Request) bool {
+				if strings.HasSuffix(r.URL.Path, "/livez") || strings.HasSuffix(r.URL.Path, "/readyz") {
+					return false
+				}
+				return true
+			})),
 			panicMW.Middleware,
 			middleware.ContentTypeJSON,
 		)
@@ -112,7 +117,12 @@ func NewAPIRouter(config *config.Config) *chi.Mux {
 
 	r.Route("/api/v1", func(r chi.Router) {
 		r.Use(
-			otelchi.Middleware("porter-server-middleware", otelchi.WithRequestMethodInSpanName(true), otelchi.WithChiRoutes(r)),
+			otelchi.Middleware("porter-server-middleware", otelchi.WithRequestMethodInSpanName(true), otelchi.WithChiRoutes(r), otelchi.WithFilter(func(r *http.Request) bool {
+				if strings.HasSuffix(r.URL.Path, "/livez") || strings.HasSuffix(r.URL.Path, "/readyz") {
+					return false
+				}
+				return true
+			})),
 			panicMW.Middleware,
 			middleware.ContentTypeJSON,
 		)