Package tag provides support for telemetry tagging.
Package tag provides support for telemetry tagging. This package is a thin shim over contexts with the main addition being the the ability to observe when contexts get tagged with new values.
Get collects a set of values from the context and returns them as a tag list.
Of returns a Tag for a key and value. This is a trivial helper that makes common logging easier to read.
Tags collects a list of tags for the taggers from the context.
With is roughly equivalent to context.WithValue except that it also notifies registered observers. Unlike WithValue, it takes a list of tags so that you can set many values at once if needed. Each call to With results in one invocation of each observer.
Key represents the key for a context tag. It is a helper to make use of context tagging slightly easier to read, it is not strictly needed to use it at all. It is intended that your common tagging keys are declared as constants of this type, and then you can use the methods of this type to apply and find those values in the context.
Of creates a new Tag with this key and the supplied value. You can use this when building a tag list.
Tag can be used to get a tag for the key from a context. It makes Key conform to the Tagger interface.
With applies sets this key to the supplied value on the context and returns the new context generated. It uses the With package level function so that observers are also notified.
Tagger is the interface to something that returns a Tag given a context. Both Tag itself and Key support this interface, allowing methods that can take either (and other implementations as well)