Documentation ¶
Overview ¶
Package event provides support for event based telemetry.
Index ¶
- Constants
- Variables
- func Debugf(ctx context.Context, message string, args ...interface{})
- 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, 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
- func (ev Event) Find(key Key) Tag
- func (ev Event) Format(f fmt.State, r rune)
- func (ev Event) IsDetach() bool
- func (ev Event) IsEndSpan() bool
- func (ev Event) IsLabel() bool
- func (ev Event) IsLog() bool
- func (ev Event) IsRecord() bool
- func (ev Event) IsStartSpan() bool
- func (ev Event) Tag(index int) Tag
- func (ev Event) Valid(index int) bool
- type Exporter
- type Float32Key
- type Float64Key
- type Int16Key
- type Int32Key
- type Int64Key
- type Int8Key
- type IntKey
- type Key
- type StringKey
- type Tag
- type TagList
- type TagMap
- 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 Debugf ¶
Debugf sends a log event with the supplied message to the exporter. This is intended only for temporary debugging lines, and usage should not normally be checked in, preffering structured log events for things that have to be used in production.
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 ¶
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 // Format is used in formatting to append the value of the tag to the // supplied buffer. // The formatter may use the supplied buf as a scratch area to avoid // allocations. Format(w io.Writer, buf []byte, tag Tag) }
Key is used as the identity of a Tag. Keys are intended to be compared by pointer only, the name should be unique for communicating with external systems, but it is not required or enforced.
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 {
// contains filtered or unexported fields
}
Tag holds a key and value pair. It is normally used when passing around lists of tags.
func TagOf64 ¶
TagOf64 creates a new tag from a key and a uint64. This is often used for non uint64 values that can be packed into a uint64. This method is for implementing new key types, tag creation should normally be done with the Of method of the key.
func TagOfString ¶
TagOfString creates a new tag from a key and a string. This method is for implementing new key types, tag creation should normally be done with the Of method of the key.
func TagOfValue ¶
TagOfValue creates a new tag from the key and value. This method is for implementing new key types, tag creation should normally be done with the Of method of the key.
func (Tag) Unpack64 ¶
Unpack64 assumes the tag was built using TagOf64 and returns the value that was passed to that constructor. This method is for implementing new key types, for type safety normal access should be done with the From method of the key.
func (Tag) UnpackString ¶
UnpackString assumes the tag was built using TagOfString and returns the value that was passed to that constructor. This method is for implementing new key types, for type safety normal access should be done with the From method of the key.
func (Tag) UnpackValue ¶
func (t Tag) UnpackValue() interface{}
UnpackValue assumes the tag was built using TagOfValue and returns the value that was passed to that constructor. This method is for implementing new key types, for type safety normal access should be done with the From method of the key.
type TagList ¶
type TagList interface { // Valid returns true if the index is within range for the list. // It does not imply the tag at that index will itself be valid. Valid(index int) bool // Tag returns the tag at the given index. Tag(index int) Tag }
TagList is the interface to something that provides an iterable list of tags. Iteration should start from 0 and continue until Valid returns false.
func NewTagList ¶
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.