-
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
allow sending extras when setting up client #149
Comments
It would be great if trace ( So please consider adding tracing even in the simplest Cloud Run apps that are basically
|
…e id makes log lines attach to their HTTP request and show grouped in cloud console log browser. google-cloud-logging used to do this automatically for webapp2, based on the X-Cloud-Trace-Context header, but it dropped webapp2 as of google-cloud-logging 2.0. background: googleapis/python-logging#110 (comment) googleapis/python-logging#149 (comment) also note that AppEngineHandler is evidently deprecated, so I may need to port that whole class into webutil eventually. :( googleapis/python-logging#202
Please. It is mind-blowing how badly these libraries integrate with Logging Explorer. This two things:
have been requested multiple times, and were already a thing in all Gen1 App Engine environments, yet people have to resort to third party solutions (such as https://github.com/salrashid123/flask-gcp-log-groups) to make the logs bearable. I can't think of any use case where you wouldn't want those things to just happen. |
Hey @spiqueras , It's surprising to me that you're still seeing these issues. The library does attempt to parse X-Cloud-Trace-Context and w3 traceparent headers for trace correlation. The Log grouping backend behaviour has changed since App Engine Gen1, but it should now group based on It's possible the issues you're seeing are due to a bug in the library, or it could be a configuration error, or it could just be an issue with the environment you are running the code in. If you can give me more information of how you're running your code, example logs, and/or sample code that reproduces what you're seeing, I can try to take a look. If you have an example of a log output by the library that's ungrouped vs a similar one that is grouped how you expect, that would be especially helpful in tracking down the root cause Thanks, |
For anyone using this library who is only using it because they want to get log correlation like they had before with appengine standard, and who doesn't need to actually call functions in the cloud logging API, you don't need to use this library at all. You might have to change the way you are looking at logs, or in the way you are analyzing their output if you are forwarding them to BigQuery or elsewhere using log sinks and depend on I'm not sure why they don't recommend this approach by default for appengine customers in this situation, and maybe there's a good reason I'm not aware of, so take this comment with a grain of salt. I'm sharing this here because it would have saved me many hours of wasted time if I had seen a comment like this. |
Hey pnico, Yes, you are correct that App Engine and certain other GCP environments will automatically pick up formatted stdout logs. This library provides the StructuredLogHandler to take advantage of this, which essentially does what you describe, by sending logs through a custom Formatter and Handler to export properly formatted logs over stdout, to avoid the overhead of network calls. This library will attempt to determine which environment your code is running on, and pick the best log export method based on the environment. But you are correct that if you only plan on running your code on App Engine, you can avoid this library and just write structured json logs directly (using our StructuredLogHandler, or custom code doing something similar) |
Yeah, I looked at some of the handler classes there but importing any of those seems to bring in the rest of the library
Maybe those handlers add some details that could be useful, but we can get everything we need with something much simpler. GCP is actually adding resource labels |
This could be addressed with an adapter: #750 |
@gkevinzheng @daniel-sanche fancy to provide at least a cursory review to the PR? (I'm not able due to my limited skills) |
The code in #751 looks safe to use if you'd find it helpful, although it only adds labels to logs, not other fields like was initially discussed I don't think this feature is likely to be added to python-logging in the near-term, but the library fully supports external adapters in user code |
We recently added a feature to allow log commands to send in
extras
, allowing users to customize certain fields (#129)@nicoleczhu suggested expanding this by allowing users to set default
extras
when first setting up the logging clientThe text was updated successfully, but these errors were encountered: