From ef88c70d39a040ec764ae626371104d9935d7cc4 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Thu, 5 Nov 2020 14:32:54 +0100 Subject: [PATCH 1/3] tracing: exclude liveness and readiness checks --- tracing/inbound_http.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tracing/inbound_http.go b/tracing/inbound_http.go index 9ff9490..e00cea3 100644 --- a/tracing/inbound_http.go +++ b/tracing/inbound_http.go @@ -19,6 +19,11 @@ func Handler(h http.Handler, opts ...HandlerOption) http.Handler { return } + if r.URL.Path == "/-/liveness" || r.URL.Path == "/-/readiness" { + h.ServeHTTP(w, r) + return + } + wireContext, _ := tracer.Extract( opentracing.HTTPHeaders, opentracing.HTTPHeadersCarrier(r.Header)) -- GitLab From 7dcdc14d0b95c26ba2ad7fdc7ec3a3641fc3d5f2 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Thu, 19 Nov 2020 11:59:31 +0100 Subject: [PATCH 2/3] extract health check and move logic up --- tracing/inbound_http.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tracing/inbound_http.go b/tracing/inbound_http.go index e00cea3..a2f4744 100644 --- a/tracing/inbound_http.go +++ b/tracing/inbound_http.go @@ -13,13 +13,13 @@ func Handler(h http.Handler, opts ...HandlerOption) http.Handler { config := applyHandlerOptions(opts) return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - tracer := opentracing.GlobalTracer() - if tracer == nil { + if isHealthCheck(r) { h.ServeHTTP(w, r) return } - if r.URL.Path == "/-/liveness" || r.URL.Path == "/-/readiness" { + tracer := opentracing.GlobalTracer() + if tracer == nil { h.ServeHTTP(w, r) return } @@ -52,3 +52,7 @@ func Handler(h http.Handler, opts ...HandlerOption) http.Handler { h.ServeHTTP(w, r.WithContext(ctx)) }) } + +func isHealthCheck(r *http.Request) bool { + return r.URL.Path == "/-/liveness" || r.URL.Path == "/-/readiness" +} -- GitLab From 3ac2630f9b2886a5e24462ccbb55014f1cb2d506 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Thu, 19 Nov 2020 12:17:41 +0100 Subject: [PATCH 3/3] godot lint --- tracing/grpc/healthcheck_filter.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tracing/grpc/healthcheck_filter.go b/tracing/grpc/healthcheck_filter.go index 04fac10..f365009 100644 --- a/tracing/grpc/healthcheck_filter.go +++ b/tracing/grpc/healthcheck_filter.go @@ -2,12 +2,12 @@ package grpccorrelation import "context" -// grpcHealthCheckMethodFullName is the name of the standard GRPC health check full method name +// grpcHealthCheckMethodFullName is the name of the standard GRPC health check full method name. const grpcHealthCheckMethodFullName = "/grpc.health.v1.Health/Check" // healthCheckFilterFunc will exclude all GRPC health checks from tracing // since these calls are high frequency, but low value from a tracing point -// of view, excluding them reduces the tracing load +// of view, excluding them reduces the tracing load. func healthCheckFilterFunc(_ context.Context, fullMethodName string) bool { return fullMethodName != grpcHealthCheckMethodFullName } -- GitLab