@@ -38,7 +38,6 @@ import (
38
38
type queryFrontendTestConfig struct {
39
39
testMissingMetricName bool
40
40
querySchedulerEnabled bool
41
- queryStatsEnabled bool
42
41
remoteReadEnabled bool
43
42
testSubQueryStepSize bool
44
43
setup func (t * testing.T , s * e2e.Scenario ) (configFile string , flags map [string ]string )
@@ -61,7 +60,6 @@ func TestQueryFrontendWithBlocksStorageViaFlags(t *testing.T) {
61
60
func TestQueryFrontendWithBlocksStorageViaFlagsAndQueryStatsEnabled (t * testing.T ) {
62
61
runQueryFrontendTest (t , queryFrontendTestConfig {
63
62
testMissingMetricName : false ,
64
- queryStatsEnabled : true ,
65
63
setup : func (t * testing.T , s * e2e.Scenario ) (configFile string , flags map [string ]string ) {
66
64
flags = BlocksStorageFlags ()
67
65
@@ -92,7 +90,6 @@ func TestQueryFrontendWithBlocksStorageViaFlagsAndWithQuerySchedulerAndQueryStat
92
90
runQueryFrontendTest (t , queryFrontendTestConfig {
93
91
testMissingMetricName : false ,
94
92
querySchedulerEnabled : true ,
95
- queryStatsEnabled : true ,
96
93
setup : func (t * testing.T , s * e2e.Scenario ) (configFile string , flags map [string ]string ) {
97
94
flags = BlocksStorageFlags ()
98
95
@@ -168,7 +165,6 @@ func TestQueryFrontendWithVerticalSharding(t *testing.T) {
168
165
runQueryFrontendTest (t , queryFrontendTestConfig {
169
166
testMissingMetricName : false ,
170
167
querySchedulerEnabled : false ,
171
- queryStatsEnabled : true ,
172
168
setup : func (t * testing.T , s * e2e.Scenario ) (configFile string , flags map [string ]string ) {
173
169
require .NoError (t , writeFileToSharedDir (s , cortexConfigFile , []byte (BlocksStorageConfig )))
174
170
@@ -188,7 +184,6 @@ func TestQueryFrontendWithVerticalShardingQueryScheduler(t *testing.T) {
188
184
runQueryFrontendTest (t , queryFrontendTestConfig {
189
185
testMissingMetricName : false ,
190
186
querySchedulerEnabled : true ,
191
- queryStatsEnabled : true ,
192
187
setup : func (t * testing.T , s * e2e.Scenario ) (configFile string , flags map [string ]string ) {
193
188
require .NoError (t , writeFileToSharedDir (s , cortexConfigFile , []byte (BlocksStorageConfig )))
194
189
@@ -208,7 +203,6 @@ func TestQueryFrontendProtobufCodec(t *testing.T) {
208
203
runQueryFrontendTest (t , queryFrontendTestConfig {
209
204
testMissingMetricName : false ,
210
205
querySchedulerEnabled : true ,
211
- queryStatsEnabled : true ,
212
206
setup : func (t * testing.T , s * e2e.Scenario ) (configFile string , flags map [string ]string ) {
213
207
require .NoError (t , writeFileToSharedDir (s , cortexConfigFile , []byte (BlocksStorageConfig )))
214
208
@@ -228,7 +222,6 @@ func TestQuerierToQueryFrontendCompression(t *testing.T) {
228
222
runQueryFrontendTest (t , queryFrontendTestConfig {
229
223
testMissingMetricName : false ,
230
224
querySchedulerEnabled : true ,
231
- queryStatsEnabled : true ,
232
225
setup : func (t * testing.T , s * e2e.Scenario ) (configFile string , flags map [string ]string ) {
233
226
require .NoError (t , writeFileToSharedDir (s , cortexConfigFile , []byte (BlocksStorageConfig )))
234
227
@@ -294,7 +287,7 @@ func runQueryFrontendTest(t *testing.T, cfg queryFrontendTestConfig) {
294
287
"-querier.split-queries-by-interval" : "24h" ,
295
288
"-querier.query-ingesters-within" : "12h" , // Required by the test on query /series out of ingesters time range
296
289
"-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
298
291
})
299
292
300
293
// Start the query-scheduler if enabled.
@@ -382,7 +375,7 @@ func runQueryFrontendTest(t *testing.T, cfg queryFrontendTestConfig) {
382
375
}
383
376
384
377
// No need to repeat the test on Server-Timing header for each user.
385
- if userID == 0 && cfg . queryStatsEnabled {
378
+ if userID == 0 {
386
379
res , _ , err := c .QueryRaw ("{instance=~\" hello.*\" }" , time .Now (), map [string ]string {})
387
380
require .NoError (t , err )
388
381
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) {
433
426
434
427
wg .Wait ()
435
428
436
- extra := float64 (2 )
429
+ extra := float64 (3 ) // Always include query stats test
437
430
if cfg .testMissingMetricName {
438
431
extra ++
439
432
}
440
433
441
- if cfg .queryStatsEnabled {
442
- extra ++
443
- }
444
-
445
434
if cfg .remoteReadEnabled {
446
435
extra ++
447
436
}
@@ -458,15 +447,11 @@ func runQueryFrontendTest(t *testing.T, cfg queryFrontendTestConfig) {
458
447
require .NoError (t , querier .WaitSumMetricsWithOptions (e2e .Greater (numUsers * numQueriesPerUser ), []string {"cortex_request_duration_seconds" }, e2e .WithMetricCount ))
459
448
require .NoError (t , querier .WaitSumMetricsWithOptions (e2e .Greater (numUsers * numQueriesPerUser ), []string {"cortex_querier_request_duration_seconds" }, e2e .WithMetricCount ))
460
449
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" ))))
470
455
471
456
// Ensure no service-specific metrics prefix is used by the wrong service.
472
457
assertServiceMetricsPrefixes (t , Distributor , distributor )
0 commit comments