Documentation ¶
Index ¶
- func CounterToPrometheus(name string, value int, now time.Time, labels prometheus.Labels) []byte
- func NewLabels(component, name string) prometheus.Labels
- func SetHostname(h string)
- func SnapshotToPrometheus(snap Snapshot, now time.Time, labels prometheus.Labels) []byte
- type AnonStats
- type CounterPair
- type Snapshot
- type Stats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CounterToPrometheus ¶
CounterToPrometheus generates a single Prometheus line for a counter.
func NewLabels ¶
func NewLabels(component, name string) prometheus.Labels
NewLabels creates a new prometheus.Labels with the component and name set as given.
func SetHostname ¶
func SetHostname(h string)
SetHostname allows the hostname reported for metrics to be overridden. This is mainly intended for tests.
func SnapshotToPrometheus ¶
SnapshotToPrometheus takes Snapshot produced by a Stats instance and formats it into Prometheus metrics lines using the timestamp and labels provided.
Types ¶
type AnonStats ¶
type AnonStats struct {
// contains filtered or unexported fields
}
AnonStats tracks a number of counters in a goroutine safe way. Counters are addressed by integer index.
func (*AnonStats) Get ¶
Get retrieves the current value of a counter. It panics if the counter is not valid.
func (*AnonStats) Inc ¶
Inc increments a stats counter, returning the new value. It panics if the counter is not valid.
type CounterPair ¶
CounterPair holds the and value for one Stats counter at a given point in time.
type Stats ¶
type Stats struct {
// contains filtered or unexported fields
}
Stats tracks a number of named counters in a goroutine safe way. It wraps an AnonStats.
func (*Stats) Get ¶
Get retrieves the current value of a counter. It panics if the counter is not valid.
func (*Stats) Inc ¶
Inc increments a stats counter, returning the new value. It panics if the counter is not valid.