PreCreation implements SeriesLifecycleCallback interface.
(metric labels.Labels)
| 498 | |
| 499 | // PreCreation implements SeriesLifecycleCallback interface. |
| 500 | func (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. |
| 544 | func (u *userTSDB) PostCreation(metric labels.Labels) { |
nothing calls this directly
no test coverage detected