-
Notifications
You must be signed in to change notification settings - Fork 23
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
"Warning" is being published as "Error" #106
Comments
@arslanov-test thank you for letting us know about the problem and providing the detailed response. The only missing bits are a configuration of the python logger and the details about the environment where you run your program. The "working" version overrides the behavior of the standard Python logging. Thus you see the different behavior. Addressing your questions:
Your hypothesis provides one of the possible ways to solve this problem (in Cloud Function). Another is to print to
Would you mind to explain what functionality you are looking for? I am not familiar with the term "backoff file" that you used. |
@minherz Thank you for your kind reply. Afterwards, I have tried to reproduce the issue by running the python file in Cloud Functions with the code I provided in the first comment (I tried to import logging library as you did) and found that logging.warning is being published as "Error". Therefore, I came to conclusion that although you have changed from logger.error to logger.warning in [2], anyway error comes out with the message[3]. Therefore, I think you should fix the code in backoff.py[4] (e.g. adding google.cloud.logging as I did) so that [5] is published as "warning" in GCP VMs. Could you fix it? [1]. https://github.com/GoogleCloudPlatform/cloud-profiler-python/blob/main/googlecloudprofiler/backoff.py#L82-L85
|
How can I modify your code in [1] (e.g. by adding structured logging or using google.cloud.logging) and use it in Cloud Dataflow so that [2] is published as warning? Should I use custom package way?
|
If you want to use the standard logging module, the # Imports the Cloud Logging client library
import google.cloud.logging
# Instantiates a client
client = google.cloud.logging.Client()
# Retrieves a Cloud Logging handler based on the environment
# you're running in and integrates the handler with the
# Python logging module. By default this captures all logs
# at INFO level and higher
client.setup_logging() |
Note re: #106 (comment), since the Cloud Profiler Agent is intended to be run in places other than GCP, you may not want to take on |
@arslanov-test Does adding the snippet from your issue description import google.cloud.logging # Don't conflict with standard logging
client = google.cloud.logging.Client()
client.setup_logging() to your code before enabling profiling solve your issue? I'm not sure what changes you are expecting from the Cloud Profiler team. It doesn't make much sense to me to have it always send logs to Cloud Logging, since the product can be used in environments other than GCP. |
The profiler agent is also just a library - things like |
Thank you team for your replies. I understood. |
Summary
In commit (8147311#diff-6bc78e58322668fa0a7c4d34928f7647f75ac41852c8df1ee3e3aee2fd422966), you have changed log.error to log.warning. However, it seems that GCP Cloud Logging will take this as "Error" anyway since python's logging library is not fully respected[1]. There is an internal issue on this inside Google[2].
To heal this issue, we should import google.cloud.logging library. Please see the below reproducing steps.
Reproducing steps
I have tried to run following in Cloud Functions and "Error" came out anyway instead of "Warning" in Cloud Logging:
main.py:
requirements.txt:
After I added google.cloud.logging as follows, the warning has been published as "Warning" in cloud logging:
main.py:
Request to the team
[1]. https://stackoverflow.com/questions/65776399/why-is-my-gcp-function-logging-errors-that-should-be-info-or-debug
[2]. https://issuetracker.google.com/124403972
The text was updated successfully, but these errors were encountered: