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

grpc_logging payloads embedded in the classic log output #135

Closed
jhayotte opened this issue Mar 27, 2018 · 2 comments
Closed

grpc_logging payloads embedded in the classic log output #135

jhayotte opened this issue Mar 27, 2018 · 2 comments
Labels
on reporter Waiting on reporter to answer.

Comments

@jhayotte
Copy link

jhayotte commented Mar 27, 2018

Hi,

I am using most of go-grpc-middleware and I have a question regarding logs. I wish to include the payload in the standard output or have a way to correlate both of them.

In order to get, ideally, this king of output:

{
    "level": "info",									
    "msg": "finished unary call",						
    "grpc.code": "OK",								
    "grpc.method": "Ping",							
    "grpc.service": "mwitkow.testproto.TestService", 
    "grpc.start_time": "2006-01-02T15:04:05Z07:00", 
    "grpc.request.deadline": "2006-01-02T15:04:05Z07:00",
    "grpc.request.value": "something",
    "grpc.time_ms": 1.345,		
    "peer.address": {
        "IP": "127.0.0.1",			
        "Port": 60216,				
        "Zone": ""				
    },
    "span.kind": "server",			
    "system": "grpc"				
    "grpc.request.content": {		        
        "msg" : {														
            "value": "something",											
            "sleepTimeMs": 9999											
        }
    },
    "custom_field": "custom_value",					
    "custom_tags.int": 1337,							
    "custom_tags.string": "something",				
}

Below, an extract of my interceptor.

	grpc_zap.UnaryServerInterceptor(logger.Zap, opts...),
	grpc_zap.PayloadUnaryServerInterceptor(logger.Zap, alwaysLoggingDeciderServer),	

One simple way could be to pass a GUID in the context and flag both logs with it. Then we could aggregate both results in Grafana. It' not optimal but would work, though. 🤔

By the way, thanks for the amazing work!

@jhayotte jhayotte changed the title grpc_logging payloads embedded in the standard output grpc_logging payloads embedded in the classic log output Mar 27, 2018
@mwitkow
Copy link
Member

mwitkow commented Mar 31, 2018

So the reason why the payload is separate is to facilitate streaming requests: one log entry per emitted payload. This way you can flash statements as they come.

As for tagging, that's already supported. Both interceptors should be automatically adding whatever you're getting from grpc_ctxtags to every log statement made.

We are using it together with grpc_opentracing to get a request trace/span number automatically tagged.

Does this help?

@mwitkow mwitkow added the on reporter Waiting on reporter to answer. label Mar 31, 2018
@jhayotte
Copy link
Author

Thank you @mwitkow for the explanation. I close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
on reporter Waiting on reporter to answer.
Projects
None yet
Development

No branches or pull requests

2 participants