@@ -37,7 +37,6 @@ import (
37
37
type queryFrontendTestConfig struct {
38
38
testMissingMetricName bool
39
39
querySchedulerEnabled bool
40
- queryStatsEnabled bool
41
40
remoteReadEnabled bool
42
41
testSubQueryStepSize bool
43
42
setup func (t * testing.T , s * e2e.Scenario ) (configFile string , flags map [string ]string )
@@ -60,7 +59,6 @@ func TestQueryFrontendWithBlocksStorageViaFlags(t *testing.T) {
60
59
func TestQueryFrontendWithBlocksStorageViaFlagsAndQueryStatsEnabled (t * testing.T ) {
61
60
runQueryFrontendTest (t , queryFrontendTestConfig {
62
61
testMissingMetricName : false ,
63
- queryStatsEnabled : true ,
64
62
setup : func (t * testing.T , s * e2e.Scenario ) (configFile string , flags map [string ]string ) {
65
63
flags = BlocksStorageFlags ()
66
64
@@ -91,7 +89,6 @@ func TestQueryFrontendWithBlocksStorageViaFlagsAndWithQuerySchedulerAndQueryStat
91
89
runQueryFrontendTest (t , queryFrontendTestConfig {
92
90
testMissingMetricName : false ,
93
91
querySchedulerEnabled : true ,
94
- queryStatsEnabled : true ,
95
92
setup : func (t * testing.T , s * e2e.Scenario ) (configFile string , flags map [string ]string ) {
96
93
flags = BlocksStorageFlags ()
97
94
@@ -167,7 +164,6 @@ func TestQueryFrontendWithVerticalSharding(t *testing.T) {
167
164
runQueryFrontendTest (t , queryFrontendTestConfig {
168
165
testMissingMetricName : false ,
169
166
querySchedulerEnabled : false ,
170
- queryStatsEnabled : true ,
171
167
setup : func (t * testing.T , s * e2e.Scenario ) (configFile string , flags map [string ]string ) {
172
168
require .NoError (t , writeFileToSharedDir (s , cortexConfigFile , []byte (BlocksStorageConfig )))
173
169
@@ -187,7 +183,6 @@ func TestQueryFrontendWithVerticalShardingQueryScheduler(t *testing.T) {
187
183
runQueryFrontendTest (t , queryFrontendTestConfig {
188
184
testMissingMetricName : false ,
189
185
querySchedulerEnabled : true ,
190
- queryStatsEnabled : true ,
191
186
setup : func (t * testing.T , s * e2e.Scenario ) (configFile string , flags map [string ]string ) {
192
187
require .NoError (t , writeFileToSharedDir (s , cortexConfigFile , []byte (BlocksStorageConfig )))
193
188
@@ -207,7 +202,6 @@ func TestQueryFrontendProtobufCodec(t *testing.T) {
207
202
runQueryFrontendTest (t , queryFrontendTestConfig {
208
203
testMissingMetricName : false ,
209
204
querySchedulerEnabled : true ,
210
- queryStatsEnabled : true ,
211
205
setup : func (t * testing.T , s * e2e.Scenario ) (configFile string , flags map [string ]string ) {
212
206
require .NoError (t , writeFileToSharedDir (s , cortexConfigFile , []byte (BlocksStorageConfig )))
213
207
@@ -273,7 +267,7 @@ func runQueryFrontendTest(t *testing.T, cfg queryFrontendTestConfig) {
273
267
"-querier.split-queries-by-interval" : "24h" ,
274
268
"-querier.query-ingesters-within" : "12h" , // Required by the test on query /series out of ingesters time range
275
269
"-frontend.memcached.addresses" : "dns+" + memcached .NetworkEndpoint (e2ecache .MemcachedPort ),
276
- "-frontend.query-stats-enabled" : strconv . FormatBool ( cfg . queryStatsEnabled ),
270
+ "-frontend.query-stats-enabled" : "true" , // Always enable query stats to capture regressions
277
271
})
278
272
279
273
// Start the query-scheduler if enabled.
@@ -361,7 +355,7 @@ func runQueryFrontendTest(t *testing.T, cfg queryFrontendTestConfig) {
361
355
}
362
356
363
357
// No need to repeat the test on Server-Timing header for each user.
364
- if userID == 0 && cfg . queryStatsEnabled {
358
+ if userID == 0 {
365
359
res , _ , err := c .QueryRaw ("{instance=~\" hello.*\" }" , time .Now (), map [string ]string {})
366
360
require .NoError (t , err )
367
361
require .Regexp (t , "querier_wall_time;dur=[0-9.]*, response_time;dur=[0-9.]*$" , res .Header .Values ("Server-Timing" )[0 ])
@@ -412,15 +406,11 @@ func runQueryFrontendTest(t *testing.T, cfg queryFrontendTestConfig) {
412
406
413
407
wg .Wait ()
414
408
415
- extra := float64 (2 )
409
+ extra := float64 (3 ) // Always include query stats test
416
410
if cfg .testMissingMetricName {
417
411
extra ++
418
412
}
419
413
420
- if cfg .queryStatsEnabled {
421
- extra ++
422
- }
423
-
424
414
if cfg .remoteReadEnabled {
425
415
extra ++
426
416
}
@@ -437,15 +427,11 @@ func runQueryFrontendTest(t *testing.T, cfg queryFrontendTestConfig) {
437
427
require .NoError (t , querier .WaitSumMetricsWithOptions (e2e .Greater (numUsers * numQueriesPerUser ), []string {"cortex_request_duration_seconds" }, e2e .WithMetricCount ))
438
428
require .NoError (t , querier .WaitSumMetricsWithOptions (e2e .Greater (numUsers * numQueriesPerUser ), []string {"cortex_querier_request_duration_seconds" }, e2e .WithMetricCount ))
439
429
440
- // Ensure query stats metrics are tracked only when enabled.
441
- if cfg .queryStatsEnabled {
442
- require .NoError (t , queryFrontend .WaitSumMetricsWithOptions (
443
- e2e .Greater (0 ),
444
- []string {"cortex_query_seconds_total" },
445
- e2e .WithLabelMatchers (labels .MustNewMatcher (labels .MatchEqual , "user" , "user-1" ))))
446
- } else {
447
- require .NoError (t , queryFrontend .WaitRemovedMetric ("cortex_query_seconds_total" ))
448
- }
430
+ // Ensure query stats metrics are always tracked to capture regressions.
431
+ require .NoError (t , queryFrontend .WaitSumMetricsWithOptions (
432
+ e2e .Greater (0 ),
433
+ []string {"cortex_query_seconds_total" },
434
+ e2e .WithLabelMatchers (labels .MustNewMatcher (labels .MatchEqual , "user" , "user-1" ))))
449
435
450
436
// Ensure no service-specific metrics prefix is used by the wrong service.
451
437
assertServiceMetricsPrefixes (t , Distributor , distributor )
0 commit comments