[print backtrace] Print exception backtrace for all exceptions#33442
Merged
XuanWang-Amos merged 4 commits intogrpc:masterfrom Jul 27, 2023
Merged
[print backtrace] Print exception backtrace for all exceptions#33442XuanWang-Amos merged 4 commits intogrpc:masterfrom
XuanWang-Amos merged 4 commits intogrpc:masterfrom
Conversation
gnossen
reviewed
Jun 15, 2023
| ) | ||
| traceback.print_exc() | ||
| traceback.print_exc() | ||
| _LOGGER.exception(details) |
Contributor
There was a problem hiding this comment.
As discussed, let's also log this via the _LOGGER. This will ensure that the message shows up:
- On STDERR when no logging sink has been configured.
- In the log file, if it is not combined with STDERR.
Contributor
Author
There was a problem hiding this comment.
Sure, since we're already logging printable exceptions, I'll just add _LOGGER support for un-printable exceptions.
Contributor
|
Please manually test and link the logs to the PR. |
Contributor
Author
Added to PR description. |
gnossen
approved these changes
Jul 27, 2023
mario-vimal
pushed a commit
to mario-vimal/grpc
that referenced
this pull request
Jul 27, 2023
…33442) Action item from: grpc#33364 <!-- If you know who should review your pull request, please assign it to that person, otherwise the pull request would get assigned randomly. If your pull request is for a specific language, please add the appropriate lang label. --> ### Before change: * Printable Exception (Only printing exception): ``` ERROR:grpc._server:Exception calling application: Test exception Traceback (most recent call last): File "/usr/local/google/home/xuanwn/.cache/bazel/_bazel_xuanwn/da3828576aa39e99a5c826cc2e2e22fb/sandbox/linux-sandbox/2110/execroot/com_github_grpc_grpc/bazel-out/k8-fastbuild/bin/src/python/grpcio_tests/tests/unit/_metadata_test.native.runfiles/com_github_grpc_grpc/src/python/grpcio/grpc/_server.py", line 561, in _call_behavior raise TestException grpc._server.TestException: Test exception ERROR ``` * Un-Printable Exception (Only printing traceback): ``` Traceback (most recent call last): File "/usr/local/google/home/xuanwn/.cache/bazel/_bazel_xuanwn/da3828576aa39e99a5c826cc2e2e22fb/sandbox/linux-sandbox/2112/execroot/com_github_grpc_grpc/bazel-out/k8-fastbuild/bin/src/python/grpcio_tests/tests/unit/_metadata_test.native.runfiles/com_github_grpc_grpc/src/python/grpcio/grpc/_server.py", line 561, in _call_behavior raise TestException grpc._server.TestException: <unprintable TestException object> During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/google/home/xuanwn/.cache/bazel/_bazel_xuanwn/da3828576aa39e99a5c826cc2e2e22fb/sandbox/linux-sandbox/2112/execroot/com_github_grpc_grpc/bazel-out/k8-fastbuild/bin/src/python/grpcio_tests/tests/unit/_metadata_test.native.runfiles/com_github_grpc_grpc/src/python/grpcio/grpc/_server.py", line 574, in _call_behavior details = "Exception calling application: {}".format( File "/usr/local/google/home/xuanwn/.cache/bazel/_bazel_xuanwn/da3828576aa39e99a5c826cc2e2e22fb/sandbox/linux-sandbox/2112/execroot/com_github_grpc_grpc/bazel-out/k8-fastbuild/bin/src/python/grpcio_tests/tests/unit/_metadata_test.native.runfiles/com_github_grpc_grpc/src/python/grpcio/grpc/_server.py", line 536, in __str__ return 'Test exception {0}'.format(self.val) AttributeError: 'TestException' object has no attribute 'val' ERROR:grpc._server:Calling application raised unprintable Exception! Traceback (most recent call last): File "/usr/local/google/home/xuanwn/.cache/bazel/_bazel_xuanwn/da3828576aa39e99a5c826cc2e2e22fb/sandbox/linux-sandbox/2112/execroot/com_github_grpc_grpc/bazel-out/k8-fastbuild/bin/src/python/grpcio_tests/tests/unit/_metadata_test.native.runfiles/com_github_grpc_grpc/src/python/grpcio/grpc/_server.py", line 561, in _call_behavior raise TestException grpc._server.TestException: <unprintable TestException object> ERROR ``` ### After change: * Printable Exception (Printing both exception and traceback): ``` Traceback (most recent call last): File "/usr/local/google/home/xuanwn/.cache/bazel/_bazel_xuanwn/da3828576aa39e99a5c826cc2e2e22fb/sandbox/linux-sandbox/2114/execroot/com_github_grpc_grpc/bazel-out/k8-fastbuild/bin/src/python/grpcio_tests/tests/unit/_metadata_test.native.runfiles/com_github_grpc_grpc/src/python/grpcio/grpc/_server.py", line 561, in _call_behavior raise TestException grpc._server.TestException: Test exception ERROR:grpc._server:Exception calling application: Test exception Traceback (most recent call last): File "/usr/local/google/home/xuanwn/.cache/bazel/_bazel_xuanwn/da3828576aa39e99a5c826cc2e2e22fb/sandbox/linux-sandbox/2114/execroot/com_github_grpc_grpc/bazel-out/k8-fastbuild/bin/src/python/grpcio_tests/tests/unit/_metadata_test.native.runfiles/com_github_grpc_grpc/src/python/grpcio/grpc/_server.py", line 561, in _call_behavior raise TestException grpc._server.TestException: Test exception ERROR ``` * Un-Printable Exception (Printing both exception and traceback): ``` ERROR:grpc._server:['Traceback (most recent call last):\n', ' File "/usr/local/google/home/xuanwn/.cache/bazel/_bazel_xuanwn/da3828576aa39e99a5c826cc2e2e22fb/sandbox/linux-sandbox/2116/execroot/com_github_grpc_grpc/bazel-out/k8-fastbuild/bin/src/python/grpcio_tests/tests/unit/_metadata_test.native.runfiles/com_github_grpc_grpc/src/python/grpcio/grpc/_server.py", line 561, in _call_behavior\n raise TestException\n', 'grpc._server.TestException: <unprintable TestException object>\n'] Traceback (most recent call last): File "/usr/local/google/home/xuanwn/.cache/bazel/_bazel_xuanwn/da3828576aa39e99a5c826cc2e2e22fb/sandbox/linux-sandbox/2116/execroot/com_github_grpc_grpc/bazel-out/k8-fastbuild/bin/src/python/grpcio_tests/tests/unit/_metadata_test.native.runfiles/com_github_grpc_grpc/src/python/grpcio/grpc/_server.py", line 561, in _call_behavior raise TestException grpc._server.TestException: <unprintable TestException object> During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/google/home/xuanwn/.cache/bazel/_bazel_xuanwn/da3828576aa39e99a5c826cc2e2e22fb/sandbox/linux-sandbox/2116/execroot/com_github_grpc_grpc/bazel-out/k8-fastbuild/bin/src/python/grpcio_tests/tests/unit/_metadata_test.native.runfiles/com_github_grpc_grpc/src/python/grpcio/grpc/_server.py", line 574, in _call_behavior details = "Exception calling application: {}".format( File "/usr/local/google/home/xuanwn/.cache/bazel/_bazel_xuanwn/da3828576aa39e99a5c826cc2e2e22fb/sandbox/linux-sandbox/2116/execroot/com_github_grpc_grpc/bazel-out/k8-fastbuild/bin/src/python/grpcio_tests/tests/unit/_metadata_test.native.runfiles/com_github_grpc_grpc/src/python/grpcio/grpc/_server.py", line 536, in __str__ return 'Test exception {0}'.format(self.val) AttributeError: 'TestException' object has no attribute 'val' Traceback (most recent call last): File "/usr/local/google/home/xuanwn/.cache/bazel/_bazel_xuanwn/da3828576aa39e99a5c826cc2e2e22fb/sandbox/linux-sandbox/2116/execroot/com_github_grpc_grpc/bazel-out/k8-fastbuild/bin/src/python/grpcio_tests/tests/unit/_metadata_test.native.runfiles/com_github_grpc_grpc/src/python/grpcio/grpc/_server.py", line 561, in _call_behavior raise TestException grpc._server.TestException: <unprintable TestException object> ERROR:grpc._server:Calling application raised unprintable Exception! Traceback (most recent call last): File "/usr/local/google/home/xuanwn/.cache/bazel/_bazel_xuanwn/da3828576aa39e99a5c826cc2e2e22fb/sandbox/linux-sandbox/2116/execroot/com_github_grpc_grpc/bazel-out/k8-fastbuild/bin/src/python/grpcio_tests/tests/unit/_metadata_test.native.runfiles/com_github_grpc_grpc/src/python/grpcio/grpc/_server.py", line 561, in _call_behavior raise TestException grpc._server.TestException: <unprintable TestException object> ERROR ```
mario-vimal
pushed a commit
to mario-vimal/grpc
that referenced
this pull request
Jul 27, 2023
…33442) Action item from: grpc#33364 <!-- If you know who should review your pull request, please assign it to that person, otherwise the pull request would get assigned randomly. If your pull request is for a specific language, please add the appropriate lang label. --> ### Before change: * Printable Exception (Only printing exception): ``` ERROR:grpc._server:Exception calling application: Test exception Traceback (most recent call last): File "/usr/local/google/home/xuanwn/.cache/bazel/_bazel_xuanwn/da3828576aa39e99a5c826cc2e2e22fb/sandbox/linux-sandbox/2110/execroot/com_github_grpc_grpc/bazel-out/k8-fastbuild/bin/src/python/grpcio_tests/tests/unit/_metadata_test.native.runfiles/com_github_grpc_grpc/src/python/grpcio/grpc/_server.py", line 561, in _call_behavior raise TestException grpc._server.TestException: Test exception ERROR ``` * Un-Printable Exception (Only printing traceback): ``` Traceback (most recent call last): File "/usr/local/google/home/xuanwn/.cache/bazel/_bazel_xuanwn/da3828576aa39e99a5c826cc2e2e22fb/sandbox/linux-sandbox/2112/execroot/com_github_grpc_grpc/bazel-out/k8-fastbuild/bin/src/python/grpcio_tests/tests/unit/_metadata_test.native.runfiles/com_github_grpc_grpc/src/python/grpcio/grpc/_server.py", line 561, in _call_behavior raise TestException grpc._server.TestException: <unprintable TestException object> During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/google/home/xuanwn/.cache/bazel/_bazel_xuanwn/da3828576aa39e99a5c826cc2e2e22fb/sandbox/linux-sandbox/2112/execroot/com_github_grpc_grpc/bazel-out/k8-fastbuild/bin/src/python/grpcio_tests/tests/unit/_metadata_test.native.runfiles/com_github_grpc_grpc/src/python/grpcio/grpc/_server.py", line 574, in _call_behavior details = "Exception calling application: {}".format( File "/usr/local/google/home/xuanwn/.cache/bazel/_bazel_xuanwn/da3828576aa39e99a5c826cc2e2e22fb/sandbox/linux-sandbox/2112/execroot/com_github_grpc_grpc/bazel-out/k8-fastbuild/bin/src/python/grpcio_tests/tests/unit/_metadata_test.native.runfiles/com_github_grpc_grpc/src/python/grpcio/grpc/_server.py", line 536, in __str__ return 'Test exception {0}'.format(self.val) AttributeError: 'TestException' object has no attribute 'val' ERROR:grpc._server:Calling application raised unprintable Exception! Traceback (most recent call last): File "/usr/local/google/home/xuanwn/.cache/bazel/_bazel_xuanwn/da3828576aa39e99a5c826cc2e2e22fb/sandbox/linux-sandbox/2112/execroot/com_github_grpc_grpc/bazel-out/k8-fastbuild/bin/src/python/grpcio_tests/tests/unit/_metadata_test.native.runfiles/com_github_grpc_grpc/src/python/grpcio/grpc/_server.py", line 561, in _call_behavior raise TestException grpc._server.TestException: <unprintable TestException object> ERROR ``` ### After change: * Printable Exception (Printing both exception and traceback): ``` Traceback (most recent call last): File "/usr/local/google/home/xuanwn/.cache/bazel/_bazel_xuanwn/da3828576aa39e99a5c826cc2e2e22fb/sandbox/linux-sandbox/2114/execroot/com_github_grpc_grpc/bazel-out/k8-fastbuild/bin/src/python/grpcio_tests/tests/unit/_metadata_test.native.runfiles/com_github_grpc_grpc/src/python/grpcio/grpc/_server.py", line 561, in _call_behavior raise TestException grpc._server.TestException: Test exception ERROR:grpc._server:Exception calling application: Test exception Traceback (most recent call last): File "/usr/local/google/home/xuanwn/.cache/bazel/_bazel_xuanwn/da3828576aa39e99a5c826cc2e2e22fb/sandbox/linux-sandbox/2114/execroot/com_github_grpc_grpc/bazel-out/k8-fastbuild/bin/src/python/grpcio_tests/tests/unit/_metadata_test.native.runfiles/com_github_grpc_grpc/src/python/grpcio/grpc/_server.py", line 561, in _call_behavior raise TestException grpc._server.TestException: Test exception ERROR ``` * Un-Printable Exception (Printing both exception and traceback): ``` ERROR:grpc._server:['Traceback (most recent call last):\n', ' File "/usr/local/google/home/xuanwn/.cache/bazel/_bazel_xuanwn/da3828576aa39e99a5c826cc2e2e22fb/sandbox/linux-sandbox/2116/execroot/com_github_grpc_grpc/bazel-out/k8-fastbuild/bin/src/python/grpcio_tests/tests/unit/_metadata_test.native.runfiles/com_github_grpc_grpc/src/python/grpcio/grpc/_server.py", line 561, in _call_behavior\n raise TestException\n', 'grpc._server.TestException: <unprintable TestException object>\n'] Traceback (most recent call last): File "/usr/local/google/home/xuanwn/.cache/bazel/_bazel_xuanwn/da3828576aa39e99a5c826cc2e2e22fb/sandbox/linux-sandbox/2116/execroot/com_github_grpc_grpc/bazel-out/k8-fastbuild/bin/src/python/grpcio_tests/tests/unit/_metadata_test.native.runfiles/com_github_grpc_grpc/src/python/grpcio/grpc/_server.py", line 561, in _call_behavior raise TestException grpc._server.TestException: <unprintable TestException object> During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/google/home/xuanwn/.cache/bazel/_bazel_xuanwn/da3828576aa39e99a5c826cc2e2e22fb/sandbox/linux-sandbox/2116/execroot/com_github_grpc_grpc/bazel-out/k8-fastbuild/bin/src/python/grpcio_tests/tests/unit/_metadata_test.native.runfiles/com_github_grpc_grpc/src/python/grpcio/grpc/_server.py", line 574, in _call_behavior details = "Exception calling application: {}".format( File "/usr/local/google/home/xuanwn/.cache/bazel/_bazel_xuanwn/da3828576aa39e99a5c826cc2e2e22fb/sandbox/linux-sandbox/2116/execroot/com_github_grpc_grpc/bazel-out/k8-fastbuild/bin/src/python/grpcio_tests/tests/unit/_metadata_test.native.runfiles/com_github_grpc_grpc/src/python/grpcio/grpc/_server.py", line 536, in __str__ return 'Test exception {0}'.format(self.val) AttributeError: 'TestException' object has no attribute 'val' Traceback (most recent call last): File "/usr/local/google/home/xuanwn/.cache/bazel/_bazel_xuanwn/da3828576aa39e99a5c826cc2e2e22fb/sandbox/linux-sandbox/2116/execroot/com_github_grpc_grpc/bazel-out/k8-fastbuild/bin/src/python/grpcio_tests/tests/unit/_metadata_test.native.runfiles/com_github_grpc_grpc/src/python/grpcio/grpc/_server.py", line 561, in _call_behavior raise TestException grpc._server.TestException: <unprintable TestException object> ERROR:grpc._server:Calling application raised unprintable Exception! Traceback (most recent call last): File "/usr/local/google/home/xuanwn/.cache/bazel/_bazel_xuanwn/da3828576aa39e99a5c826cc2e2e22fb/sandbox/linux-sandbox/2116/execroot/com_github_grpc_grpc/bazel-out/k8-fastbuild/bin/src/python/grpcio_tests/tests/unit/_metadata_test.native.runfiles/com_github_grpc_grpc/src/python/grpcio/grpc/_server.py", line 561, in _call_behavior raise TestException grpc._server.TestException: <unprintable TestException object> ERROR ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Action item from: #33364
Before change:
After change: