Skip to content

Commit 0420d0b

Browse files
authored
initialize querier stats in QFE only if it is not enabled (#5142)
* initialize querier stats in QFE only if it is not already enabled Signed-off-by: Ben Ye <[email protected]> * fix lint Signed-off-by: Ben Ye <[email protected]> --------- Signed-off-by: Ben Ye <[email protected]>
1 parent 46b3b09 commit 0420d0b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pkg/frontend/transport/handler.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,13 @@ func (f *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
120120
// Initialise the stats in the context and make sure it's propagated
121121
// down the request chain.
122122
if f.cfg.QueryStatsEnabled {
123-
var ctx context.Context
124-
stats, ctx = querier_stats.ContextWithEmptyStats(r.Context())
125-
r = r.WithContext(ctx)
123+
// Check if querier stats is enabled in the context.
124+
stats = querier_stats.FromContext(r.Context())
125+
if stats == nil {
126+
var ctx context.Context
127+
stats, ctx = querier_stats.ContextWithEmptyStats(r.Context())
128+
r = r.WithContext(ctx)
129+
}
126130
}
127131

128132
defer func() {

0 commit comments

Comments
 (0)