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