-
Notifications
You must be signed in to change notification settings - Fork 55
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
How to group logs by request like python 2.7 standard? #587
Comments
hi @lucasvanhalst , The child log entries have to have the same To implement it you have to use the logging client library in Python that automatically populates the |
@minherz thanks, but that was exactly my problem, I am using that library as documented (that library is this repository). Recently though (3 weeks?), it seems like the log explorer added a function to automatically load the logs related to a request when you click on a request log, and there's also a new (or old, and I didn't notice it..) option 'correlate by' added which seems to achieve exactly what I want. It only shows the request logs (when you choose 'request log' as the property to correlate logs by), and loads the app logs for that request when you open the request log. Unfortunatlly, when you activate the correlate by function, you cannot save the query you made which is a bit annoying |
After checking in with the team, I've found that this is due to a difference in how logs are structured on the logging backend between App Engine Python 2.7 and App Engine Python 3+. Unfortunately, this isn't something that can be changed at the client library level, so I'm going to close this issue. The Log Correlation feature you mentioned above is the closest equivalent to what you're looking for with the new backend. We have raised the issues you ran into while using the feature with the team Thanks for reporting this |
Please revise the documentation that directs appengine customers to use this library in the case when all they want is a way to group logs per request. If this is all they need, and they do not need to call any functions in the logging API itself, they do not need this library to do it, and importing it has a large memory cost. |
@pnico The "Correlate By" feature will not give associated Application logs if the Cloud Logging client's 'setup_logging' method is not called - https://cloud.google.com/logging/docs/setup/python#write_logs_with_the_standard_python_logging_handler |
Hi there, I have created this to solve this issue around FastAPI applications https://github.com/chrisK824/fastapi-gae-logging Flask will follow. |
I've searched around in this repo's issues and and on other places, but couldn't find a definitive answer/solution.
#110 is basically the same but I don't see a solution there that still works.
On python 2.7 standard, logs are grouped by request, as shown below (same code running on py27 standard and py39 standard, both use flask as web framework)
python 2: there is 1 request log that you can expand to view all logs made in that request (the request log also has the highest severity of all logs):

python 3 with the following setup, the logs aren't grouped (the only thing relating them to each other is the traceId):
(in main.py / application entrypoint)
I've also tried the deprecated AppEngineHandler but that gave the same results.
I know I can manually group the logs by filtering on trace id, but that's not nearly as convenient... Is there a solution available so we can have the log grouping like it was on python 2.7?
The text was updated successfully, but these errors were encountered: