Documentation ¶
Overview ¶
Package watch provides performance monitoring routines
Package watch provides performance monitoring routines
Index ¶
- func Finish(ctx context.Context) (err error)
- func GetTrace(ctx context.Context) uuid.UUID
- func LogMetrics(kvp [][]string)
- func TraceContext(ctx context.Context) context.Context
- func WatcherContext(ctx context.Context, name string, options ...Optioner) (context.Context, error)
- type Aggregator
- type ConfigOption
- type DecimalPlaces
- type DurationUnits
- type LogMetricsFunc
- type Monitor
- type Option
- type Optioner
- type TraceID
- type TraceIDKey
- type Watch
- type Watcher
- type WatcherIDKey
- type WatcherType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LogMetrics ¶
func LogMetrics(kvp [][]string)
LogMetrics logs performance stats key/value pairs.
func TraceContext ¶
TraceContext creates new context with trace id.
Types ¶
type Aggregator ¶
Aggregator stores multiple monitors for the same operation.
func NewAggregator ¶
func NewAggregator(area string) *Aggregator
NewAggregator creates new area aggregator.
func (*Aggregator) Add ¶
func (a *Aggregator) Add(mon *Monitor)
Add appends a monitor to the aggregator.
func (*Aggregator) Aggregate ¶
func (a *Aggregator) Aggregate() (err error)
Aggregate aggregates elapsed durations of each monitor.
type ConfigOption ¶
type ConfigOption struct { ID Option Val interface{} }
ConfigOption of th capture.
func (ConfigOption) Option ¶
func (o ConfigOption) Option() Option
Option return config option identifier.
func (ConfigOption) Value ¶
func (o ConfigOption) Value() interface{}
Value return config option value.
type DecimalPlaces ¶ added in v0.1.4
type DecimalPlaces int
DecimalPlaces for percentage and unit values.
const ( // DecimalPlacesAll disabled. DecimalPlacesAll DecimalPlaces = iota // DecimalPlacesOnes 1 - ones place. DecimalPlacesOnes // DecimalPlacesTenths 2 - tenths place. DecimalPlacesTenths // DecimalPlacesHundredths 3 - hundredths place. DecimalPlacesHundredths // DecimalPlacesThousandths 4 - thousandths place. DecimalPlacesThousandths // DecimalPlacesTenThousandths 5 - ten thousandths place. DecimalPlacesTenThousandths // DecimalPlacesHundredThousandths 6 - hundred thousandths place. DecimalPlacesHundredThousandths // DecimalPlacesMillions 7 - millions place. DecimalPlacesMillions )
type DurationUnits ¶
type DurationUnits int
DurationUnits of duration.
const ( // Nanoseconds ... Nanoseconds DurationUnits = iota // Microseconds ... Microseconds // Milliseconds ... Milliseconds // Seconds ... Seconds // Minutes ... Minutes // Hours ... Hours )
type LogMetricsFunc ¶
type LogMetricsFunc func(kvp [][]string)
LogMetricsFunc defines a function to log the watch metrics.
type Monitor ¶
Monitor measures elapsed time in the area.
func NewMonitor ¶
NewMonitor creates new operation monitor.
func (*Monitor) Microseconds ¶
Microseconds returns elapsed time in 0.000001 of a second (μs/us).
func (*Monitor) Milliseconds ¶
Milliseconds returns elapsed time in 0.001 of a second (ms).
func (*Monitor) Nanoseconds ¶
Nanoseconds returns elapsed time in nanoseconds (ns).
type TraceIDKey ¶
type TraceIDKey int
TraceIDKey is the type of value to use for the key. The key is type specific and only values of the same type will match.
type Watch ¶
type Watch struct { Name string Unknown time.Duration LogMetrics LogMetricsFunc // contains filtered or unexported fields }
Watch performance profiler instance.
func NewWatcher ¶
NewWatcher creates a new watcher.
func (*Watch) Units ¶
func (w *Watch) Units() DurationUnits
Units return DurationUnits for the watch.
type Watcher ¶
type Watcher interface { Start(ctx context.Context, name string) *Monitor Finish(ctx context.Context) error Running() bool Units() DurationUnits }
Watcher interface.
type WatcherIDKey ¶
type WatcherIDKey int
WatcherIDKey is the type of value to use fЕor the key. The key is type specific and only values of the same type will match.