From b8cb3b9fe307f7567f179636e223f5d2c173e158 Mon Sep 17 00:00:00 2001 From: David Hontecillas Date: Thu, 25 Apr 2024 15:37:21 +0200 Subject: [PATCH 1/3] avoid instrumenting skip paths at the http layer --- http/server/server.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/http/server/server.go b/http/server/server.go index 0e0848f..8934c33 100644 --- a/http/server/server.go +++ b/http/server/server.go @@ -19,9 +19,15 @@ type trackingHandler struct { metrics *metricsHTTP traces *tracesHTTP reportHeaders bool + config *state.Config } func (h *trackingHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + if r.URL != nil && h.config.SkipEndpoint(r.URL.Path) { + h.next.ServeHTTP(rw, r) + return + } + t := newTracking() t.ctx = r.Context() if h.prop != nil { @@ -84,5 +90,6 @@ func NewTrackingHandler(next http.Handler) http.Handler { metrics: m, traces: t, reportHeaders: gCfg.ReportHeaders, + config: otelCfg, } } From 40af4a8b306fab03dc508ccc25dd458aed969ef4 Mon Sep 17 00:00:00 2001 From: David Hontecillas Date: Thu, 25 Apr 2024 16:56:04 +0200 Subject: [PATCH 2/3] fix: use Config as interface in http layer --- http/server/server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http/server/server.go b/http/server/server.go index 8934c33..767557d 100644 --- a/http/server/server.go +++ b/http/server/server.go @@ -19,7 +19,7 @@ type trackingHandler struct { metrics *metricsHTTP traces *tracesHTTP reportHeaders bool - config *state.Config + config state.Config } func (h *trackingHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request) { From bfd49a2adf1ca64941694a7a86ba998fe73380fb Mon Sep 17 00:00:00 2001 From: David Hontecillas Date: Thu, 25 Apr 2024 17:25:12 +0200 Subject: [PATCH 3/3] add script to test skip instrumentation in skip paths --- example/client/make_skip_paths_requests.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 example/client/make_skip_paths_requests.sh diff --git a/example/client/make_skip_paths_requests.sh b/example/client/make_skip_paths_requests.sh new file mode 100644 index 0000000..26c6162 --- /dev/null +++ b/example/client/make_skip_paths_requests.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +for i in {1..1000} +do + # curl localhost:54444/fake/fsf + # curl localhost:54444/combination/2 + echo -e "\n/__stats/" + curl localhost:54444/__stats/ + echo -e "\n/__health" + curl localhost:54444/__health + echo -e "\n/__echo/" + curl localhost:54444/__echo/ + # uncomment this to see real 404 not found error codes + # echo -e "\n/this_does_not_exist/" + # curl localhost:54444/this_does_not_exist/ + echo -e "\n----\n" + sleep 1 +done