| 345 | } |
| 346 | |
| 347 | func (e *Engine) scanPlanSeries(ctx *planBuildContext) error { |
| 348 | var firstErr error |
| 349 | buildSeq := ctx.collectMeta.LastSuccessSeq |
| 350 | process := func(identity metrix.SeriesIdentity, meta metrix.SeriesMeta, name string, labels metrix.LabelView, v metrix.SampleValue) { |
| 351 | ctx.seriesScanned++ |
| 352 | if firstErr != nil { |
| 353 | return |
| 354 | } |
| 355 | if e.state.cfg.seriesSelection == seriesSelectionLastSuccessOnly && |
| 356 | meta.LastSeenSuccessSeq != ctx.collectMeta.LastSuccessSeq { |
| 357 | ctx.seriesFilteredBySeq++ |
| 358 | ctx.cache.MarkSeenIfPresent(identity, buildSeq) |
| 359 | return |
| 360 | } |
| 361 | if selector := e.state.cfg.selector; selector != nil && !selector.Matches(name, labels) { |
| 362 | ctx.seriesFilteredBySel++ |
| 363 | ctx.cache.MarkSeenIfPresent(identity, buildSeq) |
| 364 | return |
| 365 | } |
| 366 | |
| 367 | routes, hit, err := e.resolveSeriesRoutes( |
| 368 | ctx.cache, |
| 369 | identity, |
| 370 | name, |
| 371 | labels, |
| 372 | meta, |
| 373 | ctx.index, |
| 374 | ctx.prog.Revision(), |
| 375 | buildSeq, |
| 376 | ) |
| 377 | if err != nil { |
| 378 | firstErr = err |
| 379 | return |
| 380 | } |
| 381 | if hit { |
| 382 | e.addRouteCacheHit() |
| 383 | ctx.routeCacheHits++ |
| 384 | } else { |
| 385 | e.addRouteCacheMiss() |
| 386 | ctx.routeCacheMisses++ |
| 387 | } |
| 388 | if len(routes) == 0 { |
| 389 | autoRoutes, ok, err := e.resolveAutogenRoute(ctx.reader, name, labels, meta) |
| 390 | if err != nil { |
| 391 | firstErr = err |
| 392 | return |
| 393 | } |
| 394 | if ok { |
| 395 | routes = autoRoutes |
| 396 | ctx.seriesAutogenMatched++ |
| 397 | ctx.seriesMatched++ |
| 398 | } else { |
| 399 | ctx.seriesUnmatched++ |
| 400 | return |
| 401 | } |
| 402 | } else { |
| 403 | ctx.seriesMatched++ |
| 404 | } |