MCPcopy Create free account
hub / github.com/cortexproject/cortex / PreCreation

Method PreCreation

pkg/ingester/ingester.go:500–541  ·  view source on GitHub ↗

PreCreation implements SeriesLifecycleCallback interface.

(metric labels.Labels)

Source from the content-addressed store, hash-verified

498
499// PreCreation implements SeriesLifecycleCallback interface.
500func (u *userTSDB) PreCreation(metric labels.Labels) error {
501 if u.limiter == nil {
502 return nil
503 }
504
505 // Verify ingester's global limit
506 gl := u.instanceLimitsFn()
507 if gl != nil && gl.MaxInMemorySeries > 0 {
508 if series := u.instanceSeriesCount.Load(); series >= gl.MaxInMemorySeries {
509 return errMaxSeriesLimitReached
510 }
511 }
512
513 // Total series limit.
514 if err := u.limiter.AssertMaxSeriesPerUser(u.userID, int(u.Head().NumSeries())); err != nil {
515 return err
516 }
517
518 // Total native histogram series limit.
519 if err := u.limiter.AssertMaxNativeHistogramSeriesPerUser(u.userID, u.activeSeries.ActiveNativeHistogram()); err != nil {
520 return err
521 }
522
523 // Series per metric name limit.
524 metricName, err := extract.MetricNameFromLabels(metric)
525 if err != nil {
526 return err
527 }
528 if err := u.seriesInMetric.canAddSeriesFor(u.userID, metricName); err != nil {
529 return err
530 }
531
532 if err := u.labelSetCounter.canAddSeriesForLabelSet(context.TODO(), u, metric); err != nil {
533 return err
534 }
535
536 if u.labelsStringInterningEnabled {
537 metric.InternStrings(u.interner.Intern)
538 }
539
540 return nil
541}
542
543// PostCreation implements SeriesLifecycleCallback interface.
544func (u *userTSDB) PostCreation(metric labels.Labels) {

Callers

nothing calls this directly

Calls 8

HeadMethod · 0.95
MetricNameFromLabelsFunction · 0.92
LoadMethod · 0.80
ActiveNativeHistogramMethod · 0.80
canAddSeriesForMethod · 0.80

Tested by

no test coverage detected