Documentation ¶
Overview ¶
Go port of Coda Hale's Metrics library
<https://github.com/rcrowley/go-metrics>
Coda Hale's original work: <https://github.com/codahale/metrics>
Example ¶
c := NewCounter() Register("money", c) c.Inc(17) // Threadsafe registration t := GetOrRegisterTimer("db.get.latency", nil) t.Time(func() { time.Sleep(10 * time.Millisecond) }) t.Update(1) fmt.Println(c.Count()) fmt.Println(t.Min())
Output: 17 1
Index ¶
- Constants
- Variables
- func CaptureDebugGCStats(r Registry, d time.Duration)
- func CaptureDebugGCStatsOnce(r Registry)
- func CaptureRuntimeMemStats(r Registry, d time.Duration)
- func CaptureRuntimeMemStatsOnce(r Registry)
- func CollectProcessMetrics(refresh time.Duration)
- func Each(f func(string, interface{}))
- func Get(name string) interface{}
- func GetOrRegister(name string, i interface{}) interface{}
- func Graphite(r Registry, d time.Duration, prefix string, addr *net.TCPAddr)
- func GraphiteOnce(c GraphiteConfig) error
- func GraphiteWithConfig(c GraphiteConfig)
- func Log(r Registry, freq time.Duration, l Logger)
- func LogScaled(r Registry, freq time.Duration, scale time.Duration, l Logger)
- func MustRegister(name string, i interface{})
- func OpenTSDB(r Registry, d time.Duration, prefix string, addr *net.TCPAddr)
- func OpenTSDBWithConfig(c OpenTSDBConfig)
- func ReadDiskStats(stats *DiskStats) error
- func Register(name string, i interface{}) error
- func RegisterDebugGCStats(r Registry)
- func RegisterRuntimeMemStats(r Registry)
- func RunHealthchecks()
- func SampleMax(values []int64) int64
- func SampleMean(values []int64) float64
- func SampleMin(values []int64) int64
- func SamplePercentile(values int64Slice, p float64) float64
- func SamplePercentiles(values int64Slice, ps []float64) []float64
- func SampleStdDev(values []int64) float64
- func SampleSum(values []int64) int64
- func SampleVariance(values []int64) float64
- func Syslog(r Registry, d time.Duration, w *syslog.Writer)
- func Unregister(name string)
- func Write(r Registry, d time.Duration, w io.Writer)
- func WriteJSON(r Registry, d time.Duration, w io.Writer)
- func WriteJSONOnce(r Registry, w io.Writer)
- func WriteOnce(r Registry, w io.Writer)
- type Counter
- type CounterSnapshot
- type DiskStats
- type DuplicateMetric
- type EWMA
- type EWMASnapshot
- type ExpDecaySample
- func (s *ExpDecaySample) Clear()
- func (s *ExpDecaySample) Count() int64
- func (s *ExpDecaySample) Max() int64
- func (s *ExpDecaySample) Mean() float64
- func (s *ExpDecaySample) Min() int64
- func (s *ExpDecaySample) Percentile(p float64) float64
- func (s *ExpDecaySample) Percentiles(ps []float64) []float64
- func (s *ExpDecaySample) Size() int
- func (s *ExpDecaySample) Snapshot() Sample
- func (s *ExpDecaySample) StdDev() float64
- func (s *ExpDecaySample) Sum() int64
- func (s *ExpDecaySample) Update(v int64)
- func (s *ExpDecaySample) Values() []int64
- func (s *ExpDecaySample) Variance() float64
- type FunctionalGauge
- type FunctionalGaugeFloat64
- type Gauge
- type GaugeFloat64
- func GetOrRegisterGaugeFloat64(name string, r Registry) GaugeFloat64
- func NewFunctionalGaugeFloat64(f func() float64) GaugeFloat64
- func NewGaugeFloat64() GaugeFloat64
- func NewRegisteredFunctionalGaugeFloat64(name string, r Registry, f func() float64) GaugeFloat64
- func NewRegisteredGaugeFloat64(name string, r Registry) GaugeFloat64
- type GaugeFloat64Snapshot
- type GaugeSnapshot
- type GraphiteConfig
- type Healthcheck
- type Histogram
- type HistogramSnapshot
- func (*HistogramSnapshot) Clear()
- func (h *HistogramSnapshot) Count() int64
- func (h *HistogramSnapshot) Max() int64
- func (h *HistogramSnapshot) Mean() float64
- func (h *HistogramSnapshot) Min() int64
- func (h *HistogramSnapshot) Percentile(p float64) float64
- func (h *HistogramSnapshot) Percentiles(ps []float64) []float64
- func (h *HistogramSnapshot) Sample() Sample
- func (h *HistogramSnapshot) Snapshot() Histogram
- func (h *HistogramSnapshot) StdDev() float64
- func (h *HistogramSnapshot) Sum() int64
- func (*HistogramSnapshot) Update(int64)
- func (h *HistogramSnapshot) Variance() float64
- type Int64Slice
- type Logger
- type Meter
- type MeterSnapshot
- func (m *MeterSnapshot) Count() int64
- func (*MeterSnapshot) Mark(n int64)
- func (m *MeterSnapshot) Rate1() float64
- func (m *MeterSnapshot) Rate15() float64
- func (m *MeterSnapshot) Rate5() float64
- func (m *MeterSnapshot) RateMean() float64
- func (m *MeterSnapshot) Snapshot() Meter
- func (m *MeterSnapshot) Stop()
- type NilCounter
- type NilEWMA
- type NilGauge
- type NilGaugeFloat64
- type NilHealthcheck
- type NilHistogram
- func (NilHistogram) Clear()
- func (NilHistogram) Count() int64
- func (NilHistogram) Max() int64
- func (NilHistogram) Mean() float64
- func (NilHistogram) Min() int64
- func (NilHistogram) Percentile(p float64) float64
- func (NilHistogram) Percentiles(ps []float64) []float64
- func (NilHistogram) Sample() Sample
- func (NilHistogram) Snapshot() Histogram
- func (NilHistogram) StdDev() float64
- func (NilHistogram) Sum() int64
- func (NilHistogram) Update(v int64)
- func (NilHistogram) Variance() float64
- type NilMeter
- type NilResettingTimer
- func (NilResettingTimer) Mean() float64
- func (NilResettingTimer) Percentiles([]float64) []int64
- func (NilResettingTimer) Snapshot() ResettingTimer
- func (NilResettingTimer) Time(func())
- func (NilResettingTimer) Update(time.Duration)
- func (NilResettingTimer) UpdateSince(time.Time)
- func (NilResettingTimer) Values() []int64
- type NilSample
- func (NilSample) Clear()
- func (NilSample) Count() int64
- func (NilSample) Max() int64
- func (NilSample) Mean() float64
- func (NilSample) Min() int64
- func (NilSample) Percentile(p float64) float64
- func (NilSample) Percentiles(ps []float64) []float64
- func (NilSample) Size() int
- func (NilSample) Snapshot() Sample
- func (NilSample) StdDev() float64
- func (NilSample) Sum() int64
- func (NilSample) Update(v int64)
- func (NilSample) Values() []int64
- func (NilSample) Variance() float64
- type NilTimer
- func (NilTimer) Count() int64
- func (NilTimer) Max() int64
- func (NilTimer) Mean() float64
- func (NilTimer) Min() int64
- func (NilTimer) Percentile(p float64) float64
- func (NilTimer) Percentiles(ps []float64) []float64
- func (NilTimer) Rate1() float64
- func (NilTimer) Rate15() float64
- func (NilTimer) Rate5() float64
- func (NilTimer) RateMean() float64
- func (NilTimer) Snapshot() Timer
- func (NilTimer) StdDev() float64
- func (NilTimer) Stop()
- func (NilTimer) Sum() int64
- func (NilTimer) Time(func())
- func (NilTimer) Update(time.Duration)
- func (NilTimer) UpdateSince(time.Time)
- func (NilTimer) Variance() float64
- type OpenTSDBConfig
- type PrefixedRegistry
- func (r *PrefixedRegistry) Each(fn func(string, interface{}))
- func (r *PrefixedRegistry) Get(name string) interface{}
- func (r *PrefixedRegistry) GetAll() map[string]map[string]interface{}
- func (r *PrefixedRegistry) GetOrRegister(name string, metric interface{}) interface{}
- func (p *PrefixedRegistry) MarshalJSON() ([]byte, error)
- func (r *PrefixedRegistry) Register(name string, metric interface{}) error
- func (r *PrefixedRegistry) RunHealthchecks()
- func (r *PrefixedRegistry) Unregister(name string)
- func (r *PrefixedRegistry) UnregisterAll()
- type Registry
- type ResettingTimer
- type ResettingTimerSnapshot
- func (t *ResettingTimerSnapshot) Mean() float64
- func (t *ResettingTimerSnapshot) Percentiles(percentiles []float64) []int64
- func (t *ResettingTimerSnapshot) Snapshot() ResettingTimer
- func (*ResettingTimerSnapshot) Time(func())
- func (*ResettingTimerSnapshot) Update(time.Duration)
- func (*ResettingTimerSnapshot) UpdateSince(time.Time)
- func (t *ResettingTimerSnapshot) Values() []int64
- type Sample
- type SampleSnapshot
- func (*SampleSnapshot) Clear()
- func (s *SampleSnapshot) Count() int64
- func (s *SampleSnapshot) Max() int64
- func (s *SampleSnapshot) Mean() float64
- func (s *SampleSnapshot) Min() int64
- func (s *SampleSnapshot) Percentile(p float64) float64
- func (s *SampleSnapshot) Percentiles(ps []float64) []float64
- func (s *SampleSnapshot) Size() int
- func (s *SampleSnapshot) Snapshot() Sample
- func (s *SampleSnapshot) StdDev() float64
- func (s *SampleSnapshot) Sum() int64
- func (*SampleSnapshot) Update(int64)
- func (s *SampleSnapshot) Values() []int64
- func (s *SampleSnapshot) Variance() float64
- type StandardCounter
- type StandardEWMA
- type StandardGauge
- type StandardGaugeFloat64
- type StandardHealthcheck
- type StandardHistogram
- func (h *StandardHistogram) Clear()
- func (h *StandardHistogram) Count() int64
- func (h *StandardHistogram) Max() int64
- func (h *StandardHistogram) Mean() float64
- func (h *StandardHistogram) Min() int64
- func (h *StandardHistogram) Percentile(p float64) float64
- func (h *StandardHistogram) Percentiles(ps []float64) []float64
- func (h *StandardHistogram) Sample() Sample
- func (h *StandardHistogram) Snapshot() Histogram
- func (h *StandardHistogram) StdDev() float64
- func (h *StandardHistogram) Sum() int64
- func (h *StandardHistogram) Update(v int64)
- func (h *StandardHistogram) Variance() float64
- type StandardMeter
- func (m *StandardMeter) Count() int64
- func (m *StandardMeter) Mark(n int64)
- func (m *StandardMeter) Rate1() float64
- func (m *StandardMeter) Rate15() float64
- func (m *StandardMeter) Rate5() float64
- func (m *StandardMeter) RateMean() float64
- func (m *StandardMeter) Snapshot() Meter
- func (m *StandardMeter) Stop()
- type StandardRegistry
- func (r *StandardRegistry) Each(f func(string, interface{}))
- func (r *StandardRegistry) Get(name string) interface{}
- func (r *StandardRegistry) GetAll() map[string]map[string]interface{}
- func (r *StandardRegistry) GetOrRegister(name string, i interface{}) interface{}
- func (r *StandardRegistry) MarshalJSON() ([]byte, error)
- func (r *StandardRegistry) Register(name string, i interface{}) error
- func (r *StandardRegistry) RunHealthchecks()
- func (r *StandardRegistry) Unregister(name string)
- func (r *StandardRegistry) UnregisterAll()
- type StandardResettingTimer
- func (t *StandardResettingTimer) Mean() float64
- func (t *StandardResettingTimer) Percentiles([]float64) []int64
- func (t *StandardResettingTimer) Snapshot() ResettingTimer
- func (t *StandardResettingTimer) Time(f func())
- func (t *StandardResettingTimer) Update(d time.Duration)
- func (t *StandardResettingTimer) UpdateSince(ts time.Time)
- func (t *StandardResettingTimer) Values() []int64
- type StandardTimer
- func (t *StandardTimer) Count() int64
- func (t *StandardTimer) Max() int64
- func (t *StandardTimer) Mean() float64
- func (t *StandardTimer) Min() int64
- func (t *StandardTimer) Percentile(p float64) float64
- func (t *StandardTimer) Percentiles(ps []float64) []float64
- func (t *StandardTimer) Rate1() float64
- func (t *StandardTimer) Rate15() float64
- func (t *StandardTimer) Rate5() float64
- func (t *StandardTimer) RateMean() float64
- func (t *StandardTimer) Snapshot() Timer
- func (t *StandardTimer) StdDev() float64
- func (t *StandardTimer) Stop()
- func (t *StandardTimer) Sum() int64
- func (t *StandardTimer) Time(f func())
- func (t *StandardTimer) Update(d time.Duration)
- func (t *StandardTimer) UpdateSince(ts time.Time)
- func (t *StandardTimer) Variance() float64
- type Stoppable
- type Timer
- type TimerSnapshot
- func (t *TimerSnapshot) Count() int64
- func (t *TimerSnapshot) Max() int64
- func (t *TimerSnapshot) Mean() float64
- func (t *TimerSnapshot) Min() int64
- func (t *TimerSnapshot) Percentile(p float64) float64
- func (t *TimerSnapshot) Percentiles(ps []float64) []float64
- func (t *TimerSnapshot) Rate1() float64
- func (t *TimerSnapshot) Rate15() float64
- func (t *TimerSnapshot) Rate5() float64
- func (t *TimerSnapshot) RateMean() float64
- func (t *TimerSnapshot) Snapshot() Timer
- func (t *TimerSnapshot) StdDev() float64
- func (t *TimerSnapshot) Stop()
- func (t *TimerSnapshot) Sum() int64
- func (*TimerSnapshot) Time(func())
- func (*TimerSnapshot) Update(time.Duration)
- func (*TimerSnapshot) UpdateSince(time.Time)
- func (t *TimerSnapshot) Variance() float64
- type UniformSample
- func (s *UniformSample) Clear()
- func (s *UniformSample) Count() int64
- func (s *UniformSample) Max() int64
- func (s *UniformSample) Mean() float64
- func (s *UniformSample) Min() int64
- func (s *UniformSample) Percentile(p float64) float64
- func (s *UniformSample) Percentiles(ps []float64) []float64
- func (s *UniformSample) Size() int
- func (s *UniformSample) Snapshot() Sample
- func (s *UniformSample) StdDev() float64
- func (s *UniformSample) Sum() int64
- func (s *UniformSample) Update(v int64)
- func (s *UniformSample) Values() []int64
- func (s *UniformSample) Variance() float64
Examples ¶
Constants ¶
const InitialResettingTimerSliceCap = 10
Initial slice capacity for the values stored in a ResettingTimer
const MetricsEnabledFlag = "metrics"
MetricsEnabledFlag is the CLI flag name to use to enable metrics collections.
Variables ¶
var Enabled bool = false
Enabled is checked by the constructor functions for all of the standard metrics. If it is true, the metric returned is a stub.
This global kill-switch helps quantify the observer effect and makes for less cluttered pprof profiles.
Functions ¶
func CaptureDebugGCStats ¶
func CaptureDebugGCStatsOnce ¶
func CaptureDebugGCStatsOnce(r Registry)
func CaptureRuntimeMemStats ¶
Capture new values for the Go runtime statistics exported in runtime.MemStats. This is designed to be called as a goroutine.
func CaptureRuntimeMemStatsOnce ¶
func CaptureRuntimeMemStatsOnce(r Registry)
Capture new values for the Go runtime statistics exported in runtime.MemStats. This is designed to be called in a background goroutine. Giving a registry which has not been given to RegisterRuntimeMemStats will panic.
Be very careful with this because runtime.ReadMemStats calls the C functions runtime·semacquire(&runtime·worldsema) and runtime·stoptheworld() and that last one does what it says on the tin.
func CollectProcessMetrics ¶
CollectProcessMetrics periodically collects various metrics about the running process.
func Each ¶
func Each(f func(string, interface{}))
Call the given function for each registered metric.
func Get ¶
func Get(name string) interface{}
Get the metric by the given name or nil if none is registered.
func GetOrRegister ¶
func GetOrRegister(name string, i interface{}) interface{}
Gets an existing metric or creates and registers a new one. Threadsafe alternative to calling Get and Register on failure.
func Graphite ¶
Example ¶
addr, _ := net.ResolveTCPAddr("net", ":2003") go Graphite(DefaultRegistry, 1*time.Second, "some.prefix", addr)
Output:
func GraphiteOnce ¶
func GraphiteOnce(c GraphiteConfig) error
func GraphiteWithConfig ¶
func GraphiteWithConfig(c GraphiteConfig)
Example ¶
addr, _ := net.ResolveTCPAddr("net", ":2003") go GraphiteWithConfig(GraphiteConfig{ Addr: addr, Registry: DefaultRegistry, FlushInterval: 1 * time.Second, DurationUnit: time.Millisecond, Percentiles: []float64{0.5, 0.75, 0.99, 0.999}, })
Output:
func LogScaled ¶
Output each metric in the given registry periodically using the given logger. Print timings in `scale` units (eg time.Millisecond) rather than nanos.
func MustRegister ¶
func MustRegister(name string, i interface{})
Register the given metric under the given name. Panics if a metric by the given name is already registered.
func OpenTSDB ¶
OpenTSDB is a blocking exporter function which reports metrics in r to a TSDB server located at addr, flushing them every d duration and prepending metric names with prefix.
Example ¶
addr, _ := net.ResolveTCPAddr("net", ":2003") go OpenTSDB(DefaultRegistry, 1*time.Second, "some.prefix", addr)
Output:
func OpenTSDBWithConfig ¶
func OpenTSDBWithConfig(c OpenTSDBConfig)
OpenTSDBWithConfig is a blocking exporter function just like OpenTSDB, but it takes a OpenTSDBConfig instead.
Example ¶
addr, _ := net.ResolveTCPAddr("net", ":2003") go OpenTSDBWithConfig(OpenTSDBConfig{ Addr: addr, Registry: DefaultRegistry, FlushInterval: 1 * time.Second, DurationUnit: time.Millisecond, })
Output:
func ReadDiskStats ¶
func Register ¶
Register the given metric under the given name. Returns a DuplicateMetric if a metric by the given name is already registered.
func RegisterDebugGCStats ¶
func RegisterDebugGCStats(r Registry)
func RegisterRuntimeMemStats ¶
func RegisterRuntimeMemStats(r Registry)
Register runtimeMetrics for the Go runtime statistics exported in runtime and specifically runtime.MemStats. The runtimeMetrics are named by their fully-qualified Go symbols, i.e. runtime.MemStats.Alloc.
func SampleMean ¶
SampleMean returns the mean value of the slice of int64.
func SamplePercentile ¶
SamplePercentiles returns an arbitrary percentile of the slice of int64.
func SamplePercentiles ¶
SamplePercentiles returns a slice of arbitrary percentiles of the slice of int64.
func SampleStdDev ¶
SampleStdDev returns the standard deviation of the slice of int64.
func SampleVariance ¶
SampleVariance returns the variance of the slice of int64.
func Syslog ¶
Output each metric in the given registry to syslog periodically using the given syslogger.
func Write ¶
Write sorts writes each metric in the given registry periodically to the given io.Writer.
func WriteJSON ¶
WriteJSON writes metrics from the given registry periodically to the specified io.Writer as JSON.
func WriteJSONOnce ¶
WriteJSONOnce writes metrics from the given registry to the specified io.Writer as JSON.
Types ¶
type Counter ¶
func GetOrRegisterCounter ¶
func NewCounter ¶
func NewCounter() Counter
func NewRegisteredCounter ¶
type CounterSnapshot ¶
type CounterSnapshot int64
func (CounterSnapshot) Clear ¶
func (CounterSnapshot) Clear()
func (CounterSnapshot) Count ¶
func (c CounterSnapshot) Count() int64
func (CounterSnapshot) Dec ¶
func (CounterSnapshot) Dec(int64)
func (CounterSnapshot) Inc ¶
func (CounterSnapshot) Inc(int64)
func (CounterSnapshot) Snapshot ¶
func (c CounterSnapshot) Snapshot() Counter
type DuplicateMetric ¶
type DuplicateMetric string
DuplicateMetric is the error returned by Registry.Register when a metric already exists. If you mean to Register that metric you must first Unregister the existing metric.
func (DuplicateMetric) Error ¶
func (err DuplicateMetric) Error() string
type EWMASnapshot ¶
type EWMASnapshot float64
func (EWMASnapshot) Rate ¶
func (a EWMASnapshot) Rate() float64
func (EWMASnapshot) Snapshot ¶
func (a EWMASnapshot) Snapshot() EWMA
func (EWMASnapshot) Tick ¶
func (EWMASnapshot) Tick()
func (EWMASnapshot) Update ¶
func (EWMASnapshot) Update(int64)
type ExpDecaySample ¶
type ExpDecaySample struct {
// contains filtered or unexported fields
}
ExpDecaySample is an exponentially-decaying sample using a forward-decaying priority reservoir. See Cormode et al's "Forward Decay: A Practical Time Decay Model for Streaming Systems".
<http://dimacs.rutgers.edu/~graham/pubs/papers/fwddecay.pdf>
func (*ExpDecaySample) Count ¶
func (s *ExpDecaySample) Count() int64
Count returns the number of samples recorded, which may exceed the reservoir size.
func (*ExpDecaySample) Max ¶
func (s *ExpDecaySample) Max() int64
Max returns the maximum value in the sample, which may not be the maximum value ever to be part of the sample.
func (*ExpDecaySample) Mean ¶
func (s *ExpDecaySample) Mean() float64
Mean returns the mean of the values in the sample.
func (*ExpDecaySample) Min ¶
func (s *ExpDecaySample) Min() int64
Min returns the minimum value in the sample, which may not be the minimum value ever to be part of the sample.
func (*ExpDecaySample) Percentile ¶
func (s *ExpDecaySample) Percentile(p float64) float64
Percentile returns an arbitrary percentile of values in the sample.
func (*ExpDecaySample) Percentiles ¶
func (s *ExpDecaySample) Percentiles(ps []float64) []float64
Percentiles returns a slice of arbitrary percentiles of values in the sample.
func (*ExpDecaySample) Size ¶
func (s *ExpDecaySample) Size() int
Size returns the size of the sample, which is at most the reservoir size.
func (*ExpDecaySample) Snapshot ¶
func (s *ExpDecaySample) Snapshot() Sample
Snapshot returns a read-only copy of the sample.
func (*ExpDecaySample) StdDev ¶
func (s *ExpDecaySample) StdDev() float64
StdDev returns the standard deviation of the values in the sample.
func (*ExpDecaySample) Sum ¶
func (s *ExpDecaySample) Sum() int64
Sum returns the sum of the values in the sample.
func (*ExpDecaySample) Update ¶
func (s *ExpDecaySample) Update(v int64)
Update samples a new value.
func (*ExpDecaySample) Values ¶
func (s *ExpDecaySample) Values() []int64
Values returns a copy of the values in the sample.
func (*ExpDecaySample) Variance ¶
func (s *ExpDecaySample) Variance() float64
Variance returns the variance of the values in the sample.
type FunctionalGauge ¶
type FunctionalGauge struct {
// contains filtered or unexported fields
}
func (FunctionalGauge) Snapshot ¶
func (g FunctionalGauge) Snapshot() Gauge
func (FunctionalGauge) Update ¶
func (FunctionalGauge) Update(int64)
func (FunctionalGauge) Value ¶
func (g FunctionalGauge) Value() int64
type FunctionalGaugeFloat64 ¶
type FunctionalGaugeFloat64 struct {
// contains filtered or unexported fields
}
func (FunctionalGaugeFloat64) Snapshot ¶
func (g FunctionalGaugeFloat64) Snapshot() GaugeFloat64
func (FunctionalGaugeFloat64) Update ¶
func (FunctionalGaugeFloat64) Update(float64)
func (FunctionalGaugeFloat64) Value ¶
func (g FunctionalGaugeFloat64) Value() float64
type Gauge ¶
func GetOrRegisterGauge ¶
Example ¶
m := "server.bytes_sent" g := GetOrRegisterGauge(m, nil) g.Update(47) fmt.Println(g.Value())
Output:
func NewFunctionalGauge ¶
func NewRegisteredGauge ¶
type GaugeFloat64 ¶
type GaugeFloat64 interface { Snapshot() GaugeFloat64 Update(float64) Value() float64 }
func GetOrRegisterGaugeFloat64 ¶
func GetOrRegisterGaugeFloat64(name string, r Registry) GaugeFloat64
func NewFunctionalGaugeFloat64 ¶
func NewFunctionalGaugeFloat64(f func() float64) GaugeFloat64
func NewGaugeFloat64 ¶
func NewGaugeFloat64() GaugeFloat64
func NewRegisteredFunctionalGaugeFloat64 ¶
func NewRegisteredFunctionalGaugeFloat64(name string, r Registry, f func() float64) GaugeFloat64
func NewRegisteredGaugeFloat64 ¶
func NewRegisteredGaugeFloat64(name string, r Registry) GaugeFloat64
type GaugeFloat64Snapshot ¶
type GaugeFloat64Snapshot float64
func (GaugeFloat64Snapshot) Snapshot ¶
func (g GaugeFloat64Snapshot) Snapshot() GaugeFloat64
func (GaugeFloat64Snapshot) Update ¶
func (GaugeFloat64Snapshot) Update(float64)
func (GaugeFloat64Snapshot) Value ¶
func (g GaugeFloat64Snapshot) Value() float64
type GaugeSnapshot ¶
type GaugeSnapshot int64
func (GaugeSnapshot) Snapshot ¶
func (g GaugeSnapshot) Snapshot() Gauge
func (GaugeSnapshot) Update ¶
func (GaugeSnapshot) Update(int64)
func (GaugeSnapshot) Value ¶
func (g GaugeSnapshot) Value() int64
type GraphiteConfig ¶
type Healthcheck ¶
func NewHealthcheck ¶
func NewHealthcheck(f func(Healthcheck)) Healthcheck
type Histogram ¶
type Histogram interface { Clear() Count() int64 Max() int64 Mean() float64 Min() int64 Percentile(float64) float64 Percentiles([]float64) []float64 Sample() Sample Snapshot() Histogram StdDev() float64 Sum() int64 Update(int64) Variance() float64 }
Histograms calculate distribution statistics from a series of int64 values.
func GetOrRegisterHistogram ¶
GetOrRegisterHistogram returns an existing Histogram or constructs and registers a new StandardHistogram.
func NewHistogram ¶
NewHistogram constructs a new StandardHistogram from a Sample.
type HistogramSnapshot ¶
type HistogramSnapshot struct {
// contains filtered or unexported fields
}
HistogramSnapshot is a read-only copy of another Histogram.
func (*HistogramSnapshot) Count ¶
func (h *HistogramSnapshot) Count() int64
Count returns the number of samples recorded at the time the snapshot was taken.
func (*HistogramSnapshot) Max ¶
func (h *HistogramSnapshot) Max() int64
Max returns the maximum value in the sample at the time the snapshot was taken.
func (*HistogramSnapshot) Mean ¶
func (h *HistogramSnapshot) Mean() float64
Mean returns the mean of the values in the sample at the time the snapshot was taken.
func (*HistogramSnapshot) Min ¶
func (h *HistogramSnapshot) Min() int64
Min returns the minimum value in the sample at the time the snapshot was taken.
func (*HistogramSnapshot) Percentile ¶
func (h *HistogramSnapshot) Percentile(p float64) float64
Percentile returns an arbitrary percentile of values in the sample at the time the snapshot was taken.
func (*HistogramSnapshot) Percentiles ¶
func (h *HistogramSnapshot) Percentiles(ps []float64) []float64
Percentiles returns a slice of arbitrary percentiles of values in the sample at the time the snapshot was taken.
func (*HistogramSnapshot) Sample ¶
func (h *HistogramSnapshot) Sample() Sample
Sample returns the Sample underlying the histogram.
func (*HistogramSnapshot) Snapshot ¶
func (h *HistogramSnapshot) Snapshot() Histogram
Snapshot returns the snapshot.
func (*HistogramSnapshot) StdDev ¶
func (h *HistogramSnapshot) StdDev() float64
StdDev returns the standard deviation of the values in the sample at the time the snapshot was taken.
func (*HistogramSnapshot) Sum ¶
func (h *HistogramSnapshot) Sum() int64
Sum returns the sum in the sample at the time the snapshot was taken.
func (*HistogramSnapshot) Variance ¶
func (h *HistogramSnapshot) Variance() float64
Variance returns the variance of inputs at the time the snapshot was taken.
type Int64Slice ¶
type Int64Slice []int64
Int64Slice attaches the methods of sort.Interface to []int64, sorting in increasing order.
func (Int64Slice) Len ¶
func (s Int64Slice) Len() int
func (Int64Slice) Less ¶
func (s Int64Slice) Less(i, j int) bool
func (Int64Slice) Swap ¶
func (s Int64Slice) Swap(i, j int)
type Meter ¶
type Meter interface { Count() int64 Mark(int64) Rate1() float64 Rate5() float64 Rate15() float64 RateMean() float64 Snapshot() Meter Stop() }
Meters count events to produce exponentially-weighted moving average rates at one-, five-, and fifteen-minutes and a mean rate.
func GetOrRegisterMeter ¶
GetOrRegisterMeter returns an existing Meter or constructs and registers a new StandardMeter. Be sure to unregister the meter from the registry once it is of no use to allow for garbage collection.
func NewMeter ¶
func NewMeter() Meter
NewMeter constructs a new StandardMeter and launches a goroutine. Be sure to call Stop() once the meter is of no use to allow for garbage collection.
func NewRegisteredMeter ¶
NewMeter constructs and registers a new StandardMeter and launches a goroutine. Be sure to unregister the meter from the registry once it is of no use to allow for garbage collection.
type MeterSnapshot ¶
type MeterSnapshot struct {
// contains filtered or unexported fields
}
MeterSnapshot is a read-only copy of another Meter.
func (*MeterSnapshot) Count ¶
func (m *MeterSnapshot) Count() int64
Count returns the count of events at the time the snapshot was taken.
func (*MeterSnapshot) Rate1 ¶
func (m *MeterSnapshot) Rate1() float64
Rate1 returns the one-minute moving average rate of events per second at the time the snapshot was taken.
func (*MeterSnapshot) Rate15 ¶
func (m *MeterSnapshot) Rate15() float64
Rate15 returns the fifteen-minute moving average rate of events per second at the time the snapshot was taken.
func (*MeterSnapshot) Rate5 ¶
func (m *MeterSnapshot) Rate5() float64
Rate5 returns the five-minute moving average rate of events per second at the time the snapshot was taken.
func (*MeterSnapshot) RateMean ¶
func (m *MeterSnapshot) RateMean() float64
RateMean returns the meter's mean rate of events per second at the time the snapshot was taken.
func (*MeterSnapshot) Snapshot ¶
func (m *MeterSnapshot) Snapshot() Meter
Snapshot returns the snapshot.
type NilCounter ¶
type NilCounter struct{}
func (NilCounter) Clear ¶
func (NilCounter) Clear()
func (NilCounter) Count ¶
func (NilCounter) Count() int64
func (NilCounter) Dec ¶
func (NilCounter) Dec(i int64)
func (NilCounter) Inc ¶
func (NilCounter) Inc(i int64)
func (NilCounter) Snapshot ¶
func (NilCounter) Snapshot() Counter
type NilGaugeFloat64 ¶
type NilGaugeFloat64 struct{}
func (NilGaugeFloat64) Snapshot ¶
func (NilGaugeFloat64) Snapshot() GaugeFloat64
func (NilGaugeFloat64) Update ¶
func (NilGaugeFloat64) Update(v float64)
func (NilGaugeFloat64) Value ¶
func (NilGaugeFloat64) Value() float64
type NilHealthcheck ¶
type NilHealthcheck struct{}
func (NilHealthcheck) Check ¶
func (NilHealthcheck) Check()
func (NilHealthcheck) Error ¶
func (NilHealthcheck) Error() error
func (NilHealthcheck) Healthy ¶
func (NilHealthcheck) Healthy()
func (NilHealthcheck) Unhealthy ¶
func (NilHealthcheck) Unhealthy(error)
type NilHistogram ¶
type NilHistogram struct{}
NilHistogram is a no-op Histogram.
func (NilHistogram) Percentile ¶
func (NilHistogram) Percentile(p float64) float64
Percentile is a no-op.
func (NilHistogram) Percentiles ¶
func (NilHistogram) Percentiles(ps []float64) []float64
Percentiles is a no-op.
type NilResettingTimer ¶
type NilResettingTimer struct { }
NilResettingTimer is a no-op ResettingTimer.
func (NilResettingTimer) Percentiles ¶
func (NilResettingTimer) Percentiles([]float64) []int64
Percentiles panics.
func (NilResettingTimer) Snapshot ¶
func (NilResettingTimer) Snapshot() ResettingTimer
Snapshot is a no-op.
func (NilResettingTimer) UpdateSince ¶
func (NilResettingTimer) UpdateSince(time.Time)
UpdateSince is a no-op.
type NilSample ¶
type NilSample struct{}
NilSample is a no-op Sample.
func (NilSample) Percentiles ¶
Percentiles is a no-op.
type NilTimer ¶
type NilTimer struct {
// contains filtered or unexported fields
}
func (NilTimer) Percentile ¶
func (NilTimer) Percentiles ¶
func (NilTimer) UpdateSince ¶
type OpenTSDBConfig ¶
type OpenTSDBConfig struct { Addr *net.TCPAddr // Network address to connect to Registry Registry // Registry to be exported FlushInterval time.Duration // Flush interval DurationUnit time.Duration // Time conversion unit for durations Prefix string // Prefix to be prepended to metric names }
OpenTSDBConfig provides a container with configuration parameters for the OpenTSDB exporter
type PrefixedRegistry ¶
type PrefixedRegistry struct {
// contains filtered or unexported fields
}
func (*PrefixedRegistry) Each ¶
func (r *PrefixedRegistry) Each(fn func(string, interface{}))
Call the given function for each registered metric.
func (*PrefixedRegistry) Get ¶
func (r *PrefixedRegistry) Get(name string) interface{}
Get the metric by the given name or nil if none is registered.
func (*PrefixedRegistry) GetAll ¶
func (r *PrefixedRegistry) GetAll() map[string]map[string]interface{}
GetAll metrics in the Registry
func (*PrefixedRegistry) GetOrRegister ¶
func (r *PrefixedRegistry) GetOrRegister(name string, metric interface{}) interface{}
Gets an existing metric or registers the given one. The interface can be the metric to register if not found in registry, or a function returning the metric for lazy instantiation.
func (*PrefixedRegistry) MarshalJSON ¶
func (p *PrefixedRegistry) MarshalJSON() ([]byte, error)
func (*PrefixedRegistry) Register ¶
func (r *PrefixedRegistry) Register(name string, metric interface{}) error
Register the given metric under the given name. The name will be prefixed.
func (*PrefixedRegistry) RunHealthchecks ¶
func (r *PrefixedRegistry) RunHealthchecks()
Run all registered healthchecks.
func (*PrefixedRegistry) Unregister ¶
func (r *PrefixedRegistry) Unregister(name string)
Unregister the metric with the given name. The name will be prefixed.
func (*PrefixedRegistry) UnregisterAll ¶
func (r *PrefixedRegistry) UnregisterAll()
Unregister all metrics. (Mostly for testing.)
type Registry ¶
type Registry interface { // Call the given function for each registered metric. Each(func(string, interface{})) // Get the metric by the given name or nil if none is registered. Get(string) interface{} // GetAll metrics in the Registry. GetAll() map[string]map[string]interface{} // Gets an existing metric or registers the given one. // The interface can be the metric to register if not found in registry, // or a function returning the metric for lazy instantiation. GetOrRegister(string, interface{}) interface{} // Register the given metric under the given name. Register(string, interface{}) error // Run all registered healthchecks. RunHealthchecks() // Unregister the metric with the given name. Unregister(string) // Unregister all metrics. (Mostly for testing.) UnregisterAll() }
A Registry holds references to a set of metrics by name and can iterate over them, calling callback functions provided by the user.
This is an interface so as to encourage other structs to implement the Registry API as appropriate.
var DefaultRegistry Registry = NewRegistry()
func NewPrefixedRegistry ¶
type ResettingTimer ¶
type ResettingTimer interface { Values() []int64 Snapshot() ResettingTimer Percentiles([]float64) []int64 Mean() float64 Time(func()) Update(time.Duration) UpdateSince(time.Time) }
ResettingTimer is used for storing aggregated values for timers, which are reset on every flush interval.
func GetOrRegisterResettingTimer ¶
func GetOrRegisterResettingTimer(name string, r Registry) ResettingTimer
GetOrRegisterResettingTimer returns an existing ResettingTimer or constructs and registers a new StandardResettingTimer.
func NewRegisteredResettingTimer ¶
func NewRegisteredResettingTimer(name string, r Registry) ResettingTimer
NewRegisteredResettingTimer constructs and registers a new StandardResettingTimer.
func NewResettingTimer ¶
func NewResettingTimer() ResettingTimer
NewResettingTimer constructs a new StandardResettingTimer
type ResettingTimerSnapshot ¶
type ResettingTimerSnapshot struct {
// contains filtered or unexported fields
}
ResettingTimerSnapshot is a point-in-time copy of another ResettingTimer.
func (*ResettingTimerSnapshot) Mean ¶
func (t *ResettingTimerSnapshot) Mean() float64
Mean returns the mean of the snapshotted values
func (*ResettingTimerSnapshot) Percentiles ¶
func (t *ResettingTimerSnapshot) Percentiles(percentiles []float64) []int64
Percentiles returns the boundaries for the input percentiles.
func (*ResettingTimerSnapshot) Snapshot ¶
func (t *ResettingTimerSnapshot) Snapshot() ResettingTimer
Snapshot returns the snapshot.
func (*ResettingTimerSnapshot) Update ¶
func (*ResettingTimerSnapshot) Update(time.Duration)
Update panics.
func (*ResettingTimerSnapshot) UpdateSince ¶
func (*ResettingTimerSnapshot) UpdateSince(time.Time)
UpdateSince panics.
func (*ResettingTimerSnapshot) Values ¶
func (t *ResettingTimerSnapshot) Values() []int64
Values returns all values from snapshot.
type Sample ¶
type Sample interface { Clear() Count() int64 Max() int64 Mean() float64 Min() int64 Percentile(float64) float64 Percentiles([]float64) []float64 Size() int Snapshot() Sample StdDev() float64 Sum() int64 Update(int64) Values() []int64 Variance() float64 }
Samples maintain a statistically-significant selection of values from a stream.
func NewExpDecaySample ¶
NewExpDecaySample constructs a new exponentially-decaying sample with the given reservoir size and alpha.
func NewUniformSample ¶
NewUniformSample constructs a new uniform sample with the given reservoir size.
type SampleSnapshot ¶
type SampleSnapshot struct {
// contains filtered or unexported fields
}
SampleSnapshot is a read-only copy of another Sample.
func NewSampleSnapshot ¶
func NewSampleSnapshot(count int64, values []int64) *SampleSnapshot
func (*SampleSnapshot) Count ¶
func (s *SampleSnapshot) Count() int64
Count returns the count of inputs at the time the snapshot was taken.
func (*SampleSnapshot) Max ¶
func (s *SampleSnapshot) Max() int64
Max returns the maximal value at the time the snapshot was taken.
func (*SampleSnapshot) Mean ¶
func (s *SampleSnapshot) Mean() float64
Mean returns the mean value at the time the snapshot was taken.
func (*SampleSnapshot) Min ¶
func (s *SampleSnapshot) Min() int64
Min returns the minimal value at the time the snapshot was taken.
func (*SampleSnapshot) Percentile ¶
func (s *SampleSnapshot) Percentile(p float64) float64
Percentile returns an arbitrary percentile of values at the time the snapshot was taken.
func (*SampleSnapshot) Percentiles ¶
func (s *SampleSnapshot) Percentiles(ps []float64) []float64
Percentiles returns a slice of arbitrary percentiles of values at the time the snapshot was taken.
func (*SampleSnapshot) Size ¶
func (s *SampleSnapshot) Size() int
Size returns the size of the sample at the time the snapshot was taken.
func (*SampleSnapshot) Snapshot ¶
func (s *SampleSnapshot) Snapshot() Sample
Snapshot returns the snapshot.
func (*SampleSnapshot) StdDev ¶
func (s *SampleSnapshot) StdDev() float64
StdDev returns the standard deviation of values at the time the snapshot was taken.
func (*SampleSnapshot) Sum ¶
func (s *SampleSnapshot) Sum() int64
Sum returns the sum of values at the time the snapshot was taken.
func (*SampleSnapshot) Values ¶
func (s *SampleSnapshot) Values() []int64
Values returns a copy of the values in the sample.
func (*SampleSnapshot) Variance ¶
func (s *SampleSnapshot) Variance() float64
Variance returns the variance of values at the time the snapshot was taken.
type StandardCounter ¶
type StandardCounter struct {
// contains filtered or unexported fields
}
func (*StandardCounter) Clear ¶
func (c *StandardCounter) Clear()
func (*StandardCounter) Count ¶
func (c *StandardCounter) Count() int64
func (*StandardCounter) Dec ¶
func (c *StandardCounter) Dec(i int64)
func (*StandardCounter) Inc ¶
func (c *StandardCounter) Inc(i int64)
func (*StandardCounter) Snapshot ¶
func (c *StandardCounter) Snapshot() Counter
type StandardEWMA ¶
type StandardEWMA struct {
// contains filtered or unexported fields
}
func (*StandardEWMA) Rate ¶
func (a *StandardEWMA) Rate() float64
func (*StandardEWMA) Snapshot ¶
func (a *StandardEWMA) Snapshot() EWMA
func (*StandardEWMA) Tick ¶
func (a *StandardEWMA) Tick()
func (*StandardEWMA) Update ¶
func (a *StandardEWMA) Update(n int64)
type StandardGauge ¶
type StandardGauge struct {
// contains filtered or unexported fields
}
func (*StandardGauge) Snapshot ¶
func (g *StandardGauge) Snapshot() Gauge
func (*StandardGauge) Update ¶
func (g *StandardGauge) Update(v int64)
func (*StandardGauge) Value ¶
func (g *StandardGauge) Value() int64
type StandardGaugeFloat64 ¶
type StandardGaugeFloat64 struct {
// contains filtered or unexported fields
}
func (*StandardGaugeFloat64) Snapshot ¶
func (g *StandardGaugeFloat64) Snapshot() GaugeFloat64
func (*StandardGaugeFloat64) Update ¶
func (g *StandardGaugeFloat64) Update(v float64)
func (*StandardGaugeFloat64) Value ¶
func (g *StandardGaugeFloat64) Value() float64
type StandardHealthcheck ¶
type StandardHealthcheck struct {
// contains filtered or unexported fields
}
func (*StandardHealthcheck) Check ¶
func (h *StandardHealthcheck) Check()
func (*StandardHealthcheck) Error ¶
func (h *StandardHealthcheck) Error() error
func (*StandardHealthcheck) Healthy ¶
func (h *StandardHealthcheck) Healthy()
func (*StandardHealthcheck) Unhealthy ¶
func (h *StandardHealthcheck) Unhealthy(err error)
type StandardHistogram ¶
type StandardHistogram struct {
// contains filtered or unexported fields
}
StandardHistogram is the standard implementation of a Histogram and uses a Sample to bound its memory use.
func (*StandardHistogram) Clear ¶
func (h *StandardHistogram) Clear()
Clear clears the histogram and its sample.
func (*StandardHistogram) Count ¶
func (h *StandardHistogram) Count() int64
Count returns the number of samples recorded since the histogram was last cleared.
func (*StandardHistogram) Max ¶
func (h *StandardHistogram) Max() int64
Max returns the maximum value in the sample.
func (*StandardHistogram) Mean ¶
func (h *StandardHistogram) Mean() float64
Mean returns the mean of the values in the sample.
func (*StandardHistogram) Min ¶
func (h *StandardHistogram) Min() int64
Min returns the minimum value in the sample.
func (*StandardHistogram) Percentile ¶
func (h *StandardHistogram) Percentile(p float64) float64
Percentile returns an arbitrary percentile of the values in the sample.
func (*StandardHistogram) Percentiles ¶
func (h *StandardHistogram) Percentiles(ps []float64) []float64
Percentiles returns a slice of arbitrary percentiles of the values in the sample.
func (*StandardHistogram) Sample ¶
func (h *StandardHistogram) Sample() Sample
Sample returns the Sample underlying the histogram.
func (*StandardHistogram) Snapshot ¶
func (h *StandardHistogram) Snapshot() Histogram
Snapshot returns a read-only copy of the histogram.
func (*StandardHistogram) StdDev ¶
func (h *StandardHistogram) StdDev() float64
StdDev returns the standard deviation of the values in the sample.
func (*StandardHistogram) Sum ¶
func (h *StandardHistogram) Sum() int64
Sum returns the sum in the sample.
func (*StandardHistogram) Update ¶
func (h *StandardHistogram) Update(v int64)
Update samples a new value.
func (*StandardHistogram) Variance ¶
func (h *StandardHistogram) Variance() float64
Variance returns the variance of the values in the sample.
type StandardMeter ¶
type StandardMeter struct {
// contains filtered or unexported fields
}
StandardMeter is the standard implementation of a Meter.
func (*StandardMeter) Count ¶
func (m *StandardMeter) Count() int64
Count returns the number of events recorded.
func (*StandardMeter) Mark ¶
func (m *StandardMeter) Mark(n int64)
Mark records the occurrence of n events.
func (*StandardMeter) Rate1 ¶
func (m *StandardMeter) Rate1() float64
Rate1 returns the one-minute moving average rate of events per second.
func (*StandardMeter) Rate15 ¶
func (m *StandardMeter) Rate15() float64
Rate15 returns the fifteen-minute moving average rate of events per second.
func (*StandardMeter) Rate5 ¶
func (m *StandardMeter) Rate5() float64
Rate5 returns the five-minute moving average rate of events per second.
func (*StandardMeter) RateMean ¶
func (m *StandardMeter) RateMean() float64
RateMean returns the meter's mean rate of events per second.
func (*StandardMeter) Snapshot ¶
func (m *StandardMeter) Snapshot() Meter
Snapshot returns a read-only copy of the meter.
func (*StandardMeter) Stop ¶
func (m *StandardMeter) Stop()
Stop stops the meter, Mark() will be a no-op if you use it after being stopped.
type StandardRegistry ¶
type StandardRegistry struct {
// contains filtered or unexported fields
}
The standard implementation of a Registry is a mutex-protected map of names to metrics.
func (*StandardRegistry) Each ¶
func (r *StandardRegistry) Each(f func(string, interface{}))
Call the given function for each registered metric.
func (*StandardRegistry) Get ¶
func (r *StandardRegistry) Get(name string) interface{}
Get the metric by the given name or nil if none is registered.
func (*StandardRegistry) GetAll ¶
func (r *StandardRegistry) GetAll() map[string]map[string]interface{}
GetAll metrics in the Registry
func (*StandardRegistry) GetOrRegister ¶
func (r *StandardRegistry) GetOrRegister(name string, i interface{}) interface{}
Gets an existing metric or creates and registers a new one. Threadsafe alternative to calling Get and Register on failure. The interface can be the metric to register if not found in registry, or a function returning the metric for lazy instantiation.
func (*StandardRegistry) MarshalJSON ¶
func (r *StandardRegistry) MarshalJSON() ([]byte, error)
MarshalJSON returns a byte slice containing a JSON representation of all the metrics in the Registry.
func (*StandardRegistry) Register ¶
func (r *StandardRegistry) Register(name string, i interface{}) error
Register the given metric under the given name. Returns a DuplicateMetric if a metric by the given name is already registered.
func (*StandardRegistry) RunHealthchecks ¶
func (r *StandardRegistry) RunHealthchecks()
Run all registered healthchecks.
func (*StandardRegistry) Unregister ¶
func (r *StandardRegistry) Unregister(name string)
Unregister the metric with the given name.
func (*StandardRegistry) UnregisterAll ¶
func (r *StandardRegistry) UnregisterAll()
Unregister all metrics. (Mostly for testing.)
type StandardResettingTimer ¶
type StandardResettingTimer struct {
// contains filtered or unexported fields
}
StandardResettingTimer is the standard implementation of a ResettingTimer. and Meter.
func (*StandardResettingTimer) Percentiles ¶
func (t *StandardResettingTimer) Percentiles([]float64) []int64
Percentiles panics.
func (*StandardResettingTimer) Snapshot ¶
func (t *StandardResettingTimer) Snapshot() ResettingTimer
Snapshot resets the timer and returns a read-only copy of its contents.
func (*StandardResettingTimer) Time ¶
func (t *StandardResettingTimer) Time(f func())
Record the duration of the execution of the given function.
func (*StandardResettingTimer) Update ¶
func (t *StandardResettingTimer) Update(d time.Duration)
Record the duration of an event.
func (*StandardResettingTimer) UpdateSince ¶
func (t *StandardResettingTimer) UpdateSince(ts time.Time)
Record the duration of an event that started at a time and ends now.
func (*StandardResettingTimer) Values ¶
func (t *StandardResettingTimer) Values() []int64
Values returns a slice with all measurements.
type StandardTimer ¶
type StandardTimer struct {
// contains filtered or unexported fields
}
func (*StandardTimer) Count ¶
func (t *StandardTimer) Count() int64
func (*StandardTimer) Max ¶
func (t *StandardTimer) Max() int64
func (*StandardTimer) Mean ¶
func (t *StandardTimer) Mean() float64
func (*StandardTimer) Min ¶
func (t *StandardTimer) Min() int64
func (*StandardTimer) Percentile ¶
func (t *StandardTimer) Percentile(p float64) float64
func (*StandardTimer) Percentiles ¶
func (t *StandardTimer) Percentiles(ps []float64) []float64
func (*StandardTimer) Rate1 ¶
func (t *StandardTimer) Rate1() float64
func (*StandardTimer) Rate15 ¶
func (t *StandardTimer) Rate15() float64
func (*StandardTimer) Rate5 ¶
func (t *StandardTimer) Rate5() float64
func (*StandardTimer) RateMean ¶
func (t *StandardTimer) RateMean() float64
func (*StandardTimer) Snapshot ¶
func (t *StandardTimer) Snapshot() Timer
func (*StandardTimer) StdDev ¶
func (t *StandardTimer) StdDev() float64
func (*StandardTimer) Stop ¶
func (t *StandardTimer) Stop()
func (*StandardTimer) Sum ¶
func (t *StandardTimer) Sum() int64
func (*StandardTimer) Time ¶
func (t *StandardTimer) Time(f func())
func (*StandardTimer) Update ¶
func (t *StandardTimer) Update(d time.Duration)
func (*StandardTimer) UpdateSince ¶
func (t *StandardTimer) UpdateSince(ts time.Time)
func (*StandardTimer) Variance ¶
func (t *StandardTimer) Variance() float64
type Stoppable ¶
type Stoppable interface {
Stop()
}
Stoppable defines the metrics which has to be stopped.
type Timer ¶
type Timer interface { Count() int64 Max() int64 Mean() float64 Min() int64 Percentile(float64) float64 Percentiles([]float64) []float64 Rate1() float64 Rate5() float64 Rate15() float64 RateMean() float64 Snapshot() Timer StdDev() float64 Stop() Sum() int64 Time(func()) Update(time.Duration) UpdateSince(time.Time) Variance() float64 }
func GetOrRegisterTimer ¶
Example ¶
m := "account.create.latency" t := GetOrRegisterTimer(m, nil) t.Update(47) fmt.Println(t.Max())
Output: 47
func NewCustomTimer ¶
func NewRegisteredTimer ¶
type TimerSnapshot ¶
type TimerSnapshot struct {
// contains filtered or unexported fields
}
func (*TimerSnapshot) Count ¶
func (t *TimerSnapshot) Count() int64
func (*TimerSnapshot) Max ¶
func (t *TimerSnapshot) Max() int64
func (*TimerSnapshot) Mean ¶
func (t *TimerSnapshot) Mean() float64
func (*TimerSnapshot) Min ¶
func (t *TimerSnapshot) Min() int64
func (*TimerSnapshot) Percentile ¶
func (t *TimerSnapshot) Percentile(p float64) float64
func (*TimerSnapshot) Percentiles ¶
func (t *TimerSnapshot) Percentiles(ps []float64) []float64
func (*TimerSnapshot) Rate1 ¶
func (t *TimerSnapshot) Rate1() float64
func (*TimerSnapshot) Rate15 ¶
func (t *TimerSnapshot) Rate15() float64
func (*TimerSnapshot) Rate5 ¶
func (t *TimerSnapshot) Rate5() float64
func (*TimerSnapshot) RateMean ¶
func (t *TimerSnapshot) RateMean() float64
func (*TimerSnapshot) Snapshot ¶
func (t *TimerSnapshot) Snapshot() Timer
func (*TimerSnapshot) StdDev ¶
func (t *TimerSnapshot) StdDev() float64
func (*TimerSnapshot) Stop ¶
func (t *TimerSnapshot) Stop()
func (*TimerSnapshot) Sum ¶
func (t *TimerSnapshot) Sum() int64
func (*TimerSnapshot) Time ¶
func (*TimerSnapshot) Time(func())
func (*TimerSnapshot) Update ¶
func (*TimerSnapshot) Update(time.Duration)
func (*TimerSnapshot) UpdateSince ¶
func (*TimerSnapshot) UpdateSince(time.Time)
func (*TimerSnapshot) Variance ¶
func (t *TimerSnapshot) Variance() float64
type UniformSample ¶
type UniformSample struct {
// contains filtered or unexported fields
}
A uniform sample using Vitter's Algorithm R.
<http://www.cs.umd.edu/~samir/498/vitter.pdf>
func (*UniformSample) Count ¶
func (s *UniformSample) Count() int64
Count returns the number of samples recorded, which may exceed the reservoir size.
func (*UniformSample) Max ¶
func (s *UniformSample) Max() int64
Max returns the maximum value in the sample, which may not be the maximum value ever to be part of the sample.
func (*UniformSample) Mean ¶
func (s *UniformSample) Mean() float64
Mean returns the mean of the values in the sample.
func (*UniformSample) Min ¶
func (s *UniformSample) Min() int64
Min returns the minimum value in the sample, which may not be the minimum value ever to be part of the sample.
func (*UniformSample) Percentile ¶
func (s *UniformSample) Percentile(p float64) float64
Percentile returns an arbitrary percentile of values in the sample.
func (*UniformSample) Percentiles ¶
func (s *UniformSample) Percentiles(ps []float64) []float64
Percentiles returns a slice of arbitrary percentiles of values in the sample.
func (*UniformSample) Size ¶
func (s *UniformSample) Size() int
Size returns the size of the sample, which is at most the reservoir size.
func (*UniformSample) Snapshot ¶
func (s *UniformSample) Snapshot() Sample
Snapshot returns a read-only copy of the sample.
func (*UniformSample) StdDev ¶
func (s *UniformSample) StdDev() float64
StdDev returns the standard deviation of the values in the sample.
func (*UniformSample) Sum ¶
func (s *UniformSample) Sum() int64
Sum returns the sum of the values in the sample.
func (*UniformSample) Values ¶
func (s *UniformSample) Values() []int64
Values returns a copy of the values in the sample.
func (*UniformSample) Variance ¶
func (s *UniformSample) Variance() float64
Variance returns the variance of the values in the sample.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Hook go-metrics into expvar on any /debug/metrics request, load all vars from the registry into expvar, and execute regular expvar handler
|
Hook go-metrics into expvar on any /debug/metrics request, load all vars from the registry into expvar, and execute regular expvar handler |