diff --git a/pkg/query-service/app/server.go b/pkg/query-service/app/server.go index 77ab3fc9b9..b2fbe2df5a 100644 --- a/pkg/query-service/app/server.go +++ b/pkg/query-service/app/server.go @@ -242,8 +242,14 @@ func (s *Server) analyticsMiddleware(next http.Handler) http.Handler { func setTimeoutMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - ctx, cancel := context.WithTimeout(r.Context(), constants.ContextTimeout*time.Second) - defer cancel() + ctx := r.Context() + var cancel context.CancelFunc + // check if route is not excluded + url := r.URL.Path + if _, ok := constants.TimeoutExcludedRoutes[url]; !ok { + ctx, cancel = context.WithTimeout(r.Context(), constants.ContextTimeout*time.Second) + defer cancel() + } r = r.WithContext(ctx) next.ServeHTTP(w, r) diff --git a/pkg/query-service/constants/constants.go b/pkg/query-service/constants/constants.go index 8f590d81ba..e5e727de0b 100644 --- a/pkg/query-service/constants/constants.go +++ b/pkg/query-service/constants/constants.go @@ -81,6 +81,10 @@ const ( SIGNOZ_TIMESERIES_TABLENAME = "time_series_v2" ) +var TimeoutExcludedRoutes = map[string]bool{ + "/api/v1/logs/tail": true, +} + // alert related constants const ( // AlertHelpPage is used in case default alert repo url is not set