-
Notifications
You must be signed in to change notification settings - Fork 5
feat(proxy): add sentinel errors and unified error handling (fixes #89) #92
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
base: main
Are you sure you want to change the base?
feat(proxy): add sentinel errors and unified error handling (fixes #89) #92
Conversation
4b167fe to
f44590c
Compare
Signed-off-by: UmarFarooq-MP <[email protected]>
Add spell check workflow Signed-off-by: Hélia Barroso <[email protected]> Signed-off-by: UmarFarooq-MP <[email protected]>
…lojmdias#91) Bumps [github.com/grafana/loki/v3](https://github.com/grafana/loki) from 3.5.4 to 3.5.5. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/grafana/loki/releases">github.com/grafana/loki/v3's releases</a>.</em></p> <blockquote> <h2>v3.5.5</h2> <h2><a href="https://github.com/grafana/loki/compare/v3.5.4...v3.5.5">3.5.5</a> (2025-09-11)</h2> <h3>Bug Fixes</h3> <ul> <li><strong>release-3.5.x:</strong> backport fix to correctly calculate entry metadata size (<a href="https://redirect.github.com/grafana/loki/issues/19163">#19163</a>) (<a href="https://github.com/grafana/loki/commit/5aa8bd27946a1ce5267790ebe9210f93cd7111b2">5aa8bd2</a>)</li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/grafana/loki/commit/5aa8bd27946a1ce5267790ebe9210f93cd7111b2"><code>5aa8bd2</code></a> fix(release-3.5.x): backport fix to correctly calculate entry metadata size (...</li> <li><a href="https://github.com/grafana/loki/commit/58c0ca12feaaf99a90a28563389e68f47bd075bd"><code>58c0ca1</code></a> docs: Backport 19151 (<a href="https://redirect.github.com/grafana/loki/issues/19158">#19158</a>)</li> <li><a href="https://github.com/grafana/loki/commit/78f9c6f18455dff0a0a1dc0600225d98cc5d133c"><code>78f9c6f</code></a> docs: Add breaking change to upgrade (backport release-3.5.x) (<a href="https://redirect.github.com/grafana/loki/issues/19147">#19147</a>)</li> <li><a href="https://github.com/grafana/loki/commit/ecdf1ea7826be513a3cbf91875459e656cad3ca8"><code>ecdf1ea</code></a> docs: manual backport 3.5 (<a href="https://redirect.github.com/grafana/loki/issues/19123">#19123</a>)</li> <li><a href="https://github.com/grafana/loki/commit/2e0b55d02dc6dc5cf4b6133e5dbeb00e0f01d72b"><code>2e0b55d</code></a> docs: Release notes for 3.5.4 (<a href="https://redirect.github.com/grafana/loki/issues/19113">#19113</a>)</li> <li><a href="https://github.com/grafana/loki/commit/b4075c0a307b68183366d9a2d618948199135e67"><code>b4075c0</code></a> chore(release-3.5.x): release 3.5.4 (<a href="https://redirect.github.com/grafana/loki/issues/18680">#18680</a>)</li> <li>See full diff in <a href="https://github.com/grafana/loki/compare/v3.5.4...v3.5.5">compare view</a></li> </ul> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: UmarFarooq-MP <[email protected]>
Signed-off-by: UmarFarooq-MP <[email protected]>
f44590c to
8347b0b
Compare
|
is it wise to update the tool chain to latest on 1.24 but CI needs to update for that otherwise CI will keep on failing. @heliapb |
|
@UmarFarooq-MP thanks for your PR! Can we just focus on returning back the errors returned by Loki? Currently it seems a big refactor |
|
I think you are right let me revert them. I added a response pattern with sentinel errors. @paulojmdias |
Signed-off-by: UmarFarooq-MP <[email protected]>
4f77a7f to
04ed207
Compare
Signed-off-by: UmarFarooq-MP <[email protected]>
|
The PR is updated @paulojmdias @heliapb |
| // Log the raw body for debugging | ||
| level.Debug(logger).Log("msg", "Received body for label values", "body", string(bodyBytes)) | ||
|
|
||
| // Unmarshal into a struct that matches the actual response format |
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.
@UmarFarooq-MP can we keep all the existing comments to make this PR easier to review?
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.
sure @paulojmdias , was caught up in thing will try to do it in this week.
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.
@UmarFarooq-MP any chance to came back on this ? 🙏
What this PR does
This PR implements centralized error handling for the proxy layer in
lokxy.Key Changes
pkg/proxy/errorspackage with sentinel errors (e.g.ErrNoUpstream,ErrReadBodyFailed,ErrTailRequiresWebSocket).WriteJSONErrorutility so that all handlers return consistent JSON error responses instead of raw text/plain.query,labels,series,stats,tail) to use the centralized error definitions.README.mdso users can easily test both success and failure cases for every endpoint.Why this matters
Testing the Proxy Endpoints
To verify that
lokxyis correctly proxying requests to Loki, you can run a few simplecurlandwebsocatcommands.These examples assume:
lokxyis running onhttp://localhost:3100http://localhost:9090log-generatorcontainer)Query Range (Success)
This way your
test.shremains local for you, and contributors can still see exactly how to test without needing a script.Closes #89