@@ -192,14 +192,15 @@ func NewWithScanners(opts Opts, scanners engstorage.Scanners) *Engine {
192
192
193
193
disableDuplicateLabelChecks : opts .DisableDuplicateLabelChecks ,
194
194
195
- logger : opts .Logger ,
196
- lookbackDelta : opts .LookbackDelta ,
197
- enablePerStepStats : opts .EnablePerStepStats ,
198
- logicalOptimizers : opts .LogicalOptimizers ,
199
- timeout : opts .Timeout ,
200
- metrics : metrics ,
201
- extLookbackDelta : opts .ExtLookbackDelta ,
202
- enableAnalysis : opts .EnableAnalysis ,
195
+ logger : opts .Logger ,
196
+ lookbackDelta : opts .LookbackDelta ,
197
+ enablePerStepStats : opts .EnablePerStepStats ,
198
+ logicalOptimizers : opts .LogicalOptimizers ,
199
+ timeout : opts .Timeout ,
200
+ metrics : metrics ,
201
+ extLookbackDelta : opts .ExtLookbackDelta ,
202
+ enableAnalysis : opts .EnableAnalysis ,
203
+ enableDelayedNameRemoval : opts .EnableDelayedNameRemoval ,
203
204
noStepSubqueryIntervalFn : func (d time.Duration ) time.Duration {
204
205
return time .Duration (opts .NoStepSubqueryIntervalFn (d .Milliseconds ()) * 1000000 )
205
206
},
@@ -233,6 +234,7 @@ type Engine struct {
233
234
decodingConcurrency int
234
235
selectorBatchSize int64
235
236
enableAnalysis bool
237
+ enableDelayedNameRemoval bool
236
238
noStepSubqueryIntervalFn func (time.Duration ) time.Duration
237
239
}
238
240
@@ -275,17 +277,18 @@ func (e *Engine) MakeInstantQuery(ctx context.Context, q storage.Queryable, opts
275
277
}
276
278
e .metrics .totalQueries .Inc ()
277
279
return & compatibilityQuery {
278
- Query : & Query {exec : exec , opts : opts },
279
- engine : e ,
280
- plan : lplan ,
281
- warns : warns ,
282
- ts : ts ,
283
- t : InstantQuery ,
284
- resultSort : resultSort ,
285
- scanners : scanners ,
286
- start : ts ,
287
- end : ts ,
288
- step : 0 ,
280
+ Query : & Query {exec : exec , opts : opts },
281
+ engine : e ,
282
+ plan : lplan ,
283
+ ts : ts ,
284
+ warns : warns ,
285
+ t : InstantQuery ,
286
+ resultSort : resultSort ,
287
+ scanners : scanners ,
288
+ enableDelayedNameRemoval : e .enableDelayedNameRemoval ,
289
+ start : ts ,
290
+ end : ts ,
291
+ step : 0 ,
289
292
}, nil
290
293
}
291
294
@@ -327,11 +330,12 @@ func (e *Engine) MakeInstantQueryFromPlan(ctx context.Context, q storage.Queryab
327
330
ts : ts ,
328
331
t : InstantQuery ,
329
332
// TODO(fpetkovski): Infer the sort order from the plan, ideally without copying the newResultSort function.
330
- resultSort : noSortResultSort {},
331
- scanners : scnrs ,
332
- start : ts ,
333
- end : ts ,
334
- step : 0 ,
333
+ resultSort : noSortResultSort {},
334
+ scanners : scnrs ,
335
+ enableDelayedNameRemoval : e .enableDelayedNameRemoval ,
336
+ start : ts ,
337
+ end : ts ,
338
+ step : 0 ,
335
339
}, nil
336
340
}
337
341
@@ -374,15 +378,16 @@ func (e *Engine) MakeRangeQuery(ctx context.Context, q storage.Queryable, opts *
374
378
e .metrics .totalQueries .Inc ()
375
379
376
380
return & compatibilityQuery {
377
- Query : & Query {exec : exec , opts : opts },
378
- engine : e ,
379
- plan : lplan ,
380
- warns : warns ,
381
- t : RangeQuery ,
382
- scanners : scnrs ,
383
- start : start ,
384
- end : end ,
385
- step : step ,
381
+ Query : & Query {exec : exec , opts : opts },
382
+ engine : e ,
383
+ plan : lplan ,
384
+ warns : warns ,
385
+ t : RangeQuery ,
386
+ scanners : scnrs ,
387
+ enableDelayedNameRemoval : e .enableDelayedNameRemoval ,
388
+ start : start ,
389
+ end : end ,
390
+ step : step ,
386
391
}, nil
387
392
}
388
393
@@ -450,6 +455,7 @@ func (e *Engine) makeQueryOpts(start time.Time, end time.Time, step time.Duratio
450
455
EnablePerStepStats : e .enablePerStepStats ,
451
456
ExtLookbackDelta : e .extLookbackDelta ,
452
457
EnableAnalysis : e .enableAnalysis ,
458
+ EnableDelayedNameRemoval : e .enableDelayedNameRemoval ,
453
459
NoStepSubqueryIntervalFn : e .noStepSubqueryIntervalFn ,
454
460
DecodingConcurrency : e .decodingConcurrency ,
455
461
}
@@ -520,9 +526,10 @@ type compatibilityQuery struct {
520
526
end time.Time
521
527
step time.Duration
522
528
523
- t QueryType
524
- resultSort resultSorter
525
- cancel context.CancelFunc
529
+ t QueryType
530
+ resultSort resultSorter
531
+ cancel context.CancelFunc
532
+ enableDelayedNameRemoval bool
526
533
527
534
scanners engstorage.Scanners
528
535
}
@@ -564,7 +571,10 @@ func (q *compatibilityQuery) Exec(ctx context.Context) (ret *promql.Result) {
564
571
565
572
series := make ([]promql.Series , len (resultSeries ))
566
573
for i , s := range resultSeries {
567
- series [i ].Metric = s
574
+ if s .DropName && q .enableDelayedNameRemoval {
575
+ s .Metric = s .Metric .DropMetricName ()
576
+ }
577
+ series [i ] = s
568
578
}
569
579
loop:
570
580
for {
0 commit comments