Documentation
¶
Overview ¶
Package contextmd allows attaching metadata to the context of RPC calls.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromContexts ¶
FromContexts returns a context derived from the first one with metadata merged from all of ctxs.
If len(ctxs) == 0, ctx is returned as is. Returns the first error or nil.
func Infof ¶
Infof is equivalent to log.V(x).Infof(...) except it also logs context metadata, if available.
func WithMetadata ¶
WithMetadata attaches metadata to the passed-in context, returning a new context. This function should be called in every test method after a context is created. It uses the already created context to generate a new one containing the metadata header.
Types ¶
type Metadata ¶
type Metadata struct { // ActionID is an optional id to use to identify an action. ActionID string // InvocationID is an optional id to use to identify an invocation spanning multiple commands. InvocationID string CorrelatedInvocationsID string // ToolName is an optional tool name to pass to the remote server for logging. ToolName string // ToolVersion is an optional tool version to pass to the remote server for logging. ToolVersion string }
Metadata is optionally attached to RPC requests.
func ExtractMetadata ¶
ExtractMetadata parses the metadata from the given context, if it exists. If metadata does not exist, empty values are returned.
func MergeMetadata ¶
MergeMetadata returns a new instance that has the tool name, tool version and correlated action id from the first argument, and joins a sorted and unique set of action IDs and invocation IDs from all arguments. Nil is never returned.