grpc-ecosystem / go-grpc-middleware

Golang gRPC Middlewares: interceptor chaining, auth, logging, retries and more.
Apache License 2.0
6.26k stars 690 forks source link

interceptors: Update logging interceptor Reporter to re-extract fields from context before logging #702

Closed chancez closed 5 months ago

chancez commented 5 months ago

When using logging.WithFieldsFromContext, if the value being extracted as a log field is modified after the logging interceptor initializes the Reporter before the underlying handler is called, then the updated value will not be reflected in the log message.

To fix this, re-extract fields from the context before logging them in PostCall, PostMsgSend and PostMsgReceive, ensuring the updated values in the context are logged.

Changes

Verification

chancez commented 5 months ago

Wow thanks for the promptness!