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

Method canAddSeriesForLabelSet

pkg/ingester/user_state.go:118–131  ·  view source on GitHub ↗
(ctx context.Context, u *userTSDB, metric labels.Labels)

Source from the content-addressed store, hash-verified

116}
117
118func (m *labelSetCounter) canAddSeriesForLabelSet(ctx context.Context, u *userTSDB, metric labels.Labels) error {
119 return m.limiter.AssertMaxSeriesPerLabelSet(u.userID, metric, func(allLimits []validation.LimitsPerLabelSet, limit validation.LimitsPerLabelSet) (int, error) {
120 s := m.shards[util.HashFP(model.Fingerprint(limit.Hash))%numMetricCounterShards]
121 s.RLock()
122 if r, ok := s.valuesCounter[limit.Hash]; ok {
123 defer s.RUnlock()
124 return r.count, nil
125 }
126 s.RUnlock()
127
128 // We still dont keep track of this label value so we need to backfill
129 return m.backFillLimit(ctx, u, false, allLimits, limit, s)
130 })
131}
132
133func (m *labelSetCounter) backFillLimit(ctx context.Context, u *userTSDB, forceBackfill bool, allLimits []validation.LimitsPerLabelSet, limit validation.LimitsPerLabelSet, s *labelSetCounterShard) (int, error) {
134 s.Lock()

Callers 1

PreCreationMethod · 0.80

Calls 3

backFillLimitMethod · 0.95
HashFPFunction · 0.92

Tested by

no test coverage detected