Engine: Allow error response code to be customized#16257
Engine: Allow error response code to be customized#16257bboreham merged 30 commits intoprometheus:mainfrom
Conversation
Signed-off-by: Justin Jung <jungjust@amazon.com>
Signed-off-by: Justin Jung <jungjust@amazon.com>
eaf77a0 to
01b7861
Compare
|
Thanks for this. |
|
Thank you @machine424 for taking a look. |
Signed-off-by: Justin Jung <jungjust@amazon.com>
|
Added new struct and downstream components (prometheus dependencies) can do the following to specify HTTP error code on engine execution error: |
Signed-off-by: Justin Jung <jungjust@amazon.com>
Signed-off-by: Justin Jung <justinjung04@gmail.com>
|
Thanks, but I still believe that I hadn't shared my opinion earlier, but as an end user I’d be confused e.g. if an API occasionally returned a |
|
I'm a Cortex user, and I'd like to implement different throttling mechanisms on queryables where I want to return error code other than 422. For example, if the data layer is hammered, I want to throttle user with 429 instead of 422, encouraging user to retry the queries at a slower pace, rather than implying the individual queries are beyond certain limits and can never succeed. I don't believe full customization of all different |
|
I believe another option is to add a new field in the |
|
Thanks for sharing the details. |
Signed-off-by: Justin Jung <jungjust@amazon.com>
1d50eb8 to
ceed934
Compare
Signed-off-by: Justin Jung <jungjust@amazon.com>
|
Signed-off-by: Justin Jung <justinjung04@gmail.com>
|
@machine424 Updates have been made and conflicts have been resolved. Could you take another look? |
machine424
left a comment
There was a problem hiding this comment.
thanks, looks better to me, just some suggestions.
|
cc @bboreham as a "prometheus as a library" user, FYI |
|
If you're going to change this, why go via strings at all? Isn't it logically more like an enum? |
|
@bboreham Could you elaborate? The error type enums haven't been changed, and I just exposed them so that code handler could be customized. Here's an examples uage: where |
|
I mean |
|
Oh I see, I believe we still need the string consts since they're used for creating apiError: To avoid string hashing, I can create another set of enum (const with int type), and add that to the apiError struct like this? Please let me know if this alternative looks good to you |
Signed-off-by: Justin Jung <jungjust@amazon.com>
|
Updated |
|
@machine424 @bboreham Could you take another look? |
bboreham
left a comment
There was a problem hiding this comment.
Thanks; I guess we can live with this but it still seems a little over-complicated.
Do we need both tests? They seem to be doing about the same thing for the new functionality.
Signed-off-by: Justin Jung <jungjust@amazon.com>
Signed-off-by: Justin Jung <jungjust@amazon.com>
Signed-off-by: Justin Jung <jungjust@amazon.com>
Signed-off-by: Justin Jung <justinjung04@gmail.com>
|
@machine424 @bboreham could I get final reviews? |
Signed-off-by: Justin Jung <justinjung04@gmail.com>
1f30161 to
12de470
Compare
Currently the API always returns http code 422 for engine execution error, and This PR allows the error code to be overriden, based on the ErrorType and the error itself. Signed-off-by: Justin Jung <jungjust@amazon.com> Signed-off-by: Justin Jung <justinjung04@gmail.com> Co-authored-by: Ayoub Mrini <ayoubmrini424@gmail.com> Signed-off-by: perebaj <perebaj@gmail.com>
Both k8s and prometheus libraries have to be updated because they depend on each other and both have breaking changes. The following files changed to adopt to the API breaking changes: - processor/k8sattributesprocessor/internal/kube/fake_informer.go: - kubernetes/kubernetes#126387 - receiver/prometheusreceiver/metrics_receiver.go: - prometheus/prometheus#16257 - receiver/prometheusremotewritereceiver/receiver.go: - prometheus/prometheus#17160 I haven't touched any usages of deprecated k8s API to keep the changeset small. Created a separate issue for that instead #43891 Some prometheus tests are failing due to behavioral change in prometheus library. I skipped them for now and reported #43893
Both k8s and prometheus libraries have to be updated because they depend on each other and both have breaking changes. The following files changed to adopt to the API breaking changes: - processor/k8sattributesprocessor/internal/kube/fake_informer.go: - kubernetes/kubernetes#126387 - receiver/prometheusreceiver/metrics_receiver.go: - prometheus/prometheus#16257 - receiver/prometheusremotewritereceiver/receiver.go: - prometheus/prometheus#17160 I haven't touched any usages of deprecated k8s API to keep the changeset small. Created a separate issue for that instead open-telemetry#43891 Some prometheus tests are failing due to behavioral change in prometheus library. I skipped them for now and reported open-telemetry#43893
Both k8s and prometheus libraries have to be updated because they depend on each other and both have breaking changes. The following files changed to adopt to the API breaking changes: - processor/k8sattributesprocessor/internal/kube/fake_informer.go: - kubernetes/kubernetes#126387 - receiver/prometheusreceiver/metrics_receiver.go: - prometheus/prometheus#16257 - receiver/prometheusremotewritereceiver/receiver.go: - prometheus/prometheus#17160 I haven't touched any usages of deprecated k8s API to keep the changeset small. Created a separate issue for that instead open-telemetry#43891 Some prometheus tests are failing due to behavioral change in prometheus library. I skipped them for now and reported open-telemetry#43893
Description
Currently the API always returns http code 422 for engine execution error, and
This PR allows the error code to be overriden, based on the ErrorType and the error itself.
Before the PR:
After the PR:
Testing
Added unit tests
Which issue(s) does the PR fix:
N/A
Does this PR introduce a user-facing change?