| 102 | } |
| 103 | |
| 104 | func newLabelSetCounter(limiter *Limiter) *labelSetCounter { |
| 105 | shards := make([]*labelSetCounterShard, 0, numMetricCounterShards) |
| 106 | for range numMetricCounterShards { |
| 107 | shards = append(shards, &labelSetCounterShard{ |
| 108 | RWMutex: &sync.RWMutex{}, |
| 109 | valuesCounter: map[uint64]*labelSetCounterEntry{}, |
| 110 | }) |
| 111 | } |
| 112 | return &labelSetCounter{ |
| 113 | shards: shards, |
| 114 | limiter: limiter, |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | func (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) { |