event

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2020 License: Apache-2.0, BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package event provides support for event based telemetry.

Index

Constants

View Source
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

View Source
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

func Detach(ctx context.Context) context.Context

Detach returns a context without an associated span. This allows the creation of spans that are not children of the current span.

func Error

func Error(ctx context.Context, message string, err error, tags ...Tag)

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 Label

func Label(ctx context.Context, tags ...Tag) context.Context

Label sends a label event to the exporter with the supplied tags.

func Label1

func Label1(ctx context.Context, t1 Tag) context.Context

Label1 sends a label event to the exporter with the supplied tags.

func Label2

func Label2(ctx context.Context, t1, t2 Tag) context.Context

Label2 sends a label event to the exporter with the supplied tags.

func Label3

func Label3(ctx context.Context, t1, t2, t3 Tag) context.Context

Label3 sends a label event to the exporter with the supplied tags.

func Log

func Log(ctx context.Context, tags ...Tag)

Log sends a log event with the supplied tag list to the exporter.

func Log1

func Log1(ctx context.Context, t1 Tag) context.Context

Log1 sends a label event to the exporter with the supplied tags.

func Log2

func Log2(ctx context.Context, t1, t2 Tag) context.Context

Log2 sends a label event to the exporter with the supplied tags.

func Log3

func Log3(ctx context.Context, t1, t2, t3 Tag) context.Context

Log3 sends a label event to the exporter with the supplied tags.

func Print

func Print(ctx context.Context, message string, tags ...Tag)

Print takes a message and a tag list and combines them into a single event before delivering them to the exporter.

func Print1

func Print1(ctx context.Context, message string, t1 Tag)

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

func Print2(ctx context.Context, message string, t1 Tag, t2 Tag)

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 Record

func Record(ctx context.Context, tags ...Tag) context.Context

Record sends a label event to the exporter with the supplied tags.

func Record1

func Record1(ctx context.Context, t1 Tag) context.Context

Record1 sends a label event to the exporter with the supplied tags.

func Record2

func Record2(ctx context.Context, t1, t2 Tag) context.Context

Record2 sends a label event to the exporter with the supplied tags.

func Record3

func Record3(ctx context.Context, t1, t2, t3 Tag) context.Context

Record3 sends a label event to the exporter with the supplied tags.

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

func StartSpan(ctx context.Context, name string, tags ...Tag) (context.Context, func())

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

func StartSpan1(ctx context.Context, name string, t1 Tag) (context.Context, func())

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.

func StartSpan2

func StartSpan2(ctx context.Context, name string, t1, t2 Tag) (context.Context, func())

StartSpan2 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

func NewErrorKey(name, description string) *ErrorKey

NewErrorKey creates a new Key for int64 values.

func (*ErrorKey) Description

func (k *ErrorKey) Description() string

func (*ErrorKey) From

func (k *ErrorKey) From(t Tag) error

From can be used to get a value from a Tag.

func (*ErrorKey) Get

func (k *ErrorKey) Get(tags TagMap) error

Get can be used to get a tag for the key from a TagMap.

func (*ErrorKey) Name

func (k *ErrorKey) Name() string

func (*ErrorKey) Of

func (k *ErrorKey) Of(v error) Tag

Of creates a new Tag with this key and the supplied value.

type Event

type Event struct {
	At time.Time
	// contains filtered or unexported fields
}

Event holds the information about an event of note that ocurred.

func (Event) Format

func (ev Event) Format(f fmt.State, r rune)

func (Event) IsDetach

func (ev Event) IsDetach() bool

func (Event) IsEndSpan

func (ev Event) IsEndSpan() bool

func (Event) IsLabel

func (ev Event) IsLabel() bool

func (Event) IsLog

func (ev Event) IsLog() bool

func (Event) IsRecord

func (ev Event) IsRecord() bool

func (Event) IsStartSpan

func (ev Event) IsStartSpan() bool

func (Event) Map

func (ev Event) Map() TagMap

func (Event) Tags

func (ev Event) Tags() TagIterator

type Exporter

type Exporter func(context.Context, Event, TagMap) context.Context

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

func NewInt16Key(name, description string) *Int16Key

NewInt16Key creates a new Key for int16 values.

func (*Int16Key) Description

func (k *Int16Key) Description() string

func (*Int16Key) From

func (k *Int16Key) From(t Tag) int16

From can be used to get a value from a Tag.

func (*Int16Key) Get

func (k *Int16Key) Get(tags TagMap) int16

Get can be used to get a tag for the key from a TagMap.

func (*Int16Key) Name

func (k *Int16Key) Name() string

func (*Int16Key) Of

func (k *Int16Key) Of(v int16) Tag

Of creates a new Tag with this key and the supplied value.

type Int32Key

type Int32Key struct {
	// contains filtered or unexported fields
}

Int32Key represents a key

func NewInt32Key

func NewInt32Key(name, description string) *Int32Key

NewInt32Key creates a new Key for int32 values.

func (*Int32Key) Description

func (k *Int32Key) Description() string

func (*Int32Key) From

func (k *Int32Key) From(t Tag) int32

From can be used to get a value from a Tag.

func (*Int32Key) Get

func (k *Int32Key) Get(tags TagMap) int32

Get can be used to get a tag for the key from a TagMap.

func (*Int32Key) Name

func (k *Int32Key) Name() string

func (*Int32Key) Of

func (k *Int32Key) Of(v int32) Tag

Of creates a new Tag with this key and the supplied value.

type Int64Key

type Int64Key struct {
	// contains filtered or unexported fields
}

Int64Key represents a key

func NewInt64Key

func NewInt64Key(name, description string) *Int64Key

NewInt64Key creates a new Key for int64 values.

func (*Int64Key) Description

func (k *Int64Key) Description() string

func (*Int64Key) From

func (k *Int64Key) From(t Tag) int64

From can be used to get a value from a Tag.

func (*Int64Key) Get

func (k *Int64Key) Get(tags TagMap) int64

Get can be used to get a tag for the key from a TagMap.

func (*Int64Key) Name

func (k *Int64Key) Name() string

func (*Int64Key) Of

func (k *Int64Key) Of(v int64) Tag

Of creates a new Tag with this key and the supplied value.

type Int8Key

type Int8Key struct {
	// contains filtered or unexported fields
}

Int8Key represents a key

func NewInt8Key

func NewInt8Key(name, description string) *Int8Key

NewInt8Key creates a new Key for int8 values.

func (*Int8Key) Description

func (k *Int8Key) Description() string

func (*Int8Key) From

func (k *Int8Key) From(t Tag) int8

From can be used to get a value from a Tag.

func (*Int8Key) Get

func (k *Int8Key) Get(tags TagMap) int8

Get can be used to get a tag for the key from a TagMap.

func (*Int8Key) Name

func (k *Int8Key) Name() string

func (*Int8Key) Of

func (k *Int8Key) Of(v int8) Tag

Of creates a new Tag with this key and the supplied value.

type IntKey

type IntKey struct {
	// contains filtered or unexported fields
}

IntKey represents a key

func NewIntKey

func NewIntKey(name, description string) *IntKey

NewIntKey creates a new Key for int values.

func (*IntKey) Description

func (k *IntKey) Description() string

func (*IntKey) From

func (k *IntKey) From(t Tag) int

From can be used to get a value from a Tag.

func (*IntKey) Get

func (k *IntKey) Get(tags TagMap) int

Get can be used to get a tag for the key from a TagMap.

func (*IntKey) Name

func (k *IntKey) Name() string

func (*IntKey) Of

func (k *IntKey) Of(v int) Tag

Of creates a new Tag with this key and the supplied value.

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

func NewStringKey(name, description string) *StringKey

NewStringKey creates a new Key for int64 values.

func (*StringKey) Description

func (k *StringKey) Description() string

func (*StringKey) From

func (k *StringKey) From(t Tag) string

From can be used to get a value from a Tag.

func (*StringKey) Get

func (k *StringKey) Get(tags TagMap) string

Get can be used to get a tag for the key from a TagMap.

func (*StringKey) Name

func (k *StringKey) Name() string

func (*StringKey) Of

func (k *StringKey) Of(v string) Tag

Of creates a new Tag with this key and the supplied value.

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.

func (Tag) Format

func (t Tag) Format(f fmt.State, r rune)

Format is used for debug printing of tags.

func (Tag) Valid

func (t Tag) Valid() bool

Valid returns true if the Tag is a valid one (it has a key).

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

func MergeTagMaps(srcs ...TagMap) TagMap

func NewTagMap

func NewTagMap(tags ...Tag) TagMap

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

func NewUInt16Key(name, description string) *UInt16Key

NewUInt16Key creates a new Key for uint16 values.

func (*UInt16Key) Description

func (k *UInt16Key) Description() string

func (*UInt16Key) From

func (k *UInt16Key) From(t Tag) uint16

From can be used to get a value from a Tag.

func (*UInt16Key) Get

func (k *UInt16Key) Get(tags TagMap) uint16

Get can be used to get a tag for the key from a TagMap.

func (*UInt16Key) Name

func (k *UInt16Key) Name() string

func (*UInt16Key) Of

func (k *UInt16Key) Of(v uint16) Tag

Of creates a new Tag with this key and the supplied value.

type UInt32Key

type UInt32Key struct {
	// contains filtered or unexported fields
}

UInt32Key represents a key

func NewUInt32Key

func NewUInt32Key(name, description string) *UInt32Key

NewUInt32Key creates a new Key for uint32 values.

func (*UInt32Key) Description

func (k *UInt32Key) Description() string

func (*UInt32Key) From

func (k *UInt32Key) From(t Tag) uint32

From can be used to get a value from a Tag.

func (*UInt32Key) Get

func (k *UInt32Key) Get(tags TagMap) uint32

Get can be used to get a tag for the key from a TagMap.

func (*UInt32Key) Name

func (k *UInt32Key) Name() string

func (*UInt32Key) Of

func (k *UInt32Key) Of(v uint32) Tag

Of creates a new Tag with this key and the supplied value.

type UInt64Key

type UInt64Key struct {
	// contains filtered or unexported fields
}

UInt64Key represents a key

func NewUInt64Key

func NewUInt64Key(name, description string) *UInt64Key

NewUInt64Key creates a new Key for uint64 values.

func (*UInt64Key) Description

func (k *UInt64Key) Description() string

func (*UInt64Key) From

func (k *UInt64Key) From(t Tag) uint64

From can be used to get a value from a Tag.

func (*UInt64Key) Get

func (k *UInt64Key) Get(tags TagMap) uint64

Get can be used to get a tag for the key from a TagMap.

func (*UInt64Key) Name

func (k *UInt64Key) Name() string

func (*UInt64Key) Of

func (k *UInt64Key) Of(v uint64) Tag

Of creates a new Tag with this key and the supplied value.

type UInt8Key

type UInt8Key struct {
	// contains filtered or unexported fields
}

UInt8Key represents a key

func NewUInt8Key

func NewUInt8Key(name, description string) *UInt8Key

NewUInt8Key creates a new Key for uint8 values.

func (*UInt8Key) Description

func (k *UInt8Key) Description() string

func (*UInt8Key) From

func (k *UInt8Key) From(t Tag) uint8

From can be used to get a value from a Tag.

func (*UInt8Key) Get

func (k *UInt8Key) Get(tags TagMap) uint8

Get can be used to get a tag for the key from a TagMap.

func (*UInt8Key) Name

func (k *UInt8Key) Name() string

func (*UInt8Key) Of

func (k *UInt8Key) Of(v uint8) Tag

Of creates a new Tag with this key and the supplied value.

type UIntKey

type UIntKey struct {
	// contains filtered or unexported fields
}

UIntKey represents a key

func NewUIntKey

func NewUIntKey(name, description string) *UIntKey

NewUIntKey creates a new Key for uint values.

func (*UIntKey) Description

func (k *UIntKey) Description() string

func (*UIntKey) From

func (k *UIntKey) From(t Tag) uint

From can be used to get a value from a Tag.

func (*UIntKey) Get

func (k *UIntKey) Get(tags TagMap) uint

Get can be used to get a tag for the key from a TagMap.

func (*UIntKey) Name

func (k *UIntKey) Name() string

func (*UIntKey) Of

func (k *UIntKey) Of(v uint) Tag

Of creates a new Tag with this key and the supplied value.

type ValueKey

type ValueKey struct {
	// contains filtered or unexported fields
}

ValueKey represents a key for untyped values.

func NewKey

func NewKey(name, description string) *ValueKey

NewKey creates a new Key for untyped values.

func (*ValueKey) Description

func (k *ValueKey) Description() string

func (*ValueKey) From

func (k *ValueKey) From(t Tag) interface{}

From can be used to get a value from a Tag.

func (*ValueKey) Get

func (k *ValueKey) Get(tags TagMap) interface{}

Get can be used to get a tag for the key from a TagMap.

func (*ValueKey) Name

func (k *ValueKey) Name() string

func (*ValueKey) Of

func (k *ValueKey) Of(value interface{}) Tag

Of creates a new Tag with this key and the supplied value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL