Documentation ¶
Overview ¶
trace provides opinionated utilities for generating traces
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MicrosecondTimestampFn ¶
func MicrosecondTimestampFn() int64
MicrosecondTimestampFn is the default function used to generate timestamps by a Tracer
Types ¶
type Duration ¶
type Duration struct {
// contains filtered or unexported fields
}
Duration is a handle to a Duration generated by BeginDuration, allowing you to signal the end of a Duration
func (Duration) End ¶
func (d Duration) End(options ...EventOption)
End generates an event signalling the end of some work on a thread
type ErrorHandler ¶
type ErrorHandler = func(err error)
ErrorHandler allows client code to observe events that occur within the tracing library
type EventOption ¶
EventOption allows for customising the data in individual events before they are emitted
func WithArgs ¶
func WithArgs(args map[string]interface{}) EventOption
WithArgs allows for adding arbitrary argument values to an event, note that this is not supported by all events
func WithCategories ¶
func WithCategories(categories ...string) EventOption
WithCategories allows adding category strings to an event, this is supported by all events
func WithEndStackTrace ¶
func WithEndStackTrace() EventOption
WithEndStackTrace will attach a stack trace to the event in the "end" stack trace field, only supported by Complete events
func WithStackTrace ¶
func WithStackTrace() EventOption
WithStackTrace will attach a stack trace to the event, note that this is not supported by all events
type TimestampFn ¶
type TimestampFn = func() int64
TimestampFn allows client code to override the mechanism used to generate timestamps for trace events
type Tracer ¶
type Tracer struct {
// contains filtered or unexported fields
}
Tracer is an opinionated utility for generating events in Trace Event Format
func NewTracer ¶
func NewTracer(stream tio.EventWriter, options ...TracerOption) *Tracer
NewTracer creates a new Tracer that writes its events to the provided EventWriter
func TraceToFile ¶
func TraceToFile(path string, options ...TracerOption) (*Tracer, error)
TraceToFile creates a new Tracer that writes events in JSON Array Format to a file specified by the given path
func TracerToWriter ¶
func TracerToWriter(w io.WriteCloser, options ...TracerOption) *Tracer
TracerToWriter creates a new Tracer that writes its events in JSON Array Format to the provided io.WriteCloser
func (*Tracer) BeginDuration ¶
func (t *Tracer) BeginDuration(name string, options ...EventOption) Duration
BeginDuration generates an event signalling the start of some work on a thread
func (*Tracer) Instant ¶
func (t *Tracer) Instant(name string, options ...EventOption)
Instant generates an event with no duration signalling that something happened within the scope of the current thread
func (*Tracer) ScopedInstant ¶
func (t *Tracer) ScopedInstant(name string, scope events.InstantScope, options ...EventOption)
ScopedInstant generates an event with no duration signalling that something happened within the specified scope
type TracerOption ¶
type TracerOption = func(t *Tracer)
TracerOption configures the behaviour of a Tracer
func WithErrorHandler ¶
func WithErrorHandler(handler ErrorHandler) TracerOption
WithErrorHandler provides a callback for the tracing library to report errors to
func WithLogger ¶
func WithLogger(logger logr.Logger) TracerOption
WithLogger provides a logging implementation for the tracing library to report errors and other log events
func WithTimestampFn ¶
func WithTimestampFn(f TimestampFn) TracerOption
WithTimestampFn provides a custom function for generating timestamps for events