@@ -38,7 +38,6 @@ import (
3838type queryFrontendTestConfig struct {
3939 testMissingMetricName bool
4040 querySchedulerEnabled bool
41- queryStatsEnabled bool
4241 remoteReadEnabled bool
4342 testSubQueryStepSize bool
4443 setup func (t * testing.T , s * e2e.Scenario ) (configFile string , flags map [string ]string )
@@ -61,7 +60,6 @@ func TestQueryFrontendWithBlocksStorageViaFlags(t *testing.T) {
6160func TestQueryFrontendWithBlocksStorageViaFlagsAndQueryStatsEnabled (t * testing.T ) {
6261 runQueryFrontendTest (t , queryFrontendTestConfig {
6362 testMissingMetricName : false ,
64- queryStatsEnabled : true ,
6563 setup : func (t * testing.T , s * e2e.Scenario ) (configFile string , flags map [string ]string ) {
6664 flags = BlocksStorageFlags ()
6765
@@ -92,7 +90,6 @@ func TestQueryFrontendWithBlocksStorageViaFlagsAndWithQuerySchedulerAndQueryStat
9290 runQueryFrontendTest (t , queryFrontendTestConfig {
9391 testMissingMetricName : false ,
9492 querySchedulerEnabled : true ,
95- queryStatsEnabled : true ,
9693 setup : func (t * testing.T , s * e2e.Scenario ) (configFile string , flags map [string ]string ) {
9794 flags = BlocksStorageFlags ()
9895
@@ -168,7 +165,6 @@ func TestQueryFrontendWithVerticalSharding(t *testing.T) {
168165 runQueryFrontendTest (t , queryFrontendTestConfig {
169166 testMissingMetricName : false ,
170167 querySchedulerEnabled : false ,
171- queryStatsEnabled : true ,
172168 setup : func (t * testing.T , s * e2e.Scenario ) (configFile string , flags map [string ]string ) {
173169 require .NoError (t , writeFileToSharedDir (s , cortexConfigFile , []byte (BlocksStorageConfig )))
174170
@@ -188,7 +184,6 @@ func TestQueryFrontendWithVerticalShardingQueryScheduler(t *testing.T) {
188184 runQueryFrontendTest (t , queryFrontendTestConfig {
189185 testMissingMetricName : false ,
190186 querySchedulerEnabled : true ,
191- queryStatsEnabled : true ,
192187 setup : func (t * testing.T , s * e2e.Scenario ) (configFile string , flags map [string ]string ) {
193188 require .NoError (t , writeFileToSharedDir (s , cortexConfigFile , []byte (BlocksStorageConfig )))
194189
@@ -208,7 +203,6 @@ func TestQueryFrontendProtobufCodec(t *testing.T) {
208203 runQueryFrontendTest (t , queryFrontendTestConfig {
209204 testMissingMetricName : false ,
210205 querySchedulerEnabled : true ,
211- queryStatsEnabled : true ,
212206 setup : func (t * testing.T , s * e2e.Scenario ) (configFile string , flags map [string ]string ) {
213207 require .NoError (t , writeFileToSharedDir (s , cortexConfigFile , []byte (BlocksStorageConfig )))
214208
@@ -228,7 +222,6 @@ func TestQuerierToQueryFrontendCompression(t *testing.T) {
228222 runQueryFrontendTest (t , queryFrontendTestConfig {
229223 testMissingMetricName : false ,
230224 querySchedulerEnabled : true ,
231- queryStatsEnabled : true ,
232225 setup : func (t * testing.T , s * e2e.Scenario ) (configFile string , flags map [string ]string ) {
233226 require .NoError (t , writeFileToSharedDir (s , cortexConfigFile , []byte (BlocksStorageConfig )))
234227
@@ -294,7 +287,7 @@ func runQueryFrontendTest(t *testing.T, cfg queryFrontendTestConfig) {
294287 "-querier.split-queries-by-interval" : "24h" ,
295288 "-querier.query-ingesters-within" : "12h" , // Required by the test on query /series out of ingesters time range
296289 "-frontend.memcached.addresses" : "dns+" + memcached .NetworkEndpoint (e2ecache .MemcachedPort ),
297- "-frontend.query-stats-enabled" : strconv . FormatBool ( cfg . queryStatsEnabled ),
290+ "-frontend.query-stats-enabled" : "true" , // Always enable query stats to capture regressions
298291 })
299292
300293 // Start the query-scheduler if enabled.
@@ -382,7 +375,7 @@ func runQueryFrontendTest(t *testing.T, cfg queryFrontendTestConfig) {
382375 }
383376
384377 // No need to repeat the test on Server-Timing header for each user.
385- if userID == 0 && cfg . queryStatsEnabled {
378+ if userID == 0 {
386379 res , _ , err := c .QueryRaw ("{instance=~\" hello.*\" }" , time .Now (), map [string ]string {})
387380 require .NoError (t , err )
388381 require .Regexp (t , "querier_wall_time;dur=[0-9.]*, response_time;dur=[0-9.]*$" , res .Header .Values ("Server-Timing" )[0 ])
@@ -433,15 +426,11 @@ func runQueryFrontendTest(t *testing.T, cfg queryFrontendTestConfig) {
433426
434427 wg .Wait ()
435428
436- extra := float64 (2 )
429+ extra := float64 (3 ) // Always include query stats test
437430 if cfg .testMissingMetricName {
438431 extra ++
439432 }
440433
441- if cfg .queryStatsEnabled {
442- extra ++
443- }
444-
445434 if cfg .remoteReadEnabled {
446435 extra ++
447436 }
@@ -458,15 +447,11 @@ func runQueryFrontendTest(t *testing.T, cfg queryFrontendTestConfig) {
458447 require .NoError (t , querier .WaitSumMetricsWithOptions (e2e .Greater (numUsers * numQueriesPerUser ), []string {"cortex_request_duration_seconds" }, e2e .WithMetricCount ))
459448 require .NoError (t , querier .WaitSumMetricsWithOptions (e2e .Greater (numUsers * numQueriesPerUser ), []string {"cortex_querier_request_duration_seconds" }, e2e .WithMetricCount ))
460449
461- // Ensure query stats metrics are tracked only when enabled.
462- if cfg .queryStatsEnabled {
463- require .NoError (t , queryFrontend .WaitSumMetricsWithOptions (
464- e2e .Greater (0 ),
465- []string {"cortex_query_seconds_total" },
466- e2e .WithLabelMatchers (labels .MustNewMatcher (labels .MatchEqual , "user" , "user-1" ))))
467- } else {
468- require .NoError (t , queryFrontend .WaitRemovedMetric ("cortex_query_seconds_total" ))
469- }
450+ // Ensure query stats metrics are always tracked to capture regressions.
451+ require .NoError (t , queryFrontend .WaitSumMetricsWithOptions (
452+ e2e .Greater (0 ),
453+ []string {"cortex_query_seconds_total" },
454+ e2e .WithLabelMatchers (labels .MustNewMatcher (labels .MatchEqual , "user" , "user-1" ))))
470455
471456 // Ensure no service-specific metrics prefix is used by the wrong service.
472457 assertServiceMetricsPrefixes (t , Distributor , distributor )
0 commit comments