-
Notifications
You must be signed in to change notification settings - Fork 810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add metric name in limiter per-metric exceeded errors #6422
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Signed-off-by: Essam Eldaly <eeldaly@amazon.com>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,26 +130,26 @@ func (l *Limiter) AssertMaxSeriesPerLabelSet(userID string, metric labels.Labels | |
|
||
// 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. | ||
func (l *Limiter) FormatError(userID string, err error) error { | ||
func (l *Limiter) FormatError(userID string, err error, lbls labels.Labels) error { | ||
switch { | ||
case errors.Is(err, errMaxSeriesPerUserLimitExceeded): | ||
return l.formatMaxSeriesPerUserError(userID) | ||
return l.formatMaxSeriesPerUserError(userID, lbls) | ||
case errors.Is(err, errMaxSeriesPerMetricLimitExceeded): | ||
return l.formatMaxSeriesPerMetricError(userID) | ||
return l.formatMaxSeriesPerMetricError(userID, lbls) | ||
case errors.Is(err, errMaxMetadataPerUserLimitExceeded): | ||
return l.formatMaxMetadataPerUserError(userID) | ||
return l.formatMaxMetadataPerUserError(userID, lbls) | ||
case errors.Is(err, errMaxMetadataPerMetricLimitExceeded): | ||
return l.formatMaxMetadataPerMetricError(userID) | ||
return l.formatMaxMetadataPerMetricError(userID, lbls) | ||
case errors.As(err, &errMaxSeriesPerLabelSetLimitExceeded{}): | ||
e := errMaxSeriesPerLabelSetLimitExceeded{} | ||
errors.As(err, &e) | ||
return l.formatMaxSeriesPerLabelSetError(e) | ||
return l.formatMaxSeriesPerLabelSetError(e, lbls) | ||
default: | ||
return err | ||
} | ||
} | ||
|
||
func (l *Limiter) formatMaxSeriesPerUserError(userID string) error { | ||
func (l *Limiter) formatMaxSeriesPerUserError(userID string, lbls labels.Labels) error { | ||
actualLimit := l.maxSeriesPerUser(userID) | ||
localLimit := l.limits.MaxLocalSeriesPerUser(userID) | ||
globalLimit := l.limits.MaxGlobalSeriesPerUser(userID) | ||
|
@@ -158,16 +158,16 @@ func (l *Limiter) formatMaxSeriesPerUserError(userID string) error { | |
minNonZero(localLimit, globalLimit), l.AdminLimitMessage, localLimit, globalLimit, actualLimit) | ||
} | ||
|
||
func (l *Limiter) formatMaxSeriesPerMetricError(userID string) error { | ||
func (l *Limiter) formatMaxSeriesPerMetricError(userID string, lbls labels.Labels) error { | ||
actualLimit := l.maxSeriesPerMetric(userID) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can just pass the metric name string. No need to pass labels |
||
localLimit := l.limits.MaxLocalSeriesPerMetric(userID) | ||
globalLimit := l.limits.MaxGlobalSeriesPerMetric(userID) | ||
|
||
return fmt.Errorf("per-metric series limit of %d exceeded, %s (local limit: %d global limit: %d actual local limit: %d)", | ||
minNonZero(localLimit, globalLimit), l.AdminLimitMessage, localLimit, globalLimit, actualLimit) | ||
return fmt.Errorf("per-metric series limit of %d exceeded for metric %s, %s (local limit: %d global limit: %d actual local limit: %d)", | ||
minNonZero(localLimit, globalLimit), lbls.Get(labels.MetricName), l.AdminLimitMessage, localLimit, globalLimit, actualLimit) | ||
} | ||
|
||
func (l *Limiter) formatMaxMetadataPerUserError(userID string) error { | ||
func (l *Limiter) formatMaxMetadataPerUserError(userID string, lbls labels.Labels) error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems not used. Do we need it? |
||
actualLimit := l.maxMetadataPerUser(userID) | ||
localLimit := l.limits.MaxLocalMetricsWithMetadataPerUser(userID) | ||
globalLimit := l.limits.MaxGlobalMetricsWithMetadataPerUser(userID) | ||
|
@@ -176,16 +176,16 @@ func (l *Limiter) formatMaxMetadataPerUserError(userID string) error { | |
minNonZero(localLimit, globalLimit), l.AdminLimitMessage, localLimit, globalLimit, actualLimit) | ||
} | ||
|
||
func (l *Limiter) formatMaxMetadataPerMetricError(userID string) error { | ||
func (l *Limiter) formatMaxMetadataPerMetricError(userID string, lbls labels.Labels) error { | ||
actualLimit := l.maxMetadataPerMetric(userID) | ||
localLimit := l.limits.MaxLocalMetadataPerMetric(userID) | ||
globalLimit := l.limits.MaxGlobalMetadataPerMetric(userID) | ||
|
||
return fmt.Errorf("per-metric metadata limit of %d exceeded, %s (local limit: %d global limit: %d actual local limit: %d)", | ||
minNonZero(localLimit, globalLimit), l.AdminLimitMessage, localLimit, globalLimit, actualLimit) | ||
return fmt.Errorf("per-metric metadata limit of %d exceeded for metric %s, %s (local limit: %d global limit: %d actual local limit: %d)", | ||
minNonZero(localLimit, globalLimit), lbls.Get(labels.MetricName), l.AdminLimitMessage, localLimit, globalLimit, actualLimit) | ||
} | ||
|
||
func (l *Limiter) formatMaxSeriesPerLabelSetError(err errMaxSeriesPerLabelSetLimitExceeded) error { | ||
func (l *Limiter) formatMaxSeriesPerLabelSetError(err errMaxSeriesPerLabelSetLimitExceeded, lbls labels.Labels) error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems not used. Do we need it? |
||
return fmt.Errorf("per-labelset series limit of %d exceeded (labelSet: %s, local limit: %d global limit: %d actual)", | ||
minNonZero(err.globalLimit, err.localLimit), err.id, err.localLimit, err.globalLimit) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems not used. Do we need it?