File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -225,16 +225,27 @@ func (f *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
225225 r .Body = io .NopCloser (& buf )
226226 }
227227
228+ // Log request
229+ if f .cfg .QueryStatsEnabled {
230+ queryString = f .parseRequestQueryString (r , buf )
231+ logMessage := append ([]interface {}{
232+ "msg" , "query request" ,
233+ "component" , "query-frontend" ,
234+ "method" , r .Method ,
235+ "path" , r .URL .Path ,
236+ }, formatQueryString (queryString )... )
237+ level .Info (util_log .WithContext (r .Context (), f .log )).Log (logMessage ... )
238+ }
239+
228240 startTime := time .Now ()
229241 resp , err := f .roundTripper .RoundTrip (r )
230242 queryResponseTime := time .Since (startTime )
231243
232- // Check whether we should parse the query string.
244+ // Check if we need to parse the query string to avoid parsing twice .
233245 shouldReportSlowQuery := f .cfg .LogQueriesLongerThan != 0 && queryResponseTime > f .cfg .LogQueriesLongerThan
234- if shouldReportSlowQuery || f .cfg .QueryStatsEnabled {
246+ if shouldReportSlowQuery && ! f .cfg .QueryStatsEnabled {
235247 queryString = f .parseRequestQueryString (r , buf )
236248 }
237-
238249 if shouldReportSlowQuery {
239250 f .reportSlowQuery (r , queryString , queryResponseTime )
240251 }
You can’t perform that action at this time.
0 commit comments