[release-12.3.1] Tracing: Fix excluding paths from tracing (#115399)
Tracing: Fix excluding paths from tracing (#115394)
fix: not tracing paths correctly
(cherry picked from commit 7913b20cca)
Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com>
This commit is contained in:
co-authored by
Levente Balogh
parent
e8f080d471
commit
0d1a5b4420
@@ -623,7 +623,7 @@ func (hs *HTTPServer) addMiddlewaresAndStaticRoutes() {
|
||||
m := hs.web
|
||||
|
||||
m.Use(requestmeta.SetupRequestMetadata())
|
||||
m.Use(middleware.RequestTracing(hs.tracer, middleware.SkipTracingPaths))
|
||||
m.Use(middleware.RequestTracing(hs.tracer, middleware.ShouldTraceWithExceptions))
|
||||
m.Use(middleware.RequestMetrics(hs.Features, hs.Cfg, hs.promRegister))
|
||||
|
||||
m.UseMiddleware(hs.LoggerMiddleware.Middleware())
|
||||
|
||||
@@ -73,16 +73,20 @@ func RouteOperationName(req *http.Request) (string, bool) {
|
||||
return "", false
|
||||
}
|
||||
|
||||
// Paths that don't need tracing spans applied to them because of the
|
||||
// little value that would provide us
|
||||
func SkipTracingPaths(req *http.Request) bool {
|
||||
return strings.HasPrefix(req.URL.Path, "/public/") ||
|
||||
func ShouldTraceWithExceptions(req *http.Request) bool {
|
||||
// Paths that don't need tracing spans applied to them because of the
|
||||
// little value that would provide us
|
||||
if strings.HasPrefix(req.URL.Path, "/public/") ||
|
||||
req.URL.Path == "/robots.txt" ||
|
||||
req.URL.Path == "/favicon.ico" ||
|
||||
req.URL.Path == "/api/health"
|
||||
req.URL.Path == "/api/health" {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func TraceAllPaths(req *http.Request) bool {
|
||||
func ShouldTraceAllPaths(req *http.Request) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ func (s *frontendService) addMiddlewares(m *web.Mux) {
|
||||
loggermiddleware := loggermw.Provide(s.cfg, s.features)
|
||||
|
||||
m.Use(requestmeta.SetupRequestMetadata())
|
||||
m.Use(middleware.RequestTracing(s.tracer, middleware.TraceAllPaths))
|
||||
m.Use(middleware.RequestTracing(s.tracer, middleware.ShouldTraceAllPaths))
|
||||
m.Use(middleware.RequestMetrics(s.features, s.cfg, s.promRegister))
|
||||
|
||||
m.UseMiddleware(s.contextMiddleware())
|
||||
|
||||
Reference in New Issue
Block a user