-
Notifications
You must be signed in to change notification settings - Fork 125
Description
atlas-app-toolkit/logging/interceptor.go
Lines 65 to 72 in c488b8e
func UnaryClientInterceptor(entry *logrus.Entry, opts ...Option) grpc.UnaryClientInterceptor { | |
options := initOptions(opts) | |
return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { | |
startTime := time.Now() | |
fields := newLoggerFields(method, startTime, DefaultClientKindValue) | |
setInterceptorFields(ctx, fields, entry.Logger, options, startTime) |
I'm curious what the use cases for this client interceptor are and if they work. The way it's implemented, it doesn't seem to do anything useful. It adds fields like account_id
to the logger sourced from the incoming metadata, while clients utilize outgoing metadata. This is probably a bug. It seems like it would be more valuable to log the subject that is being used in the client, not the subject used in whatever call triggered it (which is only set for service-to-service cases, like the test exercises). In the service-to-service case, I would expect these fields to already be set in the logger by the server interceptor, meaning the client interceptor isn't adding anything beyond what the logrus client interceptor already does.