Open
Description
The interceptors in contrib/google.golang.org/grpc
exposes two functions to add tags for the span based on the gRPC metadata: func WithMetadataTags() Option
and func WithIgnoredMetadata(ms ...string) Option
This pattern only allows for a block-list methodology for converting Metadata to Tags, not an allow-list, or any other more sophisticated pattern.
I have three different suggestions:
- Add another option
func WithMetadataDecider(decider func(k string, v []string) bool) Option
or similar, that allows the caller (creator of the interceptor) to decide which metadata should be converted to a tag. - Add another option
func WithRecognizedMetadata(ms ...string) Option
, that would take precedence overWithIgnoredMetadata
, only adding the metadata present in thecfg.recognizedMetadata
. - Another suggestion might be to create an option that would pass in the
ctx context.Context
,req interface{}
andinfo *grpc.UnaryServerInfo
, to allow for any custom tagging, and free selecting of the tag-key, etc.