diff --git a/tracing/grpc/healthcheck_filter.go b/tracing/grpc/healthcheck_filter.go index 04fac10109dde87f9f4e80c20ae3ab7f19d4cc90..f365009c79c69e135912411bf943069d21046ede 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 } diff --git a/tracing/inbound_http.go b/tracing/inbound_http.go index 9ff9490721ad63ee998ff665726a3e5081a815b4..a2f47443097972ac9b4c63363a5ffc697676d4cf 100644 --- a/tracing/inbound_http.go +++ b/tracing/inbound_http.go @@ -13,6 +13,11 @@ func Handler(h http.Handler, opts ...HandlerOption) http.Handler { config := applyHandlerOptions(opts) return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if isHealthCheck(r) { + h.ServeHTTP(w, r) + return + } + tracer := opentracing.GlobalTracer() if tracer == nil { h.ServeHTTP(w, r) @@ -47,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" +}