Skip to content
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

Improve ErrorState debugging #1768

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rousskov
Copy link
Contributor

@rousskov rousskov commented Apr 1, 2024

In triage, it is often useful to know that ErrorState was created when
it was created rather than waiting for errorAppendEntry() or errorSend()
debugging, especially if those error handling stages are not reached.

Also report HTTP status code of the error response (when available).

In triage, it is often useful to know that ErrorState was created _when_
it was created rather than waiting for errorAppendEntry() or errorSend()
debugging, especially if those error handling stages are not reached.

Also report HTTP status code of the error response (when available).
Copy link
Contributor Author

@rousskov rousskov left a comment

Choose a reason for hiding this comment

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

This PR was triggered by #1767 (comment)

Sample output:

| 4,3| errorpage.cc(712) ErrorState: ERR_CANNOT_FORWARD/http_status=502
| 17,3| FwdState.cc(461) fail: ERR_CANNOT_FORWARD/http_status=502; was: [nil]
| 4,4| errorpage.cc(739) errorAppendEntry: storing ERR_CANNOT_FORWARD/http_status=502 in e:=p2XIHWV/0x55c661abe320*4
| 4,2| errorpage.cc(1411) buildBody: No existing error page language negotiated for ERR_CANNOT_FORWARD/http_status=502. Using default error file.

The comments in this review annotate the diff. They do not request any code changes.

src/FwdState.cc Show resolved Hide resolved
src/errorpage.cc Outdated Show resolved Hide resolved
Copy link
Contributor

@yadij yadij left a comment

Choose a reason for hiding this comment

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

Just some minor polish.

{
os << errorPageName(err.type);
if (err.httpStatus != Http::scNone)
os << "/http_status=" << err.httpStatus;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use "comma SP" separator here, as is typical for lists of details about something.

Suggested change
os << "/http_status=" << err.httpStatus;
os << ", http_status=" << err.httpStatus;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The formatting here follows %err_code/%err_detail formatting model that many admins use (and I recommend for human-read logs).

IMO, the information printed here is not really a list; the printed items do not belong to the same "level" where enumeration would be natural. Instead, it is a primary ERR_FOO entry with optional/secondary detailing. Rendering this information as a list and using whitespace (without surrounding the whole things with curly braces) will make some likely debugging use cases (that contain commas and spaces for higher-level reasons) more difficult to interpret.

Please keep this summary output looking as a single "field" or "token".

Copy link
Contributor

@yadij yadij Apr 1, 2024

Choose a reason for hiding this comment

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

Admin reading cache.log will be expecting to see the same syntax found in all the surrounding lines. Which is key=value separated by comma.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Admin reading cache.log will be expecting to see the same syntax found in all the surrounding lines. Which is key=value separated by comma.

In cache.log context, we do not have a standard format for this kind of information, and I do not think we should start defining one here. There are already many ways similar information is logged, including lists, structures, compact tokens, and even multiline records. Folks seeing these values are unlikely to misunderstand them because of this particular format choice (a format that fits this data better than a list would and that will look familiar to many admins that log %err_code/%err_detail).

src/errorpage.cc Outdated Show resolved Hide resolved
@yadij yadij added the S-waiting-for-author author action is expected (and usually required) label Apr 1, 2024
@rousskov rousskov requested a review from yadij April 1, 2024 17:30
@rousskov rousskov added S-waiting-for-reviewer ready for review: Set this when requesting a (re)review using GitHub PR Reviewers box and removed S-waiting-for-author author action is expected (and usually required) labels Apr 1, 2024
@yadij yadij added S-waiting-for-author author action is expected (and usually required) and removed S-waiting-for-reviewer ready for review: Set this when requesting a (re)review using GitHub PR Reviewers box labels Apr 2, 2024
@rousskov rousskov added S-waiting-for-reviewer ready for review: Set this when requesting a (re)review using GitHub PR Reviewers box and removed S-waiting-for-author author action is expected (and usually required) labels Apr 2, 2024
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels Apr 5, 2024
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-for-reviewer ready for review: Set this when requesting a (re)review using GitHub PR Reviewers box
Projects
None yet
3 participants