Is there a python interceptor that generates access logs?

458 views
Skip to first unread message

ross.va...@cleardata.com

unread,
Feb 6, 2019, 12:12:12 PM2/6/19
to grpc.io
Hello,

I'm working on a grpc service in python and would like to have the server write simple access logs.  Seems like someone else has probably run into that, but I can't find an existing interceptor. Is there one out there?

Thanks,
Ross

Carl Mastrangelo

unread,
Feb 6, 2019, 12:37:38 PM2/6/19
to grpc.io
There was some work on binary logs to dump the traffic to disk (for replay), but It wasn't anything like access logs.   I assume you mean something like Apache's log per request.  

If you are considering writing one, I foresee a few problems:

1.  Streaming calls may take a long time.  Should the beginning or end be logged, or both?
2.  Request size is tricky.   Do you include the headers and trailers?  
3.  Writing and flushing to disk (or to a remote log service) might need some buffering considerations.

Ross Vandegrift

unread,
Feb 7, 2019, 11:39:41 AM2/7/19
to grp...@googlegroups.com
On Wed, 2019-02-06 at 09:37 -0800, 'Carl Mastrangelo' via grpc.io wrote:
> There was some work on binary logs to dump the traffic to disk (for replay),
> but It wasn't anything like access logs. I assume you mean something like
> Apache's log per request.

Yes, that's what I'm thinking. Mostly just to provide simple troubleshooting
info for developers. I might write one, thanks for the list of potential
pitfalls.

Side concern: it seems like most of the grpc ecosystem is built around golang.
Is it silly to start a new grpc python service in 2019?

Thanks for the feedback,
Ross

robert engels

unread,
Feb 7, 2019, 12:25:59 PM2/7/19
to Ross Vandegrift, grp...@googlegroups.com
Might be a better question, is it silly to start any python service in 2019, given the alternatives available like Go. :)
> --
> You received this message because you are subscribed to the Google Groups "grpc.io" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
> To post to this group, send email to grp...@googlegroups.com.
> Visit this group at https://groups.google.com/group/grpc-io.
> To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/a5b37cab4e8da160ab3b7665e57578426c354e1b.camel%40cleardata.com.
> For more options, visit https://groups.google.com/d/optout.

Carl Mastrangelo

unread,
Feb 7, 2019, 1:59:17 PM2/7/19
to grpc.io
I work on the gRPC Java implementation, but I actually use the Go version (server and client).  It has been very easy to get started and deploy.   I would recommend the Go version since you can forget about almost all threading issues in your server handler.

ross.va...@cleardata.com

unread,
Feb 26, 2019, 12:44:14 PM2/26/19
to grpc.io
For the archives: the design of the python grpc server-side interceptors cannot support request logging.  The request details are not available to the interceptor.  This is by design - see https://github.com/grpc/proposal/blob/master/L13-python-interceptors.md#server-side-implementation

Ross

On Wednesday, February 6, 2019 at 9:12:12 AM UTC-8, ross.va...@cleardata.com wrote:
Reply all
Reply to author
Forward
0 new messages