Skip to content

How to log requests and responses with interceptor in v2? #2251

@alex-vasenin-peggy

Description

@alex-vasenin-peggy

What are you trying to achieve?

I would like to have an ability to (conditionally) see contents of all messages that are sent or received via GRPCClient v2 for debug purposes. In our app we have a command line argument to enable debugging interaction with backend. Sources of ClientInterceptor has an example of LoggingInterceptor, but it only logs metadata, but not the messages.

What have you tried so far?

I tried investigation whether ClientContext, StreamingClientRequest and StreamingClientResponse has the data I need. It seems like there is no way to get sent message from the StreamingClientRequest.producer. It might be possible to get the message StreamingClientResponse.bodyParts, but I can find an example how to do it properly (and if it's safe to do at all in interceptor). Any advice on how to approach this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions