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

Method AddSeries

pkg/util/limiter/query_limiter.go:69–90  ·  view source on GitHub ↗

AddSeries adds the batch of input series and returns an error if the limit is reached.

(series ...[]cortexpb.LabelAdapter)

Source from the content-addressed store, hash-verified

67
68// AddSeries adds the batch of input series and returns an error if the limit is reached.
69func (ql *QueryLimiter) AddSeries(series ...[]cortexpb.LabelAdapter) error {
70 // If the max series is unlimited just return without managing map
71 if ql.maxSeriesPerQuery == 0 {
72 return nil
73 }
74 fps := make([]model.Fingerprint, 0, len(series))
75 for _, s := range series {
76 fps = append(fps, client.FastFingerprint(s))
77 }
78
79 ql.uniqueSeriesMx.Lock()
80 defer ql.uniqueSeriesMx.Unlock()
81 for _, fp := range fps {
82 ql.uniqueSeries[fp] = struct{}{}
83 }
84
85 if len(ql.uniqueSeries) > ql.maxSeriesPerQuery {
86 // Format error with max limit
87 return fmt.Errorf(ErrMaxSeriesHit, ql.maxSeriesPerQuery)
88 }
89 return nil
90}
91
92// uniqueSeriesCount returns the count of unique series seen by this query limiter.
93func (ql *QueryLimiter) uniqueSeriesCount() int {

Calls 1

FastFingerprintFunction · 0.92