live tail api excluded from timeout middleware

This commit is contained in:
nityanandagohain 2022-07-21 17:55:08 +05:30
parent 5912d3a4a0
commit 2132d1059c
2 changed files with 12 additions and 2 deletions

View File

@ -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)

View File

@ -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