8000 remote: Allow unwrapping of errors when reading from remote client by zenador · Pull Request #16437 · prometheus/prometheus · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

remote: Allow unwrapping of errors when reading from remote client #16437

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

Merged
merged 4 commits into from
Apr 22, 2025

Conversation

zenador
Copy link
Contributor
@zenador zenador commented Apr 15, 2025

When fmt.Errorf uses only %s and no %w, it can't be unwrapped, but when it does, it can be unwrapped to just the %w part.

This change allows us to unwrap the error we get from here, so previously an error like remote_read: remote server http://127.0.0.1:45687/api/v1/read returned http status 500 Internal Server Error: execution error couldn't be unwrapped, but now it can be unwrapped to just execution error.

zenador added 3 commits April 16, 2025 03:57
Signed-off-by: Jeanette Tan <jeanette.tan@grafana.com>
Signed-off-by: Jeanette Tan <jeanette.tan@grafana.com>
Signed-off-by: Jeanette Tan <jeanette.tan@grafana.com>
Signed-off-by: Jeanette Tan <jeanette.tan@grafana.com>
Copy link
Member
@krajorama krajorama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, we checked that the original code also has the "\n" in the message, see expectedErrorContains in the test.

@krajorama krajorama requested a review from bboreham April 16, 2025 10:00
Copy link
Member
@bboreham bboreham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems ok, but wouldn't it be even better to wrap a special error type, so you know what kind of thing you unwrapped?

@zenador
Copy link
Contributor Author
zenador commented 8000 Apr 22, 2025

Thank you both! We use this to unwrap errors to summarise them in a downstream project, so if multiple targets fail with the same error we can have a more concise summary, e.g. an error that was like queries to 2/3 targets failed: 2 errors: remote_read: remote server http://127.0.0.1:42295/api/v1/read returned http status 500 Internal Server Error: execution error (target_3); remote_read: remote server http://127.0.0.1:45687/api/v1/read returned http status 500 Internal Server Error: execution error (target_2) can now become queries to 2/3 targets failed: execution error (target_2, target_3)

@krajorama krajorama merged commit f379e2e into prometheus:main Apr 22, 2025
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0