-
Notifications
You must be signed in to change notification settings - Fork 9
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
Log request issues #111
Log request issues #111
Conversation
Also, try out time stamp processor.
Leave the scraps in case we need them later.
Also, fix the 404 error test in the B-file lookup routine, which was broken by the changes I made to oeis_get when I implemented request logs
To do this, add log testing capability to the abstract endpoint test
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.
Maybe this needs some documentation (markdown), like where are logs written to, and whether anything needs to be done to enable logging, and what is logged? Other than that, it runs fine on my system and I've pasted in the flask test
output for the unit test, which looks like it was ok. I can verify that it creates api.log
on my system if it doesn't exist, although I wasn't sure how to cause it to log something in there (I played with some sequences and nothing was logged although in the shell it showed various successful API calls).
Merge in commit hash endpoint (pull requests numberscope#113 and numberscope#114). Also, add some requirements that seemed to be missing. Not sure how that happened.
It snuck in when merging the commit hash endpoint from main.
These do need to be present, but this will be handled in `reqs_cleanup`.
Before, we were throwing away the updated log entry returned by `bind`. The `bind` method does not modify the log entry in place!
Updates:
|
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.
Let me know when you want me to test it all again.
I just pulled the current version of this PR and ran its tests, and the test of getting a nonexistent sequence failed. So @Vectornaut I am guessing this is not ready for further review and for building on to get a head start on #77? Let us know when you think it's stable enough. Thanks! |
Oh, right—I fixed the bug that was leaving HTTP response dumps out of log entries, but I haven't yet updated the test's expected log entry to include a response dump. The easiest test (comparing against a fixed expected log message) would stop working if the OEIS changes its 404 page. Is that easy test good enough for now? |
I think definitely so. The OEIS tends to move slowly, technologically speaking, and it's easy for us to update test expectations if they do change. Thanks! |
Estimating our entry capacity for the docs convinced me that we should reserve more storage for log files.
Also, link logging docs from README.
Since parts of the response are time-dependent, this requires a new abstract endpoint test feature: the ability to pre-process log entries. We use this feature to cut out the time-dependent parts of the response.
This includes: - Old code that I kept around for comparison - Draft code that I didn't end up using - Printing and exception raising that I used for debugging
Including the HTTP response dump in the nonexistent sequence test was more annoying than I expected, because parts of the response (the date line and the "last updated" ticker on the OEIS 404 page) are time-dependent. However, I've managed to cut them out, yielding a test that covers at least part of the expected 404 response. |
I think this is ready to review again! Could you both try it out, review the issues you brought up, and resolve the conversations that have been addressed to your satisfaction? |
Oops:
Does it fail if you have no logs directory and/or no pre-existing api.log file? Needs to be resilient to those possibilities, if so. |
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.
It's possible you forgot to add all the files/directories needed? Did you move logs into a subdirectory? When I do flask run
I get
FileNotFoundError: [Errno 2] No such file or directory: '/home/katestange/data/projects/numberscope/frontscope-backscope/backscope/logs/api.log'
and indeed, I have no directory "logs". flask test
seems to have a similar problem
Took the liberty of adding where to find the log files in production, since it seems on-point for this PR and then will also close #55. |
And since this now touches server-administration.md, removed warning about get_commit not working to kill #115 too. |
Awesome. I'm almost done with the revised commit message. |
This should be documented in the documentation, not just in the PR.
… logbad Grab server log documentation.
Here's my proposed commit message! Let me know if I should shorten it (or feel free to revise it unilaterally). While writing it, I realized that the
|
My apologies, I saw the odd merge of logbad into logbad in the git log and didn't know what that was all about, so did a "git diff" versus main just to be sure all was well, and all these "noise" items came up which it would be good to squelch here before the merge. Sorry. |
No, it's a good idea to clean these up. Because I'd imagined dealing with formatting errors in a separate commit, I didn't think to make sure this PR didn't introduce new formatting errors. I should be able to finish that in a few minutes. |
Order imports alphabetically. Drop indentation-keeping whitespace from blank lines. The goal of this commit is to keep the request logging PR from introducing new formatting inconsistencies, not to correct existing ones.
Commit aa5db13 should prevent this PR from introducing new formatting inconsistencies. You may want to review the alphabetization of imports: I tried to imitate existing files, but I'm not sure I did it correctly. |
This PR sets up a system to log requests that go wrong. This involves several smaller changes.
Logging
structlog
for all explicit logging. This makes it easy to write JSON logs that include all the response data from problematic requests, while also writing summary logs to standard output.structlogger
attribute of the app, leaving the defaultlogger
attribute as it is.create_app
runs? This might make it easier to see which version of the software other log entries are coming from.oeis_get
wrapper for OEIS requests, which automatically logs any problems.Testing