Documentation
¶
Index ¶
- Variables
- func ExpectTagsOnContext(ctx context.Context, expectedTags ...*Tag) error
- func WithComponent(ctx context.Context, component string, chained bool) context.Context
- func WithNamespaceTags(ctx context.Context, namespace string, tags ...*Tag) context.Context
- func WithTags(ctx context.Context, tags ...*Tag) context.Context
- type Key
- type Set
- type Tag
- type Type
- type Value
Constants ¶
This section is empty.
Variables ¶
var DefaultNamespace = ""
DefaultNamespace is the default namespace for tags
var EmptySet = Set{}
Functions ¶
func ExpectTagsOnContext ¶
func WithComponent ¶
WithComponent returns a new context with the component chained tag added to the default namespace set. If chained is true, the component tag will be chained to the existing component tag.
Example: WithComponent(ctx, "component1", true) will return a new context with the component tag "component1" WithComponent(ctx, "component2", true) will return a new context with the component tag "component1.component2"
If chained is false, the component tag will replace the existing component tag.
Example: WithComponent(ctx, "component1", false) will return a new context with the component tag "component1" WithComponent(ctx, "component2", false) will return a new context with the component tag "component2"
func WithNamespaceTags ¶
WithNamespaceTags returns a new context with the given added to the namespace set. The namespace set on the parent context is not modified.
Types ¶
type Key ¶
type Key string
Key represents the key part in key-value pairs. It's a string. The allowed character set in the key depends on the use of the key.
type Set ¶
type Set []*Tag
Set represents a immutable set of
func FromContext ¶
FromContext returns the set of tags from the context for the default namespace set
func FromNamespaceContext ¶
FromNamespaceContext returns the set of tags for the given namespace from the context.
type Tag ¶
A tag is a key-value pair that can be attached to a context It is used to carry metadata about a given context execution along the context chain It is primarily used for rich instrumentation of the application: logging, metrics, tracing
func Float64Tag ¶
Float64Tag creates a new tag with a 64-bit floating point value.
func (*Tag) Chained ¶
Chained flags the tag as chained. If chained is true, the tag will be chained to the existing tag with the same key. If chained is false, the tag will replace the existing tag with the same key.
Example: set := tag.EmptySet.WithTags(tag.Key("component").String("component1")) newSet := set.WithTags(tag.Key("component").String("component2").Chained(true)) newSet will be [tag.Key("component").String("component1.component2")]
type Type ¶
type Type int
Type describes the type of the Value holds.
const ( // INVALID is used for a Value with no value set. INVALID Type = iota // BOOL is a boolean Type Value. BOOL // INT64 is a 64-bit signed integral Type Value. INT64 // FLOAT64 is a 64-bit floating point Type Value. FLOAT64 // STRING is a string Type Value. STRING // OBJECT is a generic object Type Value. OBJECT // MAP is a map of tags Type Value. MAP )
type Value ¶
type Value struct {
Type Type
Interface interface{}
}
Value represents a tag value.
func Float64Value ¶
Float64Value returns a Value with a 64-bit floating point value set.
func Int64Value ¶
Int64Value returns a Value with a 64-bit signed integral value set.
func ObjectValue ¶
func ObjectValue(v interface{}) Value
ObjectValue returns a Value with a generic object value set.
func StringValue ¶
StringValue returns a Value with a string value set.