github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/go-grpc-middleware/tags/doc.go (about) 1 /* 2 `grpc_ctxtags` adds a Tag object to the context that can be used by other middleware to add context about a request. 3 4 Request Context Tags 5 6 Tags describe information about the request, and can be set and used by other middleware, or handlers. Tags are used 7 for logging and tracing of requests. Tags are populated both upwards, *and* downwards in the interceptor-handler stack. 8 9 You can automatically extract tags (in `grpc.request.<field_name>`) from request payloads. 10 11 For unary and server-streaming methods, pass in the `WithFieldExtractor` option. For client-streams and bidirectional-streams, you can 12 use `WithFieldExtractorForInitialReq` which will extract the tags from the first message passed from client to server. 13 Note the tags will not be modified for subsequent requests, so this option only makes sense when the initial message 14 establishes the meta-data for the stream. 15 16 If a user doesn't use the interceptors that initialize the `Tags` object, all operations following from an `Extract(ctx)` 17 will be no-ops. This is to ensure that code doesn't panic if the interceptors weren't used. 18 19 Tags fields are typed, and shallow and should follow the OpenTracing semantics convention: 20 https://github.com/opentracing/specification/blob/master/semantic_conventions.md 21 */ 22 package grpc_ctxtags