-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Context Key not set in gRPC worker thread #2535
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
Comments
FYI this is a GA-blocker for google-cloud-logging. |
This can't be fixed. The transport code works on multiple RPCs at the same time. In addition, both backtraces you provided don't have to relate to any RPC since they are connection startup. |
Ok I have a general workaround to my grpc-thread-calling-logger-which-calls-grpc woes, which is to have the logger use the bundling feature in GAX, which essentially offloads all grpc logging to a distinct thread from the thread that added the log (don't worry, it uses thread pooling). This means that one-time logs (such as the ones above for establishing the transport) are fine, because they won't repeat. There is only one log left causing a problem:
LoggerName: io.grpc.netty.NettyClientHandler This is an oddball case - it seems to be some kind of logger class that calls a logger passed into it. Is there a recommended way to turn off frame logging? Or, do I just have to hack around it like this:
I don't necessarily want to turn off all logging from the io.grpc.netty.NettyClientHandler logger, unless this is really the only thing it's ever going to log. |
Some guidance would be helpful here so I could proceed to fix the issue at the google-cloud-java level. |
I'd suggest providing your own event loop to the NettyChannelBuilder used for sending logs and then detect whether you are in that event loop when logging. If you are in the event loop, don't send the log. There may be other options, but good ones should separate the channel/code used to send logs from the rest of the application. |
Please answer these questions before submitting your issue.
What version of gRPC are you using?
1.01
What JVM are you using (
java -version
)?openjdk version "1.8.0_102"
OpenJDK Runtime Environment (build 1.8.0_102)
OpenJDK 64-Bit Server VM (build 25.102-b01, mixed mode)
What did you do?
If possible, provide a recipe for reproducing the error.
What did you expect to see?
I expected to see the Context Key set in the gRPC worker thread.
What did you see instead?
The key was not set.
Here are the stack traces where I expected it to be set, but it wasn't:
second:
The text was updated successfully, but these errors were encountered: