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

v2: WithFieldExtractorForInitialReq equivalent #592

Open
fparga opened this issue Jun 14, 2023 · 1 comment
Open

v2: WithFieldExtractorForInitialReq equivalent #592

fparga opened this issue Jun 14, 2023 · 1 comment

Comments

@fparga
Copy link

fparga commented Jun 14, 2023

The old grpc_ctxtags interceptor had an option WithFieldExtractorForInitialReq, to extract the tags from the first message passed from client to server.

For client-streams and bidirectional-streams, you can use WithFieldExtractorForInitialReq which will extract the tags from the first message passed from client to server. Note the tags will not be modified for subsequent requests, so this option only makes sense when the initial message establishes the meta-data for the stream.
https://pkg.go.dev/github.com/grpc-ecosystem/go-grpc-middleware/tags#hdr-Request_Context_Tags

Now that grpc_ctxtags has been removed, what would be the right way to do this?

grpc_ctxtags interceptor was removed. Custom tags can be added to logging fields using logging.InjectFields. Proto option to add logging field was clunky in practice and we don't see any use of it nowadays, so it's removed.

The README mentions that logging.InjectFields should be used, but can it be used to add fields using the content of the first message received on a stream?

@fparga
Copy link
Author

fparga commented Jun 19, 2023

I tried wrapping the stream, and setting the context of the wrapped stream in the RecvMsg on first message, but no luck, looks like the logging interceptor doesn't get the new context, even in the logging.FinishCall.

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

No branches or pull requests

1 participant