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

Method FormatError

pkg/ingester/limiter.go:144–163  ·  view source on GitHub ↗

FormatError returns the input error enriched with the actual limits for the given user. It acts as pass-through if the input error is unknown.

(userID string, err error, lbls labels.Labels)

Source from the content-addressed store, hash-verified

142// FormatError returns the input error enriched with the actual limits for the given user.
143// It acts as pass-through if the input error is unknown.
144func (l *Limiter) FormatError(userID string, err error, lbls labels.Labels) error {
145 switch {
146 case errors.Is(err, errMaxSeriesPerUserLimitExceeded):
147 return l.formatMaxSeriesPerUserError(userID)
148 case errors.Is(err, errMaxNativeHistogramSeriesPerUserLimitExceeded):
149 return l.formatMaxNativeHistogramsSeriesPerUserError(userID)
150 case errors.Is(err, errMaxSeriesPerMetricLimitExceeded):
151 return l.formatMaxSeriesPerMetricError(userID, lbls.Get(labels.MetricName))
152 case errors.Is(err, errMaxMetadataPerUserLimitExceeded):
153 return l.formatMaxMetadataPerUserError(userID)
154 case errors.Is(err, errMaxMetadataPerMetricLimitExceeded):
155 return l.formatMaxMetadataPerMetricError(userID, lbls.Get(labels.MetricName))
156 case errors.As(err, &errMaxSeriesPerLabelSetLimitExceeded{}):
157 e := errMaxSeriesPerLabelSetLimitExceeded{}
158 errors.As(err, &e)
159 return l.formatMaxSeriesPerLabelSetError(e)
160 default:
161 return err
162 }
163}
164
165func (l *Limiter) formatMaxSeriesPerUserError(userID string) error {
166 actualLimit := l.maxSeriesPerUser(userID)

Callers 6

TestLimiter_FormatErrorFunction · 0.95
PushMethod · 0.80
addMethod · 0.80