go-grpc-middleware icon indicating copy to clipboard operation
go-grpc-middleware copied to clipboard

[grpc_zap] Payload error message

Open koteesy opened this issue 4 years ago • 5 comments

Hello, when i add to my GRPC server line:

grpc_zap.PayloadUnaryServerInterceptor(logger, alwaysLoggingDeciderServer),

I see not complete log,I see incoming requests, responses, but i didn't see payload

I take

alwaysLoggingDeciderServer
from go-grpc-middleware tests folder.
alwaysLoggingDeciderServer := func(ctx context.Context, fullMethodName string, servingObject interface{}) bool {
		return true
}
{"level":"info","ts":1626187747.4904773,"caller":"zap/payload_interceptors.go:131","msg":"server response payload logged as grpc.response.content field","system":"grpc","span.kind":"server","grpc.service":"api.SimpleService","grpc.method":"DebugParse","grpc.response.content":{},"grpc.response.contentError":"json: error calling MarshalJSON for type *grpc_zap.jsonpbObjectMarshaler: jsonpb serializer failed: proto: not found"}

What i need add to see bodies of requests?

koteesy avatar Jul 13 '21 14:07 koteesy

Edit: Actually i see payload for incoming requests, but for response i see this error:

json: error calling MarshalJSON for type *grpc_zap.jsonpbObjectMarshaler: jsonpb serializer failed: proto: not found

koteesy avatar Jul 13 '21 15:07 koteesy

Could you try to narrow down what messages are causing this problem? I'm not sure what could be causing that problem, but it looks to me like that error is coming from the jsonpb serializer, which isn't something we maintain in this repo.

johanbrandhorst avatar Jul 14 '21 00:07 johanbrandhorst

Could you try to narrow down what messages are causing this problem? I'm not sure what could be causing that problem, but it looks to me like that error is coming from the jsonpb serializer, which isn't something we maintain in this repo.

This hard to do, because i have only one rpc method, i'm not returning nil, everytime i respond with crawler.CrawlerResponse, and how i understand when debug, sometimes I see information, but, for a small returned response, for example, where only the string {value: 123456} is contained. Could the problem be caused by the fact that I am returning too much data?

args.Encode(true)
is a array of bytes.
data := &crawler.CrawlerData{
   Data: &any.Any{Value: args.Encode(true)},
}

return &crawler.CrawlerResponse{Data: data, Status: status.CrawlerStatus_OK}, nil

koteesy avatar Jul 14 '21 08:07 koteesy

If it's happening intermittently, then I have no idea what could cause it, but it's unlikely to be a problem in our library. Maybe you are returning too much data, yes.

johanbrandhorst avatar Jul 15 '21 00:07 johanbrandhorst

If it's happening intermittently, then I have no idea what could cause it, but it's unlikely to be a problem in our library. Maybe you are returning too much data, yes.

on average, more than 2-3 kb are returned. I'll test this theory and let you know.

koteesy avatar Jul 15 '21 01:07 koteesy

Closing as didn't hear from you back. We can always reopen if still valid. Make sure to check v2 branch as well.

bwplotka avatar Mar 19 '23 01:03 bwplotka