Documentation ¶
Overview ¶
Package metrics provides various measurements that are safe for concurrent access.
Measurements are arranged into groups that are efficient to create and access.
Index ¶
Constants ¶
const ( // DefaultGroup is the identifier for the default group. DefaultGroup = GID(0) )
Variables ¶
This section is empty.
Functions ¶
func NewContextWithGroup ¶
NewContextWithGroup returns a new context with the given Group added.
Types ¶
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
The Counter type represents a numeric counter that is safe to use from concurrent goroutines.
type GID ¶
type GID uint32
func MustRegisterGroup ¶
MustRegisterGroup registers a new group using the specified name. If the group name is not unique, MustRegisterGroup will panic.
MustRegisterGroup is not safe to call from multiple goroutines.
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
The Group type represents an instance of a set of measurements that are used for instrumenting a specific request.
func GroupFromContext ¶
GroupFromContext returns the Group associated with ctx or nil if no Group has been assigned.
func NewGroup ¶
NewGroup returns a new measurement group from the default registry.
NewGroup is safe to call from multiple goroutines.
func (*Group) GetCounter ¶
GetCounter returns the counter identified by the id that was returned by MustRegisterCounter for the same group. Using an id from a different group will result in undefined behavior.
type ID ¶
type ID uint64
func MustRegisterCounter ¶
MustRegisterCounter registers a new counter metric with the default registry using the provided descriptor. If the metric name is not unique, MustRegisterCounter will panic.
MustRegisterCounter is not safe to call from multiple goroutines.
func MustRegisterTimer ¶
MustRegisterTimer registers a new timer metric with the default registry using the provided descriptor. If the metric name is not unique, MustRegisterTimer will panic.
MustRegisterTimer is not safe to call from multiple goroutines.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry() *Registry
NewRegistry creates a new Registry with a single group identified by DefaultGroup.
func (*Registry) MustRegisterCounter ¶
MustRegisterCounter registers a new counter metric using the provided descriptor. If the metric name is not unique within the group, MustRegisterCounter will panic.
MustRegisterCounter is not safe to call from concurrent goroutines.
func (*Registry) MustRegisterGroup ¶
MustRegisterGroup registers a new group and panics if a group already exists with the same name.
MustRegisterGroup is not safe to call from concurrent goroutines.
func (*Registry) MustRegisterTimer ¶
MustRegisterTimer registers a new timer metric using the provided descriptor. If the metric name is not unique within the group, MustRegisterTimer will panic.
MustRegisterTimer is not safe to call from concurrent goroutines.
type Timer ¶
type Timer struct {
// contains filtered or unexported fields
}
The timer type is used to store a duration.
func (*Timer) String ¶
String returns a string representation using the name and value of the timer.
func (*Timer) Time ¶
func (t *Timer) Time(f func())
Time updates the timer to the duration it takes to call f.
func (*Timer) UpdateSince ¶
UpdateSince sets the timer value to the difference between since and the current time.