Documentation ¶
Overview ¶
Package event provides support for event based telemetry.
Index ¶
- Constants
- Variables
- func Detach(ctx context.Context) context.Context
- func Error(ctx context.Context, message string, err error, tags ...Tag)
- func Label(ctx context.Context, tags ...Tag) context.Context
- func Label1(ctx context.Context, t1 Tag) context.Context
- func Label2(ctx context.Context, t1, t2 Tag) context.Context
- func Label3(ctx context.Context, t1, t2, t3 Tag) context.Context
- func Log(ctx context.Context, tags ...Tag)
- func Log1(ctx context.Context, t1 Tag) context.Context
- func Log2(ctx context.Context, t1, t2 Tag) context.Context
- func Log3(ctx context.Context, t1, t2, t3 Tag) context.Context
- func Print(ctx context.Context, message string, tags ...Tag)
- func Print1(ctx context.Context, message string, t1 Tag)
- func Print2(ctx context.Context, message string, t1 Tag, t2 Tag)
- func Record(ctx context.Context, tags ...Tag) context.Context
- func Record1(ctx context.Context, t1 Tag) context.Context
- func Record2(ctx context.Context, t1, t2 Tag) context.Context
- func Record3(ctx context.Context, t1, t2, t3 Tag) context.Context
- func SetExporter(e Exporter)
- func StartSpan(ctx context.Context, name string, tags ...Tag) (context.Context, func())
- func StartSpan1(ctx context.Context, name string, t1 Tag) (context.Context, func())
- func StartSpan2(ctx context.Context, name string, t1, t2 Tag) (context.Context, func())
- type BooleanKey
- type ErrorKey
- type Event
- type Exporter
- type Float32Key
- type Float64Key
- type Int16Key
- type Int32Key
- type Int64Key
- type Int8Key
- type IntKey
- type Key
- type StringKey
- type Tag
- type TagIterator
- type TagMap
- type TagPointer
- type UInt16Key
- type UInt32Key
- type UInt64Key
- type UInt8Key
- type UIntKey
- type ValueKey
Constants ¶
const ( LogType // an event that should be recorded in a log StartSpanType // the start of a span of time EndSpanType // the end of a span of time LabelType // some values that should be noted for later events DetachType // an event that causes a context to detach RecordType // a value that should be tracked )
Variables ¶
var ( // Msg is a key used to add message strings to tag lists. Msg = NewStringKey("message", "a readable message") // Name is used for things like traces that have a name. Name = NewStringKey("name", "an entity name") // Err is a key used to add error values to tag lists. Err = NewErrorKey("error", "an error that occurred") )
Functions ¶
func Detach ¶
Detach returns a context without an associated span. This allows the creation of spans that are not children of the current span.
func Error ¶
Error takes a message and a tag list and combines them into a single event before delivering them to the exporter. It captures the error in the delivered event.
func Print ¶
Print takes a message and a tag list and combines them into a single event before delivering them to the exporter.
func Print1 ¶
Print1 takes a message and one tag delivers a log event to the exporter. It is a customized version of Print that is faster and does no allocation.
func Print2 ¶
Print2 takes a message and two tags and delivers a log event to the exporter. It is a customized version of Print that is faster and does no allocation.
func SetExporter ¶
func SetExporter(e Exporter)
SetExporter sets the global exporter function that handles all events. The exporter is called synchronously from the event call site, so it should return quickly so as not to hold up user code.
func StartSpan ¶
StartSpan sends a span start event with the supplied tag list to the exporter. It also returns a function that will end the span, which should normally be deferred.
func StartSpan1 ¶
StartSpan1 sends a span start event with the supplied tag list to the exporter. It also returns a function that will end the span, which should normally be deferred.
Types ¶
type BooleanKey ¶
type BooleanKey struct {
// contains filtered or unexported fields
}
BooleanKey represents a key
func NewBooleanKey ¶
func NewBooleanKey(name, description string) *BooleanKey
NewBooleanKey creates a new Key for bool values.
func (*BooleanKey) Description ¶
func (k *BooleanKey) Description() string
func (*BooleanKey) From ¶
func (k *BooleanKey) From(t Tag) bool
From can be used to get a value from a Tag.
func (*BooleanKey) Get ¶
func (k *BooleanKey) Get(tags TagMap) bool
Get can be used to get a tag for the key from a TagMap.
func (*BooleanKey) Name ¶
func (k *BooleanKey) Name() string
func (*BooleanKey) Of ¶
func (k *BooleanKey) Of(v bool) Tag
Of creates a new Tag with this key and the supplied value.
type ErrorKey ¶
type ErrorKey struct {
// contains filtered or unexported fields
}
ErrorKey represents a key
func NewErrorKey ¶
NewErrorKey creates a new Key for int64 values.
func (*ErrorKey) Description ¶
type Event ¶
Event holds the information about an event of note that ocurred.
func (Event) IsStartSpan ¶
func (Event) Tags ¶
func (ev Event) Tags() TagIterator
type Exporter ¶
Exporter is a function that handles events. It may return a modified context and event.
type Float32Key ¶
type Float32Key struct {
// contains filtered or unexported fields
}
Float32Key represents a key
func NewFloat32Key ¶
func NewFloat32Key(name, description string) *Float32Key
NewFloat32Key creates a new Key for float32 values.
func (*Float32Key) Description ¶
func (k *Float32Key) Description() string
func (*Float32Key) From ¶
func (k *Float32Key) From(t Tag) float32
From can be used to get a value from a Tag.
func (*Float32Key) Get ¶
func (k *Float32Key) Get(tags TagMap) float32
Get can be used to get a tag for the key from a TagMap.
func (*Float32Key) Name ¶
func (k *Float32Key) Name() string
func (*Float32Key) Of ¶
func (k *Float32Key) Of(v float32) Tag
Of creates a new Tag with this key and the supplied value.
type Float64Key ¶
type Float64Key struct {
// contains filtered or unexported fields
}
Float64Key represents a key
func NewFloat64Key ¶
func NewFloat64Key(name, description string) *Float64Key
NewFloat64Key creates a new Key for int64 values.
func (*Float64Key) Description ¶
func (k *Float64Key) Description() string
func (*Float64Key) From ¶
func (k *Float64Key) From(t Tag) float64
From can be used to get a value from a Tag.
func (*Float64Key) Get ¶
func (k *Float64Key) Get(tags TagMap) float64
Get can be used to get a tag for the key from a TagMap.
func (*Float64Key) Name ¶
func (k *Float64Key) Name() string
func (*Float64Key) Of ¶
func (k *Float64Key) Of(v float64) Tag
Of creates a new Tag with this key and the supplied value.
type Int16Key ¶
type Int16Key struct {
// contains filtered or unexported fields
}
Int16Key represents a key
func NewInt16Key ¶
NewInt16Key creates a new Key for int16 values.
func (*Int16Key) Description ¶
type Int32Key ¶
type Int32Key struct {
// contains filtered or unexported fields
}
Int32Key represents a key
func NewInt32Key ¶
NewInt32Key creates a new Key for int32 values.
func (*Int32Key) Description ¶
type Int64Key ¶
type Int64Key struct {
// contains filtered or unexported fields
}
Int64Key represents a key
func NewInt64Key ¶
NewInt64Key creates a new Key for int64 values.
func (*Int64Key) Description ¶
type Int8Key ¶
type Int8Key struct {
// contains filtered or unexported fields
}
Int8Key represents a key
func NewInt8Key ¶
NewInt8Key creates a new Key for int8 values.
func (*Int8Key) Description ¶
type IntKey ¶
type IntKey struct {
// contains filtered or unexported fields
}
IntKey represents a key
func (*IntKey) Description ¶
type Key ¶
type Key interface { // Name returns the key name. Name() string // Description returns a string that can be used to describe the value. Description() string }
Key is the interface shared by all key implementations.
type StringKey ¶
type StringKey struct {
// contains filtered or unexported fields
}
StringKey represents a key
func NewStringKey ¶
NewStringKey creates a new Key for int64 values.
func (*StringKey) Description ¶
type Tag ¶
type Tag struct { Key Key // contains filtered or unexported fields }
Tag holds a key and value pair. It is normally used when passing around lists of tags.
type TagIterator ¶
type TagIterator struct {
// contains filtered or unexported fields
}
TagIterator is used to iterate through tags using TagPointer. It is a small helper that will normally fully inline to make it easier to manage the fact that pointer advance returns a new pointer rather than moving the existing one.
func ChainTagIterators ¶
func ChainTagIterators(iterators ...TagIterator) TagIterator
func Filter ¶
func Filter(it TagIterator, keys ...Key) TagIterator
func NewTagIterator ¶
func NewTagIterator(tags ...Tag) TagIterator
func (*TagIterator) Advance ¶
func (i *TagIterator) Advance()
func (*TagIterator) Tag ¶
func (i *TagIterator) Tag() Tag
func (*TagIterator) Valid ¶
func (i *TagIterator) Valid() bool
type TagMap ¶
type TagMap interface { // Find returns the tag that matches the supplied key. Find(key interface{}) Tag }
TagMap is the interface to a collection of Tags indexed by key.
func MergeTagMaps ¶
type TagPointer ¶
type TagPointer interface { // Next advances to the next entry in the list and return a TagIterator for it. // It will return nil if there are no more entries. Next() TagPointer // Tag returns the tag the pointer is for. Tag() Tag }
TagPointer is the interface to something that provides an iterable list of tags.
type UInt16Key ¶
type UInt16Key struct {
// contains filtered or unexported fields
}
UInt16Key represents a key
func NewUInt16Key ¶
NewUInt16Key creates a new Key for uint16 values.
func (*UInt16Key) Description ¶
type UInt32Key ¶
type UInt32Key struct {
// contains filtered or unexported fields
}
UInt32Key represents a key
func NewUInt32Key ¶
NewUInt32Key creates a new Key for uint32 values.
func (*UInt32Key) Description ¶
type UInt64Key ¶
type UInt64Key struct {
// contains filtered or unexported fields
}
UInt64Key represents a key
func NewUInt64Key ¶
NewUInt64Key creates a new Key for uint64 values.
func (*UInt64Key) Description ¶
type UInt8Key ¶
type UInt8Key struct {
// contains filtered or unexported fields
}
UInt8Key represents a key
func NewUInt8Key ¶
NewUInt8Key creates a new Key for uint8 values.
func (*UInt8Key) Description ¶
type UIntKey ¶
type UIntKey struct {
// contains filtered or unexported fields
}
UIntKey represents a key
func NewUIntKey ¶
NewUIntKey creates a new Key for uint values.
func (*UIntKey) Description ¶
type ValueKey ¶
type ValueKey struct {
// contains filtered or unexported fields
}
ValueKey represents a key for untyped values.