-
Notifications
You must be signed in to change notification settings - Fork 812
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
Optimize distributor push on error #3990
Optimize distributor push on error #3990
Conversation
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.
LGTM (with few non-blocking nits), nice improvement!
pkg/util/validation/errors.go
Outdated
error | ||
|
||
// ToHTTPGRPCError returns the httpgrpc version of the error. | ||
ToHTTPGRPCError() error |
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.
Nit: It would be nicer if ValidationError
interface was not defined in terms of specific transport mechanism. Instead it could simply have a method IsValidationError() bool
[or some other that makes sense]. Call to httpgrpc.Errorf
could then be done in distributor, by using message from err.Error()
function, which would do the formatting. Duplicity in that all validation errors return same StatusBadRequest
code would be removed.
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.
Sounds a good idea. Done!
// error format only contains the cause and the series. | ||
type genericValidationError struct { | ||
message string | ||
cause string |
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 naming confused me... cause
is simply the first formatting-argument for message
.
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.
I see your point but I can't get a better idea for naming, so I just used cause
which was the variable name already used in ValidateLabels()
.
Conflicts with change in #3982. |
Signed-off-by: Marco Pracucci <[email protected]>
Signed-off-by: Marco Pracucci <[email protected]>
Signed-off-by: Marco Pracucci <[email protected]>
Signed-off-by: Marco Pracucci <[email protected]>
Signed-off-by: Marco Pracucci <[email protected]>
4ee375a
to
7a83bb5
Compare
What this PR does:
Following up the work done in ingesters to optimize the unhappy path (#3969 #3971 #3973), in this PR I'm introducing a benchmark for the
Distributor.Push()
on validation error and optimizing it.Contrary to the ingester, for the distributor I didn't pick the path of returning static errors from
ValidateLabels()
andValidateSample()
and then offer a function to format them because the formatting function ended up to replicate the validation logic too. What I'm proposing in this PR is returning aValidationError
which can be converted to HTTPGRPC error. We still have 1 allocation for each series/sample but, as you can see from the benchmark, the impact is minimal: the real optimization is not having to format an httpgrpc error each time.Benchmark:
No optimization to ingestion rate limit but added to the benchmark to measure it too.
Which issue(s) this PR fixes:
N/A
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]