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)
| 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. |
| 144 | func (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 | |
| 165 | func (l *Limiter) formatMaxSeriesPerUserError(userID string) error { |
| 166 | actualLimit := l.maxSeriesPerUser(userID) |