-
Notifications
You must be signed in to change notification settings - Fork 699
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
Logging interceptor does not correctly log client calls sent from a server #613
Comments
I'm happy to contribute a fix, but I'm not sure what the best solution is. The simplest solution would be to override the fields in the context, but this would break the current API which allows you to manually override fields by setting them in the context before the logger is called. Another solution could be to support multiple context markers, one for the default context and another for the user-provided context. |
@bwplotka refactored these for the v2 release, unfortunately I don't know what the best solution is here either. |
Fixes: #613 Signed-off-by: bwplotka <bwplotka@gmail.com>
Thanks for reporting--especially before 2.0! This is indeed surprising and wrong. We have to establish a policy for inheriting & overriding the fields from context. Initially I thought it would be easier if those would be immutable, but for such cases it's clearly wrong idea as e.g. component is changing all the time depends where we log from. Flipped in #616 |
Fixes: #613 Signed-off-by: bwplotka <bwplotka@gmail.com>
Just glad I caught it in our logs 🙏🏼 .
The more I think about it, the more I agree that new should override old (that's generally what you'd expect from |
Go version used: 1.20
What happened:
While testing the logging interceptor, I noticed duplicate logs at different levels. In trying to debug the issue, I realized that the issue was occurring because the logging interceptor does not override context keys that already exist and the server handler was calling a client method, passing through the context.
Sample logs:
What you expected to happen:
I expect the client logs to expose client request metadata, not server metadata.
How to reproduce it (as minimally and precisely as possible):
The text was updated successfully, but these errors were encountered: