Documentation ¶
Overview ¶
Go port of Coda Hale's Metrics library
<https://github.com/msaf1980/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() {}) // t.Update(1) fmt.Println(c.Count()) // fmt.Println(t.Min())
Output:
Index ¶
- Variables
- func CaptureRuntimeMemStats(d time.Duration)
- func CaptureRuntimeMemStatsOnce()
- func Each(f func(name, tags string, tagsMap map[string]string, i interface{}) error, ...) error
- func Get(name string) interface{}
- func GetOrRegister(name string, i interface{}) interface{}
- func GetOrRegisterT(name string, tagsMap map[string]string, i interface{}) interface{}
- func GetT(name string, tagsMap map[string]string) interface{}
- func JoinTags(tagsMap map[string]string) string
- func Max(a, b int) int
- func MergeTags(a, b map[string]string) map[string]string
- func Min(a, b int) int
- func MustRegister(name string, i interface{})
- func MustRegisterT(name string, tagsMap map[string]string, i interface{})
- func Register(name string, i interface{}) error
- func RegisterRuntimeMemStats(r Registry)
- func RegisterT(name string, tagsMap map[string]string, i interface{}) error
- func RunHealthchecks()
- func Unregister(name string)
- func UnregisterT(name string, tagsMap map[string]string)
- type Counter
- func GetOrRegisterCounter(name string, r Registry) Counter
- func GetOrRegisterCounterT(name string, tagsMap map[string]string, r Registry) Counter
- func NewCounter() Counter
- func NewRegisteredCounter(name string, r Registry) Counter
- func NewRegisteredCounterT(name string, tagsMap map[string]string, r Registry) Counter
- type CounterSnapshot
- type DownCounter
- func GetOrRegisterDownCounter(name string, r Registry) DownCounter
- func GetOrRegisterDownCounterT(name string, tagsMap map[string]string, r Registry) DownCounter
- func NewDownCounter() DownCounter
- func NewRegisteredDownCounter(name string, r Registry) DownCounter
- func NewRegisteredDownCounterT(name string, tagsMap map[string]string, r Registry) DownCounter
- type DownCounterSnapshot
- type DuplicateMetric
- type FFixedHistogram
- type FHistogram
- func GetOrRegisterFFixedHistogram(name string, r Registry, startVal, endVal, width float64) FHistogram
- func GetOrRegisterFFixedHistogramT(name string, tagsMap map[string]string, r Registry, ...) FHistogram
- func GetOrRegisterFVHistogram(name string, r Registry, weights []float64, names []string) FHistogram
- func GetOrRegisterFVHistogramT(name string, tagsMap map[string]string, r Registry, weights []float64, ...) FHistogram
- func NewFFixedHistogram(startVal, endVal, width float64) FHistogram
- func NewRegisteredFFixedHistogram(name string, r Registry, startVal, endVal, width float64) FHistogram
- func NewRegisteredFFixedHistogramT(name string, tagsMap map[string]string, r Registry, ...) FHistogram
- func NewRegisteredFVHistogram(name string, r Registry, weights []float64, names []string) FHistogram
- func NewRegisteredFVHistogramT(name string, tagsMap map[string]string, r Registry, weights []float64, ...) FHistogram
- type FHistogramSnapshot
- func (h *FHistogramSnapshot) Add(v float64)
- func (FHistogramSnapshot) AddLabelPrefix(string) FHistogram
- func (h *FHistogramSnapshot) Clear()
- func (h *FHistogramSnapshot) Interface() HistogramInterface
- func (h *FHistogramSnapshot) Labels() []string
- func (h *FHistogramSnapshot) NameTotal() string
- func (FHistogramSnapshot) SetLabels([]string) FHistogram
- func (FHistogramSnapshot) SetNameTotal(string) FHistogram
- func (h *FHistogramSnapshot) Snapshot() FHistogram
- func (h *FHistogramSnapshot) Values() []uint64
- func (h *FHistogramSnapshot) Weights() []float64
- func (h *FHistogramSnapshot) WeightsAliases() []string
- type FHistogramStorage
- func (h *FHistogramStorage) AddLabelPrefix(labelPrefix string)
- func (h *FHistogramStorage) Clear()
- func (h *FHistogramStorage) Interface() HistogramInterface
- func (h *FHistogramStorage) Labels() []string
- func (h *FHistogramStorage) NameTotal() string
- func (h *FHistogramStorage) SetLabels(labels []string)
- func (h *FHistogramStorage) SetNameTotal(total string)
- func (h *FHistogramStorage) Snapshot() FHistogram
- func (h *FHistogramStorage) Values() []uint64
- func (h *FHistogramStorage) Weights() []float64
- func (h *FHistogramStorage) WeightsAliases() []string
- type FRate
- type FRateNames
- type FRateSnapshot
- func (FRateSnapshot) Clear() (float64, float64)
- func (g *FRateSnapshot) Name() string
- func (g *FRateSnapshot) RateName() string
- func (FRateSnapshot) SetName(string) FRate
- func (FRateSnapshot) SetRateName(string) FRate
- func (g *FRateSnapshot) Snapshot() FRate
- func (FRateSnapshot) Update(float64)
- func (FRateSnapshot) UpdateTs(float64, int64)
- func (g *FRateSnapshot) Values() (float64, float64)
- type FVHistogram
- func (h *FVHistogram) Add(v float64)
- func (h *FVHistogram) AddLabelPrefix(labelPrefix string) FHistogram
- func (h *FVHistogram) Clear()
- func (h *FVHistogram) SetLabels(labels []string) FHistogram
- func (h *FVHistogram) SetNameTotal(total string) FHistogram
- func (h *FVHistogram) Snapshot() FHistogram
- func (h *FVHistogram) Values() []uint64
- type FixedHistogram
- type FunctionalGauge
- type FunctionalGaugeFloat64
- type Gauge
- func GetOrRegisterDiffer(name string, r Registry, d int64) Gauge
- func GetOrRegisterDifferT(name string, tagsMap map[string]string, r Registry, d int64) Gauge
- func GetOrRegisterGauge(name string, r Registry) Gauge
- func GetOrRegisterGaugeT(name string, tagsMap map[string]string, r Registry) Gauge
- func NewDiffer(d int64) Gauge
- func NewFunctionalGauge(f func() int64) Gauge
- func NewGauge() Gauge
- func NewRegisteredDiffer(name string, r Registry, d int64) Gauge
- func NewRegisteredDifferT(name string, tagsMap map[string]string, r Registry, d int64) Gauge
- func NewRegisteredFunctionalGauge(name string, r Registry, f func() int64) Gauge
- func NewRegisteredFunctionalGaugeT(name string, tagsMap map[string]string, r Registry, f func() int64) Gauge
- func NewRegisteredGauge(name string, r Registry) Gauge
- func NewRegisteredGaugeT(name string, tagsMap map[string]string, r Registry) Gauge
- type GaugeFloat64
- func GetOrRegisterGaugeFloat64(name string, r Registry) GaugeFloat64
- func GetOrRegisterGaugeFloat64T(name string, tagsMap map[string]string, r Registry) GaugeFloat64
- func NewFunctionalGaugeFloat64(f func() float64) GaugeFloat64
- func NewGaugeFloat64() GaugeFloat64
- func NewRegisteredFunctionalGaugeFloat64(name string, r Registry, f func() float64) GaugeFloat64
- func NewRegisteredFunctionalGaugeFloat64T(name string, tagsMap map[string]string, r Registry, f func() float64) GaugeFloat64
- func NewRegisteredGaugeFloat64(name string, r Registry) GaugeFloat64
- func NewRegisteredGaugeFloat64T(name string, tagsMap map[string]string, r Registry) GaugeFloat64
- type GaugeFloat64Snapshot
- type GaugeSnapshot
- type Healthcheck
- type Histogram
- func GetOrRegisterFixedHistogram(name string, r Registry, startVal, endVal, width int64) Histogram
- func GetOrRegisterFixedHistogramT(name string, tagsMap map[string]string, r Registry, ...) Histogram
- func GetOrRegisterVHistogram(name string, r Registry, weights []int64, names []string) Histogram
- func GetOrRegisterVHistogramT(name string, tagsMap map[string]string, r Registry, weights []int64, ...) Histogram
- func NewRegisteredFixedHistogram(name string, r Registry, startVal, endVal, width int64) Histogram
- func NewRegisteredFixedHistogramT(name string, tagsMap map[string]string, r Registry, ...) Histogram
- func NewRegisteredVHistogram(name string, r Registry, weights []int64, names []string) Histogram
- func NewRegisteredVHistogramT(name string, tagsMap map[string]string, r Registry, weights []int64, ...) Histogram
- type HistogramInterface
- type HistogramSnapshot
- func (h *HistogramSnapshot) Add(v int64)
- func (HistogramSnapshot) AddLabelPrefix(string) Histogram
- func (h *HistogramSnapshot) Clear()
- func (h *HistogramSnapshot) Interface() HistogramInterface
- func (h *HistogramSnapshot) Labels() []string
- func (h *HistogramSnapshot) NameTotal() string
- func (HistogramSnapshot) SetLabels([]string) Histogram
- func (HistogramSnapshot) SetNameTotal(string) Histogram
- func (h *HistogramSnapshot) Snapshot() Histogram
- func (h *HistogramSnapshot) Values() []uint64
- func (h *HistogramSnapshot) Weights() []int64
- func (h *HistogramSnapshot) WeightsAliases() []string
- type HistogramStorage
- func (h *HistogramStorage) AddLabelPrefix(labelPrefix string)
- func (h *HistogramStorage) Clear()
- func (h *HistogramStorage) Interface() HistogramInterface
- func (h *HistogramStorage) Labels() []string
- func (h *HistogramStorage) NameTotal() string
- func (h *HistogramStorage) SetLabels(labels []string)
- func (h *HistogramStorage) SetNameTotal(total string)
- func (h *HistogramStorage) Snapshot() Histogram
- func (h *HistogramStorage) Values() []uint64
- func (h *HistogramStorage) Weights() []int64
- func (h *HistogramStorage) WeightsAliases() []string
- type NameTagged
- type NilCounter
- type NilDownCounter
- type NilFRate
- func (NilFRate) Clear() (float64, float64)
- func (NilFRate) Name() string
- func (NilFRate) RateName() string
- func (g NilFRate) SetName(string) FRate
- func (g NilFRate) SetRateName(string) FRate
- func (NilFRate) Snapshot() FRate
- func (NilFRate) Update(float64)
- func (NilFRate) UpdateTs(float64, int64)
- func (NilFRate) Values() (float64, float64)
- type NilGauge
- type NilGaugeFloat64
- type NilHealthcheck
- type NilRate
- func (NilRate) Clear() (int64, float64)
- func (NilRate) Name() string
- func (NilRate) RateName() string
- func (g NilRate) SetName(string) Rate
- func (g NilRate) SetRateName(string) Rate
- func (NilRate) Snapshot() Rate
- func (NilRate) Update(int64)
- func (NilRate) UpdateTs(int64, int64)
- func (NilRate) Values() (int64, float64)
- type Rate
- type RateNames
- type RateSnapshot
- func (RateSnapshot) Clear() (int64, float64)
- func (g *RateSnapshot) Name() string
- func (g *RateSnapshot) RateName() string
- func (RateSnapshot) SetName(string) Rate
- func (RateSnapshot) SetRateName(string) Rate
- func (g *RateSnapshot) Snapshot() Rate
- func (RateSnapshot) Update(int64)
- func (RateSnapshot) UpdateTs(int64, int64)
- func (g *RateSnapshot) Values() (int64, float64)
- type Registry
- type StandardCounter
- type StandardDiffer
- type StandardDownCounter
- type StandardFRate
- func (g *StandardFRate) Clear() (float64, float64)
- func (g *StandardFRate) Name() string
- func (g *StandardFRate) RateName() string
- func (g *StandardFRate) SetName(name string) FRate
- func (g *StandardFRate) SetRateName(rateName string) FRate
- func (g *StandardFRate) Snapshot() FRate
- func (g *StandardFRate) Update(v float64)
- func (g *StandardFRate) UpdateTs(v float64, ts int64)
- func (g *StandardFRate) Values() (float64, float64)
- type StandardGauge
- type StandardGaugeFloat64
- type StandardHealthcheck
- type StandardRate
- func (g *StandardRate) Clear() (int64, float64)
- func (g *StandardRate) Name() string
- func (g *StandardRate) RateName() string
- func (g *StandardRate) SetName(name string) Rate
- func (g *StandardRate) SetRateName(rateName string) Rate
- func (g *StandardRate) Snapshot() Rate
- func (g *StandardRate) Update(v int64)
- func (g *StandardRate) UpdateTs(v int64, ts int64)
- func (g *StandardRate) Values() (int64, float64)
- type StandardRegistry
- func (r *StandardRegistry) Each(f func(string, string, map[string]string, interface{}) error, minLock bool) error
- 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) GetOrRegisterT(name string, tagsMap map[string]string, i interface{}) interface{}
- func (r *StandardRegistry) GetT(name string, tagsMap map[string]string) interface{}
- func (r *StandardRegistry) Register(name string, i interface{}) error
- func (r *StandardRegistry) RegisterT(name string, tagsMap map[string]string, i interface{}) error
- func (r *StandardRegistry) RunHealthchecks()
- func (r *StandardRegistry) Unregister(name string)
- func (r *StandardRegistry) UnregisterAll()
- func (r *StandardRegistry) UnregisterT(name string, tagsMap map[string]string)
- type UFixedHistogram
- type UHistogram
- func GetOrRegisterUFixedHistogram(name string, r Registry, startVal, endVal, width uint64) UHistogram
- func GetOrRegisterUFixedHistogramT(name string, tagsMap map[string]string, r Registry, ...) UHistogram
- func GetOrRegisterUVHistogram(name string, r Registry, weights []uint64, names []string) UHistogram
- func GetOrRegisterUVHistogramT(name string, tagsMap map[string]string, r Registry, weights []uint64, ...) UHistogram
- func NewRegisteredUFixedHistogram(name string, r Registry, startVal, endVal, width uint64) UHistogram
- func NewRegisteredUFixedHistogramT(name string, tagsMap map[string]string, r Registry, ...) UHistogram
- func NewRegisteredUVHistogram(name string, r Registry, weights []uint64, names []string) UHistogram
- func NewRegisteredUVHistogramT(name string, tagsMap map[string]string, r Registry, weights []uint64, ...) UHistogram
- type UHistogramSnapshot
- func (h *UHistogramSnapshot) Add(v uint64)
- func (UHistogramSnapshot) AddLabelPrefix(string) UHistogram
- func (h *UHistogramSnapshot) Clear()
- func (h *UHistogramSnapshot) Interface() HistogramInterface
- func (h *UHistogramSnapshot) Labels() []string
- func (h *UHistogramSnapshot) NameTotal() string
- func (UHistogramSnapshot) SetLabels([]string) UHistogram
- func (UHistogramSnapshot) SetNameTotal(string) UHistogram
- func (h *UHistogramSnapshot) Snapshot() UHistogram
- func (h *UHistogramSnapshot) Values() []uint64
- func (h *UHistogramSnapshot) Weights() []uint64
- func (h *UHistogramSnapshot) WeightsAliases() []string
- type UHistogramStorage
- func (h *UHistogramStorage) AddLabelPrefix(labelPrefix string)
- func (h *UHistogramStorage) Clear()
- func (h *UHistogramStorage) Interface() HistogramInterface
- func (h *UHistogramStorage) Labels() []string
- func (h *UHistogramStorage) NameTotal() string
- func (h *UHistogramStorage) SetLabels(labels []string)
- func (h *UHistogramStorage) SetNameTotal(total string)
- func (h *UHistogramStorage) Snapshot() UHistogram
- func (h *UHistogramStorage) Values() []uint64
- func (h *UHistogramStorage) Weights() []uint64
- func (h *UHistogramStorage) WeightsAliases() []string
- type UVHistogram
- func (h *UVHistogram) Add(v uint64)
- func (h *UVHistogram) AddLabelPrefix(labelPrefix string) UHistogram
- func (h *UVHistogram) Clear()
- func (h *UVHistogram) SetLabels(labels []string) UHistogram
- func (h *UVHistogram) SetNameTotal(total string) UHistogram
- func (h *UVHistogram) Snapshot() UHistogram
- func (h *UVHistogram) Values() []uint64
- type Updated
- type VHistogram
- func (h *VHistogram) Add(v int64)
- func (h *VHistogram) AddLabelPrefix(labelPrefix string) Histogram
- func (h *VHistogram) Clear()
- func (h *VHistogram) Interface() HistogramInterface
- func (h *VHistogram) SetLabels(labels []string) Histogram
- func (h *VHistogram) SetNameTotal(total string) Histogram
- func (h *VHistogram) Snapshot() Histogram
- func (h *VHistogram) Values() []uint64
- func (h *VHistogram) WeightsAliases() []string
- type ValTagged
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( RuntimeNames struct { MemStats struct { Alloc string BuckHashSys string Frees string HeapAlloc string HeapIdle string HeapInUse string HeapObjects string HeapReleased string HeapSys string LastGC string Lookups string Mallocs string MCacheInUse string MCacheSys string MSpanInuse string MSpanSys string NextGC string NumGC string GCCPUFraction string // PauseNs Histogram PauseTotalNs string StackInUse string StackSys string Sys string TotalAlloc string } NumCgoCall string NumGoroutine string NumThread string } )
var UseNilMetrics bool = false
UseNilMetrics 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 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()
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 Each ¶
func Each(f func(name, tags string, tagsMap map[string]string, i interface{}) error, minLock bool) error
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 GetOrRegisterT ¶
Gets an existing metric or creates and registers a new one. Threadsafe alternative to calling Get and Register on failure.
func JoinTags ¶
JoinTags convert tags map sorted tags string representation (separated by comma), like tags or Graphite
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 MustRegisterT ¶
Register the given metric under the given name. Panics if a metric by the given name is already registered.
func Register ¶
Register the given metric under the given name. Returns a DuplicateMetric if a metric by the given name is already registered.
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 RegisterT ¶
Register the given metric under the given name. Returns a DuplicateMetric if a metric by the given name is already registered.
func UnregisterT ¶
Unregister the metric with the given name.
Types ¶
type Counter ¶
Counters hold an uint64 value that can be incremented only
func GetOrRegisterCounter ¶
GetOrRegisterCounter returns an existing Counter or constructs and registers a new StandardCounter.
func GetOrRegisterCounterT ¶
GetOrRegisterCounterT returns an existing Counter or constructs and registers a new StandardCounter.
func NewRegisteredCounter ¶
NewRegisteredCounter constructs and registers a new StandardCounter.
type CounterSnapshot ¶
type CounterSnapshot uint64
CounterSnapshot is a read-only copy of another Counter.
func (CounterSnapshot) Count ¶
func (c CounterSnapshot) Count() uint64
Count returns the count at the time the snapshot was taken.
func (CounterSnapshot) Snapshot ¶
func (c CounterSnapshot) Snapshot() Counter
Snapshot returns the snapshot.
type DownCounter ¶
type DownCounter interface { Clear() int64 Count() int64 Inc(int64) Dec(int64) Snapshot() DownCounter }
DownCounters hold an int64 value that can be incremented/decremented
func GetOrRegisterDownCounter ¶
func GetOrRegisterDownCounter(name string, r Registry) DownCounter
GetOrRegisterDownCounter returns an existing DownCounter or constructs and registers a new StandardDownCounter.
func GetOrRegisterDownCounterT ¶
func GetOrRegisterDownCounterT(name string, tagsMap map[string]string, r Registry) DownCounter
GetOrRegisterDownCounterT returns an existing DownCounter or constructs and registers a new StandardDownCounter.
func NewDownCounter ¶
func NewDownCounter() DownCounter
NewDownCounter constructs a new StandardDownCounter.
func NewRegisteredDownCounter ¶
func NewRegisteredDownCounter(name string, r Registry) DownCounter
NewRegisteredDownCounter constructs and registers a new StandardDownCounter.
func NewRegisteredDownCounterT ¶
func NewRegisteredDownCounterT(name string, tagsMap map[string]string, r Registry) DownCounter
NewRegisteredDownCounterT constructs and registers a new StandardDownCounter.
type DownCounterSnapshot ¶
type DownCounterSnapshot uint64
DownCounterSnapshot is a read-only copy of another DownCounter.
func (DownCounterSnapshot) Count ¶
func (c DownCounterSnapshot) Count() int64
Count returns the count at the time the snapshot was taken.
func (DownCounterSnapshot) Snapshot ¶
func (c DownCounterSnapshot) Snapshot() DownCounter
Snapshot returns the snapshot.
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 FFixedHistogram ¶
type FFixedHistogram struct { FHistogramStorage // contains filtered or unexported fields }
A FFixedHistogram is implementation of FHistogram with fixed-size buckets.
func (*FFixedHistogram) Add ¶
func (h *FFixedHistogram) Add(v float64)
func (*FFixedHistogram) AddLabelPrefix ¶
func (h *FFixedHistogram) AddLabelPrefix(labelPrefix string) FHistogram
func (*FFixedHistogram) SetLabels ¶
func (h *FFixedHistogram) SetLabels(labels []string) FHistogram
func (*FFixedHistogram) SetNameTotal ¶
func (h *FFixedHistogram) SetNameTotal(total string) FHistogram
type FHistogram ¶
type FHistogram interface { HistogramInterface SetLabels([]string) FHistogram AddLabelPrefix(string) FHistogram SetNameTotal(string) FHistogram Snapshot() FHistogram Clear() Add(v float64) Weights() []float64 }
A FHistogram is a lossy data structure used to record the distribution of non-normally distributed data (like latency) with a high degree of accuracy and a bounded degree of precision.
func GetOrRegisterFFixedHistogram ¶
func GetOrRegisterFFixedHistogram(name string, r Registry, startVal, endVal, width float64) FHistogram
GetOrRegisterFHistoram returns an existing FHistogram or constructs and registers a new FFixedHistorgam.
func GetOrRegisterFFixedHistogramT ¶
func GetOrRegisterFFixedHistogramT(name string, tagsMap map[string]string, r Registry, startVal, endVal, width float64) FHistogram
GetOrRegisterHistoramT returns an existing Histogram or constructs and registers a new FixedHistorgam.
func GetOrRegisterFVHistogram ¶
func GetOrRegisterFVHistogram(name string, r Registry, weights []float64, names []string) FHistogram
func NewFFixedHistogram ¶
func NewFFixedHistogram(startVal, endVal, width float64) FHistogram
func NewRegisteredFFixedHistogram ¶
func NewRegisteredFFixedHistogram(name string, r Registry, startVal, endVal, width float64) FHistogram
NewRegisteredFixedHistogram constructs and registers a new FixedHistogram.
func NewRegisteredFFixedHistogramT ¶
func NewRegisteredFFixedHistogramT(name string, tagsMap map[string]string, r Registry, startVal, endVal, width float64) FHistogram
NewRegisteredFixedHistogramT constructs and registers a new FixedHistogram.
func NewRegisteredFVHistogram ¶
func NewRegisteredFVHistogram(name string, r Registry, weights []float64, names []string) FHistogram
NewRegisteredVHistogram constructs and registers a new VHistogram.
func NewRegisteredFVHistogramT ¶
func NewRegisteredFVHistogramT(name string, tagsMap map[string]string, r Registry, weights []float64, names []string) FHistogram
NewRegisteredVHistogramT constructs and registers a new VHistogram.
type FHistogramSnapshot ¶
type FHistogramSnapshot struct {
// contains filtered or unexported fields
}
func (*FHistogramSnapshot) Add ¶
func (h *FHistogramSnapshot) Add(v float64)
func (FHistogramSnapshot) AddLabelPrefix ¶
func (FHistogramSnapshot) AddLabelPrefix(string) FHistogram
func (*FHistogramSnapshot) Clear ¶
func (h *FHistogramSnapshot) Clear()
func (*FHistogramSnapshot) Interface ¶
func (h *FHistogramSnapshot) Interface() HistogramInterface
for static check compatbility with HistogramInterface
func (*FHistogramSnapshot) Labels ¶
func (h *FHistogramSnapshot) Labels() []string
func (*FHistogramSnapshot) NameTotal ¶
func (h *FHistogramSnapshot) NameTotal() string
func (FHistogramSnapshot) SetLabels ¶
func (FHistogramSnapshot) SetLabels([]string) FHistogram
func (FHistogramSnapshot) SetNameTotal ¶
func (FHistogramSnapshot) SetNameTotal(string) FHistogram
func (*FHistogramSnapshot) Snapshot ¶
func (h *FHistogramSnapshot) Snapshot() FHistogram
func (*FHistogramSnapshot) Values ¶
func (h *FHistogramSnapshot) Values() []uint64
func (*FHistogramSnapshot) Weights ¶
func (h *FHistogramSnapshot) Weights() []float64
func (*FHistogramSnapshot) WeightsAliases ¶
func (h *FHistogramSnapshot) WeightsAliases() []string
type FHistogramStorage ¶
type FHistogramStorage struct {
// contains filtered or unexported fields
}
func (*FHistogramStorage) AddLabelPrefix ¶
func (h *FHistogramStorage) AddLabelPrefix(labelPrefix string)
func (*FHistogramStorage) Clear ¶
func (h *FHistogramStorage) Clear()
func (*FHistogramStorage) Interface ¶
func (h *FHistogramStorage) Interface() HistogramInterface
for static check compatbility with HistogramInterface
func (*FHistogramStorage) Labels ¶
func (h *FHistogramStorage) Labels() []string
func (*FHistogramStorage) NameTotal ¶
func (h *FHistogramStorage) NameTotal() string
func (*FHistogramStorage) SetLabels ¶
func (h *FHistogramStorage) SetLabels(labels []string)
func (*FHistogramStorage) SetNameTotal ¶
func (h *FHistogramStorage) SetNameTotal(total string)
func (*FHistogramStorage) Snapshot ¶
func (h *FHistogramStorage) Snapshot() FHistogram
func (*FHistogramStorage) Values ¶
func (h *FHistogramStorage) Values() []uint64
func (*FHistogramStorage) Weights ¶
func (h *FHistogramStorage) Weights() []float64
func (*FHistogramStorage) WeightsAliases ¶
func (h *FHistogramStorage) WeightsAliases() []string
type FRate ¶
type FRate interface { FRateNames Snapshot() FRate Clear() (float64, float64) Update(v float64) UpdateTs(v float64, timestamp_ns int64) Values() (float64, float64) }
FRate hold an int64 value and timestamp (current and previous) and return diff and diff/s.
func GetOrRegisterFRate ¶
GetOrRegisterFRate returns an existing FRate or constructs and registers a new StandardFRate.
Example ¶
m := "server.memory_used" r := NewRegistry() g := GetOrRegisterFRate(m, r) g.UpdateTs(1.1, 1e9) g.UpdateTs(7.1, 3e9) fmt.Println(g.Values())
Output: 7.1 3
func GetOrRegisterFRateT ¶
GetOrRegisterFRateT returns an existing FRate or constructs and registers a new StandardFRate.
func NewRegisteredFRate ¶
NewRegisteredFRate constructs and registers a new StandardFRate.
type FRateNames ¶
type FRateSnapshot ¶
type FRateSnapshot struct { FRate float64 // contains filtered or unexported fields }
FRateSnapshot is a read-only copy of another FRate.
func (*FRateSnapshot) Name ¶
func (g *FRateSnapshot) Name() string
func (*FRateSnapshot) RateName ¶
func (g *FRateSnapshot) RateName() string
func (FRateSnapshot) SetName ¶
func (FRateSnapshot) SetName(string) FRate
func (FRateSnapshot) SetRateName ¶
func (FRateSnapshot) SetRateName(string) FRate
func (*FRateSnapshot) Snapshot ¶
func (g *FRateSnapshot) Snapshot() FRate
Snapshot returns the snapshot.
func (*FRateSnapshot) Values ¶
func (g *FRateSnapshot) Values() (float64, float64)
Value returns the value at the time the snapshot was taken.
type FVHistogram ¶
type FVHistogram struct {
FHistogramStorage
}
A FVHistogram is implementation of FHistogram with varibale-size buckets.
func NewFVHistogram ¶
func NewFVHistogram(weights []float64, names []string) *FVHistogram
func (*FVHistogram) Add ¶
func (h *FVHistogram) Add(v float64)
func (*FVHistogram) AddLabelPrefix ¶
func (h *FVHistogram) AddLabelPrefix(labelPrefix string) FHistogram
func (*FVHistogram) Clear ¶
func (h *FVHistogram) Clear()
func (*FVHistogram) SetLabels ¶
func (h *FVHistogram) SetLabels(labels []string) FHistogram
func (*FVHistogram) SetNameTotal ¶
func (h *FVHistogram) SetNameTotal(total string) FHistogram
func (*FVHistogram) Snapshot ¶
func (h *FVHistogram) Snapshot() FHistogram
func (*FVHistogram) Values ¶
func (h *FVHistogram) Values() []uint64
type FixedHistogram ¶
type FixedHistogram struct { HistogramStorage // contains filtered or unexported fields }
A FixedHistogram is implementation of Histogram with fixed-size buckets.
func NewFixedHistogram ¶
func NewFixedHistogram(startVal, endVal, width int64) *FixedHistogram
func (*FixedHistogram) Add ¶
func (h *FixedHistogram) Add(v int64)
func (*FixedHistogram) AddLabelPrefix ¶
func (h *FixedHistogram) AddLabelPrefix(labelPrefix string) Histogram
func (*FixedHistogram) SetLabels ¶
func (h *FixedHistogram) SetLabels(labels []string) Histogram
func (*FixedHistogram) SetNameTotal ¶
func (h *FixedHistogram) SetNameTotal(total string) Histogram
type FunctionalGauge ¶
type FunctionalGauge struct {
// contains filtered or unexported fields
}
FunctionalGauge returns value from given function
func (FunctionalGauge) Snapshot ¶
func (g FunctionalGauge) Snapshot() Gauge
Snapshot returns the snapshot.
func (FunctionalGauge) Value ¶
func (g FunctionalGauge) Value() int64
Value returns the gauge's current value.
type FunctionalGaugeFloat64 ¶
type FunctionalGaugeFloat64 struct {
// contains filtered or unexported fields
}
FunctionalGaugeFloat64 returns value from given function
func (FunctionalGaugeFloat64) Snapshot ¶
func (g FunctionalGaugeFloat64) Snapshot() GaugeFloat64
Snapshot returns the snapshot.
func (FunctionalGaugeFloat64) Value ¶
func (g FunctionalGaugeFloat64) Value() float64
Value returns the gauge's current value.
type Gauge ¶
Gauges hold an int64 value that can be set arbitrarily.
func GetOrRegisterDiffer ¶
GetOrRegisterDiffer returns an existing Differ or constructs and registers a new StandardDiffer.
Example ¶
m := "server.memory_used" init := int64(1) g := GetOrRegisterDiffer(m, NewRegistry(), init) g.Update(47) fmt.Println(g.Value())
Output: 46
func GetOrRegisterDifferT ¶
GetOrRegisterDifferT returns an existing Differ or constructs and registers a new StandardDiffer.
func GetOrRegisterGauge ¶
GetOrRegisterGauge returns an existing Gauge or constructs and registers a new StandardGauge.
Example ¶
m := "server.bytes_sent" g := GetOrRegisterGauge(m, NewRegistry()) g.Update(47) fmt.Println(g.Value())
Output: 47
func GetOrRegisterGaugeT ¶
GetOrRegisterGaugeT returns an existing Gauge or constructs and registers a new StandardGauge.
func NewFunctionalGauge ¶
NewFunctionalGauge constructs a new FunctionalGauge.
func NewRegisteredDiffer ¶
NewRegisteredDiffer constructs and registers a new StandardDiffer.
func NewRegisteredDifferT ¶
NewRegisteredDifferT constructs and registers a new StandardDiffer.
func NewRegisteredFunctionalGauge ¶
NewRegisteredFunctionalGauge constructs and registers a new StandardGauge.
func NewRegisteredFunctionalGaugeT ¶
func NewRegisteredFunctionalGaugeT(name string, tagsMap map[string]string, r Registry, f func() int64) Gauge
NewRegisteredFunctionalGaugeT constructs and registers a new StandardGauge.
func NewRegisteredGauge ¶
NewRegisteredGauge constructs and registers a new StandardGauge.
type GaugeFloat64 ¶
type GaugeFloat64 interface { Snapshot() GaugeFloat64 Update(float64) Value() float64 }
GaugeFloat64s hold a float64 value that can be set arbitrarily.
func GetOrRegisterGaugeFloat64 ¶
func GetOrRegisterGaugeFloat64(name string, r Registry) GaugeFloat64
GetOrRegisterGaugeFloat64 returns an existing GaugeFloat64 or constructs and registers a new StandardGaugeFloat64.
func GetOrRegisterGaugeFloat64T ¶
func GetOrRegisterGaugeFloat64T(name string, tagsMap map[string]string, r Registry) GaugeFloat64
GetOrRegisterGaugeFloat64T returns an existing GaugeFloat64 or constructs and registers a new StandardGaugeFloat64.
func NewFunctionalGaugeFloat64 ¶
func NewFunctionalGaugeFloat64(f func() float64) GaugeFloat64
NewFunctionalGauge constructs a new FunctionalGauge.
func NewGaugeFloat64 ¶
func NewGaugeFloat64() GaugeFloat64
NewGaugeFloat64 constructs a new StandardGaugeFloat64.
func NewRegisteredFunctionalGaugeFloat64 ¶
func NewRegisteredFunctionalGaugeFloat64(name string, r Registry, f func() float64) GaugeFloat64
NewRegisteredFunctionalGauge constructs and registers a new StandardGauge.
func NewRegisteredFunctionalGaugeFloat64T ¶
func NewRegisteredFunctionalGaugeFloat64T(name string, tagsMap map[string]string, r Registry, f func() float64) GaugeFloat64
NewRegisteredFunctionalGaugeT constructs and registers a new StandardGauge.
func NewRegisteredGaugeFloat64 ¶
func NewRegisteredGaugeFloat64(name string, r Registry) GaugeFloat64
NewRegisteredGaugeFloat64 constructs and registers a new StandardGaugeFloat64.
func NewRegisteredGaugeFloat64T ¶
func NewRegisteredGaugeFloat64T(name string, tagsMap map[string]string, r Registry) GaugeFloat64
NewRegisteredGaugeFloat64T constructs and registers a new StandardGaugeFloat64.
type GaugeFloat64Snapshot ¶
type GaugeFloat64Snapshot float64
GaugeFloat64Snapshot is a read-only copy of another GaugeFloat64.
func (GaugeFloat64Snapshot) Snapshot ¶
func (g GaugeFloat64Snapshot) Snapshot() GaugeFloat64
Snapshot returns the snapshot.
func (GaugeFloat64Snapshot) Value ¶
func (g GaugeFloat64Snapshot) Value() float64
Value returns the value at the time the snapshot was taken.
type GaugeSnapshot ¶
type GaugeSnapshot int64
GaugeSnapshot is a read-only copy of another Gauge.
func (GaugeSnapshot) Snapshot ¶
func (g GaugeSnapshot) Snapshot() Gauge
Snapshot returns the snapshot.
func (GaugeSnapshot) Value ¶
func (g GaugeSnapshot) Value() int64
Value returns the value at the time the snapshot was taken.
type Healthcheck ¶
Healthchecks hold an error value describing an arbitrary up/down status.
func NewHealthcheck ¶
func NewHealthcheck(f func(bool) bool) Healthcheck
NewHealthcheck constructs a new Healthcheck which will use the given function to update its status.
type Histogram ¶
type Histogram interface { HistogramInterface SetLabels([]string) Histogram AddLabelPrefix(string) Histogram SetNameTotal(string) Histogram Snapshot() Histogram Clear() Add(v int64) Weights() []int64 }
A Histogram is a lossy data structure used to record the distribution of non-normally distributed data (like latency) with a high degree of accuracy and a bounded degree of precision.
func GetOrRegisterFixedHistogram ¶
GetOrRegisterHistoram returns an existing Histogram or constructs and registers a new FixedHistorgam.
func GetOrRegisterFixedHistogramT ¶
func GetOrRegisterFixedHistogramT(name string, tagsMap map[string]string, r Registry, startVal, endVal, width int64) Histogram
GetOrRegisterHistoramT returns an existing Histogram or constructs and registers a new FixedHistorgam.
func GetOrRegisterVHistogram ¶
func NewRegisteredFixedHistogram ¶
NewRegisteredFixedHistogram constructs and registers a new FixedHistogram.
func NewRegisteredFixedHistogramT ¶
func NewRegisteredFixedHistogramT(name string, tagsMap map[string]string, r Registry, startVal, endVal, width int64) Histogram
NewRegisteredFixedHistogramT constructs and registers a new FixedHistogram.
func NewRegisteredVHistogram ¶
NewRegisteredVHistogram constructs and registers a new VHistogram.
type HistogramInterface ¶
type HistogramInterface interface { Values() []uint64 Labels() []string NameTotal() string // Tag aliases values (for le key) WeightsAliases() []string }
A HistogramInterface is some strped (no Weights{}, it's not need in registry Each iterator) version of Histogram interface
type HistogramSnapshot ¶
type HistogramSnapshot struct {
// contains filtered or unexported fields
}
func (*HistogramSnapshot) Add ¶
func (h *HistogramSnapshot) Add(v int64)
func (HistogramSnapshot) AddLabelPrefix ¶
func (HistogramSnapshot) AddLabelPrefix(string) Histogram
func (*HistogramSnapshot) Clear ¶
func (h *HistogramSnapshot) Clear()
func (*HistogramSnapshot) Interface ¶
func (h *HistogramSnapshot) Interface() HistogramInterface
for static check compatbility with HistogramInterface
func (*HistogramSnapshot) Labels ¶
func (h *HistogramSnapshot) Labels() []string
func (*HistogramSnapshot) NameTotal ¶
func (h *HistogramSnapshot) NameTotal() string
func (HistogramSnapshot) SetLabels ¶
func (HistogramSnapshot) SetLabels([]string) Histogram
func (HistogramSnapshot) SetNameTotal ¶
func (HistogramSnapshot) SetNameTotal(string) Histogram
func (*HistogramSnapshot) Snapshot ¶
func (h *HistogramSnapshot) Snapshot() Histogram
func (*HistogramSnapshot) Values ¶
func (h *HistogramSnapshot) Values() []uint64
func (*HistogramSnapshot) Weights ¶
func (h *HistogramSnapshot) Weights() []int64
func (*HistogramSnapshot) WeightsAliases ¶
func (h *HistogramSnapshot) WeightsAliases() []string
type HistogramStorage ¶
type HistogramStorage struct {
// contains filtered or unexported fields
}
func (*HistogramStorage) AddLabelPrefix ¶
func (h *HistogramStorage) AddLabelPrefix(labelPrefix string)
func (*HistogramStorage) Clear ¶
func (h *HistogramStorage) Clear()
func (*HistogramStorage) Interface ¶
func (h *HistogramStorage) Interface() HistogramInterface
for static check compatbility with HistogramInterface
func (*HistogramStorage) Labels ¶
func (h *HistogramStorage) Labels() []string
func (*HistogramStorage) NameTotal ¶
func (h *HistogramStorage) NameTotal() string
func (*HistogramStorage) SetLabels ¶
func (h *HistogramStorage) SetLabels(labels []string)
func (*HistogramStorage) SetNameTotal ¶
func (h *HistogramStorage) SetNameTotal(total string)
func (*HistogramStorage) Snapshot ¶
func (h *HistogramStorage) Snapshot() Histogram
func (*HistogramStorage) Values ¶
func (h *HistogramStorage) Values() []uint64
func (*HistogramStorage) Weights ¶
func (h *HistogramStorage) Weights() []int64
func (*HistogramStorage) WeightsAliases ¶
func (h *HistogramStorage) WeightsAliases() []string
type NameTagged ¶
type NilDownCounter ¶
type NilDownCounter struct{}
NilDownCounter is a no-op DownCounter.
func (NilDownCounter) Dec ¶
func (NilDownCounter) Dec(i int64)
type NilGaugeFloat64 ¶
type NilGaugeFloat64 struct{}
NilGauge is a no-op Gauge.
func (NilGaugeFloat64) Snapshot ¶
func (NilGaugeFloat64) Snapshot() GaugeFloat64
Snapshot is a no-op.
type NilHealthcheck ¶
type NilHealthcheck struct{}
NilHealthcheck is a no-op.
func (NilHealthcheck) Status ¶
func (NilHealthcheck) Status() int32
type Rate ¶
type Rate interface { RateNames Snapshot() Rate Clear() (int64, float64) Update(v int64) UpdateTs(v int64, timestamp_ns int64) Values() (int64, float64) }
Rate hold an int64 value and timestamp (current and previous) and return diff and diff/s.
func GetOrRegisterRate ¶
GetOrRegisterRate returns an existing Rate or constructs and registers a new StandardRate.
Example ¶
m := "server.memory_used" r := NewRegistry() g := GetOrRegisterRate(m, r) g.UpdateTs(1, 1e9) g.UpdateTs(7, 3e9) fmt.Println(g.Values())
Output: 7 3
func GetOrRegisterRateT ¶
GetOrRegisterRateT returns an existing Rate or constructs and registers a new StandardRate.
func NewRegisteredRate ¶
NewRegisteredRate constructs and registers a new StandardRate.
type RateSnapshot ¶
type RateSnapshot struct {
// contains filtered or unexported fields
}
RateSnapshot is a read-only copy of another Rate.
func (*RateSnapshot) Name ¶
func (g *RateSnapshot) Name() string
func (*RateSnapshot) RateName ¶
func (g *RateSnapshot) RateName() string
func (RateSnapshot) SetName ¶
func (RateSnapshot) SetName(string) Rate
func (RateSnapshot) SetRateName ¶
func (RateSnapshot) SetRateName(string) Rate
func (*RateSnapshot) Snapshot ¶
func (g *RateSnapshot) Snapshot() Rate
Snapshot returns the snapshot.
func (*RateSnapshot) Values ¶
func (g *RateSnapshot) Values() (int64, float64)
Value returns the value at the time the snapshot was taken.
type Registry ¶
type Registry interface { // Call the given function for each registered metric. Each(f func(name string, tags string, tagsMap map[string]string, i interface{}) error, minLock bool) error // Get the metric by the given name or nil if none is registered. Get(name string) interface{} // Get the metric by the given name or nil if none is registered. GetT(name string, tagsMap map[string]string) interface{} // Get 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(name string, i interface{}) interface{} // Get get 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. GetOrRegisterT(name string, tagsMap map[string]string, i interface{}) interface{} // Register the given metric under the given name. Register(name string, i interface{}) error // Register the given metric under the given name. RegisterT(name string, tagsMap map[string]string, i interface{}) error // Run all registered healthchecks. RunHealthchecks() // Unregister the metric with the given name. Unregister(name string) // Unregister the metric with the given name. UnregisterT(name string, tagsMap map[string]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()
type StandardCounter ¶
type StandardCounter struct {
// contains filtered or unexported fields
}
StandardCounter is the standard implementation of a Counter and uses the sync/atomic package to manage a single uint64 value.
func (*StandardCounter) Clear ¶
func (c *StandardCounter) Clear() uint64
Clear sets the Counter to zero.
func (*StandardCounter) Count ¶
func (c *StandardCounter) Count() uint64
Count returns the current count.
func (*StandardCounter) Inc ¶
func (c *StandardCounter) Inc(i uint64)
Inc increments the Counter by the given amount.
func (*StandardCounter) Snapshot ¶
func (c *StandardCounter) Snapshot() Counter
Snapshot returns a read-only copy of the Counter.
type StandardDiffer ¶
type StandardDiffer struct {
// contains filtered or unexported fields
}
StandardDiffer is the standard implementation of a Differ and uses the sync/atomic package to manage a single int64 value.
func (*StandardDiffer) Clear ¶
func (g *StandardDiffer) Clear() int64
Clear sets the DownCounter to zero.
func (*StandardDiffer) Snapshot ¶
func (g *StandardDiffer) Snapshot() Gauge
Snapshot returns a read-only copy of the Differ.
func (*StandardDiffer) Update ¶
func (g *StandardDiffer) Update(v int64)
Update updates the Differ's value.
func (*StandardDiffer) Value ¶
func (g *StandardDiffer) Value() int64
Value returns the Differ's current value.
type StandardDownCounter ¶
type StandardDownCounter struct {
// contains filtered or unexported fields
}
StandardDownCounter is the standard implementation of a DownCounter and uses the sync/atomic package to manage a single uint64 value.
func (*StandardDownCounter) Clear ¶
func (c *StandardDownCounter) Clear() int64
Clear sets the DownCounter to zero.
func (*StandardDownCounter) Count ¶
func (c *StandardDownCounter) Count() int64
Count returns the current count.
func (*StandardDownCounter) Dec ¶
func (c *StandardDownCounter) Dec(i int64)
Dec decrements the DownCounter by the given amount.
func (*StandardDownCounter) Inc ¶
func (c *StandardDownCounter) Inc(i int64)
Inc increments the DownCounter by the given amount.
func (*StandardDownCounter) Snapshot ¶
func (c *StandardDownCounter) Snapshot() DownCounter
Snapshot returns a read-only copy of the DownCounter.
type StandardFRate ¶
type StandardFRate struct {
// contains filtered or unexported fields
}
StandardFRate is the standard implementation of a FRate and uses the sync/atomic package to manage a single int64 value.
func (*StandardFRate) Clear ¶
func (g *StandardFRate) Clear() (float64, float64)
Clear sets the DownCounter to zero.
func (*StandardFRate) Name ¶
func (g *StandardFRate) Name() string
func (*StandardFRate) RateName ¶
func (g *StandardFRate) RateName() string
func (*StandardFRate) SetName ¶
func (g *StandardFRate) SetName(name string) FRate
func (*StandardFRate) SetRateName ¶
func (g *StandardFRate) SetRateName(rateName string) FRate
func (*StandardFRate) Snapshot ¶
func (g *StandardFRate) Snapshot() FRate
Snapshot returns a read-only copy of the FRate.
func (*StandardFRate) Update ¶
func (g *StandardFRate) Update(v float64)
Update updates the FRate's value.
func (*StandardFRate) UpdateTs ¶
func (g *StandardFRate) UpdateTs(v float64, ts int64)
UpdateTs updates the FRate's value.
func (*StandardFRate) Values ¶
func (g *StandardFRate) Values() (float64, float64)
Value returns the FRate's current value.
type StandardGauge ¶
type StandardGauge struct {
// contains filtered or unexported fields
}
StandardGauge is the standard implementation of a Gauge and uses the sync/atomic package to manage a single int64 value.
func (*StandardGauge) Clear ¶
func (g *StandardGauge) Clear() int64
Clear sets the DownCounter to zero.
func (*StandardGauge) Snapshot ¶
func (g *StandardGauge) Snapshot() Gauge
Snapshot returns a read-only copy of the gauge.
func (*StandardGauge) Update ¶
func (g *StandardGauge) Update(v int64)
Update updates the gauge's value.
func (*StandardGauge) Value ¶
func (g *StandardGauge) Value() int64
Value returns the gauge's current value.
type StandardGaugeFloat64 ¶
type StandardGaugeFloat64 struct {
// contains filtered or unexported fields
}
StandardGaugeFloat64 is the standard implementation of a GaugeFloat64 and uses sync.Mutex to manage a single float64 value.
func (*StandardGaugeFloat64) Snapshot ¶
func (g *StandardGaugeFloat64) Snapshot() GaugeFloat64
Snapshot returns a read-only copy of the gauge.
func (*StandardGaugeFloat64) Update ¶
func (g *StandardGaugeFloat64) Update(v float64)
Update updates the gauge's value.
func (*StandardGaugeFloat64) Value ¶
func (g *StandardGaugeFloat64) Value() float64
Value returns the gauge's current value.
type StandardHealthcheck ¶
type StandardHealthcheck struct {
// contains filtered or unexported fields
}
StandardHealthcheck is the standard implementation of a Healthcheck and stores the status and a function to call to update the status.
func (*StandardHealthcheck) Check ¶
func (h *StandardHealthcheck) Check() int32
Check runs the healthcheck function to update the healthcheck's status.
func (*StandardHealthcheck) Healthy ¶
func (h *StandardHealthcheck) Healthy()
Healthy marks the healthcheck as healthy.
func (*StandardHealthcheck) IsUp ¶
func (h *StandardHealthcheck) IsUp() bool
IsUp returns the healthcheck's status
func (*StandardHealthcheck) Status ¶
func (h *StandardHealthcheck) Status() int32
Status returns the healthcheck's internal status value
func (*StandardHealthcheck) Unhealthy ¶
func (h *StandardHealthcheck) Unhealthy()
Unhealthy marks the healthcheck as unhealthy.
type StandardRate ¶
type StandardRate struct {
// contains filtered or unexported fields
}
StandardRate is the standard implementation of a Rate and uses the sync/atomic package to manage a single int64 value.
func (*StandardRate) Clear ¶
func (g *StandardRate) Clear() (int64, float64)
Clear sets the DownCounter to zero.
func (*StandardRate) Name ¶
func (g *StandardRate) Name() string
func (*StandardRate) RateName ¶
func (g *StandardRate) RateName() string
func (*StandardRate) SetName ¶
func (g *StandardRate) SetName(name string) Rate
func (*StandardRate) SetRateName ¶
func (g *StandardRate) SetRateName(rateName string) Rate
func (*StandardRate) Snapshot ¶
func (g *StandardRate) Snapshot() Rate
Snapshot returns a read-only copy of the Rate.
func (*StandardRate) Update ¶
func (g *StandardRate) Update(v int64)
Update updates the Rate's value.
func (*StandardRate) UpdateTs ¶
func (g *StandardRate) UpdateTs(v int64, ts int64)
UpdateTs updates the Rate's value.
func (*StandardRate) Values ¶
func (g *StandardRate) Values() (int64, float64)
Value returns the Rate's current value.
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) 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{}
Get 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) GetOrRegisterT ¶
func (r *StandardRegistry) GetOrRegisterT(name string, tagsMap map[string]string, i interface{}) interface{}
Get 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) GetT ¶
func (r *StandardRegistry) GetT(name string, tagsMap map[string]string) interface{}
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) RegisterT ¶
func (r *StandardRegistry) RegisterT(name string, tagsMap map[string]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.)
func (*StandardRegistry) UnregisterT ¶
func (r *StandardRegistry) UnregisterT(name string, tagsMap map[string]string)
Unregister the metric with the given name.
type UFixedHistogram ¶
type UFixedHistogram struct { UHistogramStorage // contains filtered or unexported fields }
A UFixedHistogram is implementation of UHistogram with fixed-size buckets.
func NewUFixedHistogram ¶
func NewUFixedHistogram(startVal, endVal, width uint64) *UFixedHistogram
func (*UFixedHistogram) Add ¶
func (h *UFixedHistogram) Add(v uint64)
func (*UFixedHistogram) AddLabelPrefix ¶
func (h *UFixedHistogram) AddLabelPrefix(labelPrefix string) UHistogram
func (*UFixedHistogram) SetLabels ¶
func (h *UFixedHistogram) SetLabels(labels []string) UHistogram
func (*UFixedHistogram) SetNameTotal ¶
func (h *UFixedHistogram) SetNameTotal(total string) UHistogram
type UHistogram ¶
type UHistogram interface { HistogramInterface SetLabels([]string) UHistogram AddLabelPrefix(string) UHistogram SetNameTotal(string) UHistogram Snapshot() UHistogram Clear() Add(v uint64) Weights() []uint64 }
A UHistogram is a lossy data structure used to record the distribution of non-normally distributed data (like latency) with a high degree of accuracy and a bounded degree of precision.
func GetOrRegisterUFixedHistogram ¶
func GetOrRegisterUFixedHistogram(name string, r Registry, startVal, endVal, width uint64) UHistogram
GetOrRegisterHistoram returns an existing Histogram or constructs and registers a new FixedHistorgam.
func GetOrRegisterUFixedHistogramT ¶
func GetOrRegisterUFixedHistogramT(name string, tagsMap map[string]string, r Registry, startVal, endVal, width uint64) UHistogram
GetOrRegisterHistoramT returns an existing Histogram or constructs and registers a new FixedHistorgam.
func GetOrRegisterUVHistogram ¶
func GetOrRegisterUVHistogram(name string, r Registry, weights []uint64, names []string) UHistogram
func NewRegisteredUFixedHistogram ¶
func NewRegisteredUFixedHistogram(name string, r Registry, startVal, endVal, width uint64) UHistogram
NewRegisteredFixedHistogram constructs and registers a new FixedHistogram.
func NewRegisteredUFixedHistogramT ¶
func NewRegisteredUFixedHistogramT(name string, tagsMap map[string]string, r Registry, startVal, endVal, width uint64) UHistogram
NewRegisteredFixedHistogramT constructs and registers a new FixedHistogram.
func NewRegisteredUVHistogram ¶
func NewRegisteredUVHistogram(name string, r Registry, weights []uint64, names []string) UHistogram
NewRegisteredVHistogram constructs and registers a new VHistogram.
func NewRegisteredUVHistogramT ¶
func NewRegisteredUVHistogramT(name string, tagsMap map[string]string, r Registry, weights []uint64, names []string) UHistogram
NewRegisteredVHistogramT constructs and registers a new VHistogram.
type UHistogramSnapshot ¶
type UHistogramSnapshot struct {
// contains filtered or unexported fields
}
func (*UHistogramSnapshot) Add ¶
func (h *UHistogramSnapshot) Add(v uint64)
func (UHistogramSnapshot) AddLabelPrefix ¶
func (UHistogramSnapshot) AddLabelPrefix(string) UHistogram
func (*UHistogramSnapshot) Clear ¶
func (h *UHistogramSnapshot) Clear()
func (*UHistogramSnapshot) Interface ¶
func (h *UHistogramSnapshot) Interface() HistogramInterface
for static check compatbility with HistogramInterface
func (*UHistogramSnapshot) Labels ¶
func (h *UHistogramSnapshot) Labels() []string
func (*UHistogramSnapshot) NameTotal ¶
func (h *UHistogramSnapshot) NameTotal() string
func (UHistogramSnapshot) SetLabels ¶
func (UHistogramSnapshot) SetLabels([]string) UHistogram
func (UHistogramSnapshot) SetNameTotal ¶
func (UHistogramSnapshot) SetNameTotal(string) UHistogram
func (*UHistogramSnapshot) Snapshot ¶
func (h *UHistogramSnapshot) Snapshot() UHistogram
func (*UHistogramSnapshot) Values ¶
func (h *UHistogramSnapshot) Values() []uint64
func (*UHistogramSnapshot) Weights ¶
func (h *UHistogramSnapshot) Weights() []uint64
func (*UHistogramSnapshot) WeightsAliases ¶
func (h *UHistogramSnapshot) WeightsAliases() []string
type UHistogramStorage ¶
type UHistogramStorage struct {
// contains filtered or unexported fields
}
func (*UHistogramStorage) AddLabelPrefix ¶
func (h *UHistogramStorage) AddLabelPrefix(labelPrefix string)
func (*UHistogramStorage) Clear ¶
func (h *UHistogramStorage) Clear()
func (*UHistogramStorage) Interface ¶
func (h *UHistogramStorage) Interface() HistogramInterface
for static check compatbility with HistogramInterface
func (*UHistogramStorage) Labels ¶
func (h *UHistogramStorage) Labels() []string
func (*UHistogramStorage) NameTotal ¶
func (h *UHistogramStorage) NameTotal() string
func (*UHistogramStorage) SetLabels ¶
func (h *UHistogramStorage) SetLabels(labels []string)
func (*UHistogramStorage) SetNameTotal ¶
func (h *UHistogramStorage) SetNameTotal(total string)
func (*UHistogramStorage) Snapshot ¶
func (h *UHistogramStorage) Snapshot() UHistogram
func (*UHistogramStorage) Values ¶
func (h *UHistogramStorage) Values() []uint64
func (*UHistogramStorage) Weights ¶
func (h *UHistogramStorage) Weights() []uint64
func (*UHistogramStorage) WeightsAliases ¶
func (h *UHistogramStorage) WeightsAliases() []string
type UVHistogram ¶
type UVHistogram struct {
UHistogramStorage
}
A UVHistogram is implementation of UHistogram with varibale-size buckets.
func NewUVHistogram ¶
func NewUVHistogram(weights []uint64, names []string) *UVHistogram
func (*UVHistogram) Add ¶
func (h *UVHistogram) Add(v uint64)
func (*UVHistogram) AddLabelPrefix ¶
func (h *UVHistogram) AddLabelPrefix(labelPrefix string) UHistogram
func (*UVHistogram) Clear ¶
func (h *UVHistogram) Clear()
func (*UVHistogram) SetLabels ¶
func (h *UVHistogram) SetLabels(labels []string) UHistogram
func (*UVHistogram) SetNameTotal ¶
func (h *UVHistogram) SetNameTotal(total string) UHistogram
func (*UVHistogram) Snapshot ¶
func (h *UVHistogram) Snapshot() UHistogram
func (*UVHistogram) Values ¶
func (h *UVHistogram) Values() []uint64
type Updated ¶
type Updated interface {
Update()
}
Updated defines the metrics which need to be async updated with Tick.
type VHistogram ¶
type VHistogram struct {
HistogramStorage
}
A VHistogram is implementation of Histogram with varibale-size buckets.
func NewVHistogram ¶
func NewVHistogram(weights []int64, names []string) *VHistogram
func (*VHistogram) Add ¶
func (h *VHistogram) Add(v int64)
func (*VHistogram) AddLabelPrefix ¶
func (h *VHistogram) AddLabelPrefix(labelPrefix string) Histogram
func (*VHistogram) Clear ¶
func (h *VHistogram) Clear()
func (*VHistogram) Interface ¶
func (h *VHistogram) Interface() HistogramInterface
for static check compatbility with HistogramInterface
func (*VHistogram) SetLabels ¶
func (h *VHistogram) SetLabels(labels []string) Histogram
func (*VHistogram) SetNameTotal ¶
func (h *VHistogram) SetNameTotal(total string) Histogram
func (*VHistogram) Snapshot ¶
func (h *VHistogram) Snapshot() Histogram
func (*VHistogram) Values ¶
func (h *VHistogram) Values() []uint64
func (*VHistogram) WeightsAliases ¶
func (h *VHistogram) WeightsAliases() []string
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 |