Documentation ¶
Overview ¶
Package timing is used to aggregate timing calls within hotpaths to avoid using repeated statsd calls. The package has a default set that reports at 10 second intervals and can be used directly. If a different behaviour or reporting pattern is desired, a custom Set may be created.
Example ¶
The most basic usage for the package is timing the execution time of a function.
computeThings := func() { // the easiest way is using a defer statement, which will trigger // when a function returns defer Since("compute.things", time.Now()) // do stuff... } computeThings() Stop()
Output:
Index ¶
Examples ¶
Constants ¶
const AutoreportInterval = 10 * time.Second
AutoreportInterval specifies the interval at which the default set reports.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set represents a set of metrics that can be used for timing. Use NewSet to initialize a new Set. Use Report (or Autoreport) to submit metrics. Set is safe for concurrent use.
func (*Set) Autoreport ¶
Autoreport enables autoreporting of the Set at the given interval. It returns a cancellation function.