Skip to content

contrib/google.golang.org/grpc: Whitelist metadata-tags #2299

Open
@bendiknesbo

Description

@bendiknesbo

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:

  1. 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.
  2. Add another option func WithRecognizedMetadata(ms ...string) Option, that would take precedence over WithIgnoredMetadata, only adding the metadata present in the cfg.recognizedMetadata.
  3. Another suggestion might be to create an option that would pass in the ctx context.Context, req interface{} and info *grpc.UnaryServerInfo, to allow for any custom tagging, and free selecting of the tag-key, etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementquick change/addition that does not need full team approval

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions