Skip to content
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

Ability to configure internal logging level #2098

Closed
gao-artur opened this issue Apr 18, 2023 · 2 comments · Fixed by #2106
Closed

Ability to configure internal logging level #2098

gao-artur opened this issue Apr 18, 2023 · 2 comments · Fixed by #2106
Labels
enhancement New feature or request
Milestone

Comments

@gao-artur
Copy link

Today, when the retry policy is configured to handle Unavailable status, for example, each retry will be logged as an error.

fail: Grpc.Net.Client.Internal.GrpcCall[6]
      Error starting gRPC call.
      Grpc.Core.RpcException: Status(StatusCode="Unavailable", Detail="Error connecting to subchannel.", DebugException="System.Net.Sockets.SocketException (10061): No connection could be made because the target machine actively refused it.
         at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
         at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
         at System.Net.Sockets.Socket.<ConnectAsync>g__WaitForConnectWithCancellation|281_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken)
         at Grpc.Net.Client.Balancer.Internal.SocketConnectivitySubchannelTransport.TryConnectAsync(ConnectContext context)")
         at Grpc.Net.Client.Balancer.Internal.ConnectionManager.PickAsync(PickContext context, Boolean waitForReady, CancellationToken cancellationToken)
         at Grpc.Net.Client.Balancer.Internal.BalancerHttpHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
         at Grpc.Net.Client.Internal.GrpcCall`2.RunCall(HttpRequestMessage request, Nullable`1 timeout)

This creates undesirable noise in the error channel. If the connection succeeds after a few retries, I'd want to see all the retry failures as warnings. And since the library throws RpcException after the final failure, the application writer can decide what logging level is appropriate in each case.

The simple fix would be to change the _errorStartingCall level from Error to Warning.

The more flexible solution would allow users to override specific message levels similar to how it's implemented in EF Core.

Currently, we just suppress all messages from the Grpc.Net.Client.Internal.GrpcCall namespace, which is not the perfect solution as the client may look stuck if a long retry policy is used.

@gao-artur gao-artur added the enhancement New feature or request label Apr 18, 2023
@JamesNK
Copy link
Member

JamesNK commented Apr 26, 2023

This should be changed.

Options:

  1. Either lower the log level to info all the time.
  2. Lower the log level only if the call will be retried.

@JamesNK JamesNK added this to the 8.0 milestone Apr 26, 2023
@gao-artur
Copy link
Author

I vote for option 1. With the option 2 the error will be logged twice: once by the library, then once again by the user code. The first log also not very useful for the user because it doesn't include failed service and method name and the stuck trace won't include the call path in the user app, hence it's imposible to understand which call failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants