L125: Python Abseil Logging Support#505
Conversation
sergiitk
left a comment
There was a problem hiding this comment.
LGTM, but let's ask Mark to give this a look once the remaining feedback is addressed.
L125-python-absl-logging-support.md
Outdated
| > Note that if abseil fixes https://github.com/abseil/abseil-cpp/issues/1656, | ||
| > gRPC Core itself will be able to invoke absl::InitializeLog(), but until then | ||
| > this is a workaround. |
There was a problem hiding this comment.
Looking at the ticket - I don't think its point is to allow to "Core itself" .. "to invoke absl::InitializeLog()", but to "Make absl::InitializeLog safe to be called multiple times", making the call a no-op if already been called. We'll still have to call it from Cython.
I think we should remove this block.
There was a problem hiding this comment.
Discussed IRL, to be rephrased to make it clear the call may be moved to gRPC Core depending on how abseil/abseil-cpp#1656 is resoved.
| [L117][L117]. | ||
|
|
||
| After this change, gRPC python users started seeing the warning log - | ||
| `WARNING: All log messages before absl::InitializeLog() is called are written to STDERR`. |
There was a problem hiding this comment.
How do we reproduce this? I was only able to get it printed with export GRPC_VERBOSITY=INFO (which also prints out Log level INFO is not suitable for production. Prefer WARNING or ERROR. However if you see this message in a debug environment or test environment it is safe to ignore this message., or with export GRPC_TRACE=connectivity_state (or any other module).
There was a problem hiding this comment.
I was able to reproduce by setting GRPC_VERBOSITY=debug
L125-python-absl-logging-support.md
Outdated
| _initialize() | ||
| ``` | ||
|
|
||
| ### Behaviour with multiple imports of gRPC |
There was a problem hiding this comment.
| ### Behaviour with multiple imports of gRPC | |
| ### Behavior with multiple imports of gRPC |
There was a problem hiding this comment.
This is yet another Americal vs British English differences I suppose. I was using the British English spelling, however changed as suggested now :)
addressed the feedback. @markdroth PTAL and let us know your comments too before we open for public review. |
After Core recently changed its logging system to use absl logging, gRPC python users started seeing the warning log `WARNING: All log messages before absl::InitializeLog() is called are written to STDERR.` This issue especially affects users who are indirect users of the gRPC Python library too, such as Gemini API users. `absl::InitializeLog()` is a C++ library that cannot directly be called in the Python layer. It is hence added in the Cython layer at the time of initializing. The Python layer so far did not have a dependency on the absl library, hence this PR also adds an external dependency on `absl/log:initialize` Design gRFC for this: grpc/proposal#505 ---- DO NOT SUBMIT. This PR is for testing purposes only. [cl/858528872](http://cl/858528872) [cl/858287174](http://cl/858287174) PiperOrigin-RevId: 858528872
After Core recently changed its logging system to use absl logging, gRPC python users started seeing the warning log `WARNING: All log messages before absl::InitializeLog() is called are written to STDERR.` This issue especially affects users who are indirect users of the gRPC Python library too, such as Gemini API users. `absl::InitializeLog()` is a C++ library that cannot directly be called in the Python layer. It is hence added in the Cython layer at the time of initializing. The Python layer so far did not have a dependency on the absl library, hence this PR also adds an external dependency on `absl/log:initialize` Design gRFC for this: grpc/proposal#505 ---- DO NOT SUBMIT. This PR is for testing purposes only. [cl/858528872](http://cl/858528872) [cl/858287174](http://cl/858287174) PiperOrigin-RevId: 858528872
After Core recently changed its logging system to use absl logging, gRPC python users started seeing the warning log `WARNING: All log messages before absl::InitializeLog() is called are written to STDERR.` This issue especially affects users who are indirect users of the gRPC Python library too, such as Gemini API users. `absl::InitializeLog()` is a C++ library that cannot directly be called in the Python layer. It is hence added in the Cython layer at the time of initializing. The Python layer so far did not have a dependency on the absl library, hence this PR also adds an external dependency on `absl/log:initialize` Design gRFC for this: grpc/proposal#505 ---- DO NOT SUBMIT. This PR is for testing purposes only. [cl/858528872](http://cl/858528872) [cl/858287174](http://cl/858287174) PiperOrigin-RevId: 858528872
Fixes #38703 After Core recently changed its logging system to use absl logging, gRPC python users started seeing the warning log `WARNING: All log messages before absl::InitializeLog() is called are written to STDERR.` This issue especially affects users who are indirect users of the gRPC Python library too, such as Gemini API users. `absl::InitializeLog()` is a C++ library that cannot directly be called in the Python layer. It is hence added in the Cython layer at the time of initializing. The Python layer so far did not have a dependency on the absl library, hence this PR also adds an external dependency on `absl/log:initialize` Design gRFC for this: grpc/proposal#505 Closes #39779 COPYBARA_INTEGRATE_REVIEW=#39779 from sreenithi:absl_init_log_python d53d529 PiperOrigin-RevId: 865415667
Fixes #38703 After Core recently changed its logging system to use absl logging, gRPC python users started seeing the warning log `WARNING: All log messages before absl::InitializeLog() is called are written to STDERR.` This issue especially affects users who are indirect users of the gRPC Python library too, such as Gemini API users. `absl::InitializeLog()` is a C++ library that cannot directly be called in the Python layer. It is hence added in the Cython layer at the time of initializing. The Python layer so far did not have a dependency on the absl library, hence this PR also adds an external dependency on `absl/log:initialize` Design gRFC for this: grpc/proposal#505 Closes #39779 COPYBARA_INTEGRATE_REVIEW=#39779 from sreenithi:absl_init_log_python 59eb1e5 PiperOrigin-RevId: 869586957
Fixes grpc#38703 After Core recently changed its logging system to use absl logging, gRPC python users started seeing the warning log `WARNING: All log messages before absl::InitializeLog() is called are written to STDERR.` This issue especially affects users who are indirect users of the gRPC Python library too, such as Gemini API users. `absl::InitializeLog()` is a C++ library that cannot directly be called in the Python layer. It is hence added in the Cython layer at the time of initializing. The Python layer so far did not have a dependency on the absl library, hence this PR also adds an external dependency on `absl/log:initialize` Design gRFC for this: grpc/proposal#505 Closes grpc#39779 COPYBARA_INTEGRATE_REVIEW=grpc#39779 from sreenithi:absl_init_log_python 59eb1e5 PiperOrigin-RevId: 869586957
Backport of #39779 to v1.78.x. --- Fixes #38703 After Core recently changed its logging system to use absl logging, gRPC python users started seeing the warning log `WARNING: All log messages before absl::InitializeLog() is called are written to STDERR.` This issue especially affects users who are indirect users of the gRPC Python library too, such as Gemini API users. `absl::InitializeLog()` is a C++ library that cannot directly be called in the Python layer. It is hence added in the Cython layer at the time of initializing. The Python layer so far did not have a dependency on the absl library, hence this PR also adds an external dependency on `absl/log:initialize` Design gRFC for this: grpc/proposal#505 However, abseil-cpp currently [doesn't allow `absl::InitializeLog()` to be called more than once](abseil/abseil-cpp#1656), and will result in an error like: ``` [globals.cc : 104] RAW: absl::log_internal::SetTimeZone() has already been called ``` The changes in this PR may hence cause problems to a small percentage of users with a custom build that's linking directly against gRPC Cython code, and then call absl::InitializeLog() (directly or transitively). To solve this problem, this PR also introduces a new environment variable `GRPC_PYTHON_DISABLE_ABSL_INIT_LOG` that will allow users to opt-out of this automatic abseil log initialization when set.
Proposes changes to Abseil logging initialization in gRPC Python to resolve the issue the absl warning
All log messages before absl::InitializeLog() is called are written to STDERR.Related: