metrics

package module
v0.0.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2022 License: MIT Imports: 12 Imported by: 3

README

go-metrics

Golang metrics library: Initialyy based on https://github.com/rcrowley/go-metrics Main changes:

  1. Reduce alocations for better perfomance
  2. Read-lock during Registry.Each iterator (for avoid copy registry storage)
  3. Don't append ".value" postfix and Gauge and GaugeFloat64
  4. Modified graphite client
  5. Simplify metrics types

Documentation: http://godoc.org/github.com/msaf1980/go-metrics.

Usage

Create and update metrics:

c := metrics.NewCounter()
metrics.Register("foo", c)
c.Inc(47)

g := metrics.NewGauge()
metrics.Register("bar", g)
g.Update(47)

r := metrics.NewRegistry()
g := metrics.NewRegisteredFunctionalGauge("cache-evictions", r, func() int64 { return cache.getEvictionsCount() })

fixedH := metrics.NewUFixedHistogram(1, 3, 1, "req_", "")
if err := r.Register("fixed_histogram", fixedH); err != nil {
    ...
}
fixedH.Add(2)

h := metrics.NewVHistogram([]int64{1, 2, 5, 8, 20}, nil, "", "")
if err := r.Register("histogram", h); err != nil {
    ...
}
h.Add(2)

Register() return error is metric with this name exists. For error-less metric registration use GetOrRegister: Functions NewRegistered not thread-safe and can't return unregistered metric (if name duplicated)

t := metrics.GetOrRegisterVHistogram("account.create.latency", r, []int64{1, 2, 5, 8, 20}, nil, "", "")
t.Time(func() {})
t.Update(47)

NOTE: Be sure to unregister short-lived meters and timers otherwise they will leak memory:

// Will call Stop() on the Meter to allow for garbage collection
metrics.Unregister("quux")
// Or similarly for a Timer that embeds a Meter
metrics.Unregister("bang")

Periodically log every metric in human-readable form to standard error:

go metrics.Log(metrics.DefaultRegistry, 5 * time.Second, log.New(os.Stderr, "metrics: ", log.Lmicroseconds))

Periodically log every metric in slightly-more-parseable form to syslog:

w, _ := syslog.Dial("unixgram", "/dev/log", syslog.LOG_INFO, "metrics")
go metrics.Syslog(metrics.DefaultRegistry, 60e9, w)

Periodically emit every metric to Graphite using the Graphite client:


import "github.com/msaf1980/go-metrics/graphite"

go graphite.Graphite(metrics.DefaultRegistry, 10e9, "metrics", "127.0.0.1:2003")

Maintain all metrics along with expvars at /debug/metrics:

This uses the same mechanism as the official expvar but exposed under /debug/metrics, which shows a json representation of all your usual expvars as well as all your go-metrics.

import "github.com/msaf1980/go-metrics/exp"

exp.Exp(metrics.DefaultRegistry)

Installation

go get github.com/msaf1980/go-metrics

Publishing Metrics

Clients are available for the following destinations:

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.Add(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

Examples

Constants

This section is empty.

Variables

View Source
var ErrUnsortedWeights = errors.New("unsorted weights")
View Source
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
	}
)
View Source
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

func CaptureRuntimeMemStats(d time.Duration)

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

func GetOrRegisterT(name string, tagsMap map[string]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 GetT

func GetT(name string, tagsMap map[string]string) interface{}

Get the metric by the given name or nil if none is registered.

func IsSortedSliceFloat64Le added in v0.0.14

func IsSortedSliceFloat64Le(a []float64) (sorted bool)

func IsSortedSliceInt64Ge added in v0.0.12

func IsSortedSliceInt64Ge(a []int64) (sorted bool)

func IsSortedSliceUint64Le added in v0.0.14

func IsSortedSliceUint64Le(a []uint64) (sorted bool)

func JoinTags

func JoinTags(tagsMap map[string]string) string

JoinTags convert tags map sorted tags string representation (separated by comma), like tags or Graphite

func Max

func Max(a, b int) int

func MergeTags

func MergeTags(a, b map[string]string) map[string]string

MergeTags merge two tag maps into one tag map

func Min

func Min(a, b int) int

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

func MustRegisterT(name string, tagsMap map[string]string, i interface{})

Register the given metric under the given name. Panics if a metric by the given name is already registered.

func Register

func 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 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

func 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 RunHealthchecks

func RunHealthchecks()

Run all registered healthchecks.

func SearchFloat64Le added in v0.0.14

func SearchFloat64Le(a []float64, v float64) int

func SearchInt64Le added in v0.0.14

func SearchInt64Le(a []int64, v int64) int

func SearchUint64Le added in v0.0.14

func SearchUint64Le(a []uint64, v uint64) int

func Unregister

func Unregister(name string)

Unregister the metric with the given name.

func UnregisterT

func UnregisterT(name string, tagsMap map[string]string)

Unregister the metric with the given name.

Types

type Counter

type Counter interface {
	Clear() uint64
	Count() uint64
	Add(uint64)
	Snapshot() Counter
}

Counters hold an uint64 value that can be incremented only

Graphite naming scheme

Plain: {PREFIX}.{NAME}

Tagged: {TAG_PREFIX}.{NAME}

func GetOrRegisterCounter

func GetOrRegisterCounter(name string, r Registry) Counter

GetOrRegisterCounter returns an existing Counter or constructs and registers a new StandardCounter.

func GetOrRegisterCounterT

func GetOrRegisterCounterT(name string, tagsMap map[string]string, r Registry) Counter

GetOrRegisterCounterT returns an existing Counter or constructs and registers a new StandardCounter.

func NewCounter

func NewCounter() Counter

NewCounter constructs a new StandardCounter.

func NewRegisteredCounter

func NewRegisteredCounter(name string, r Registry) Counter

NewRegisteredCounter constructs and registers a new StandardCounter.

func NewRegisteredCounterT

func NewRegisteredCounterT(name string, tagsMap map[string]string, r Registry) Counter

NewRegisteredCounterT constructs and registers a new StandardCounter.

type CounterSnapshot

type CounterSnapshot uint64

CounterSnapshot is a read-only copy of another Counter.

func (CounterSnapshot) Add added in v0.0.11

func (CounterSnapshot) Add(uint64)

Inc panics.

func (CounterSnapshot) Clear

func (CounterSnapshot) Clear() uint64

Clear panics.

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
	Add(int64)
	Sub(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) Add added in v0.0.11

Inc panics.

func (DownCounterSnapshot) Clear

func (DownCounterSnapshot) Clear() int64

Clear panics.

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.

func (DownCounterSnapshot) Sub added in v0.0.11

Inc panics.

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 FGauge added in v0.0.7

type FGauge interface {
	Snapshot() FGauge
	Update(float64)
	Value() float64
}

FGauges hold a float64 value that can be set arbitrarily.

Plain: {PREFIX}.{NAME}

Tagged: {TAG_PREFIX}.{NAME}

func GetOrRegisterFGauge added in v0.0.7

func GetOrRegisterFGauge(name string, r Registry) FGauge

GetOrRegisterFGauge returns an existing FGauge or constructs and registers a new StandardFGauge.

func GetOrRegisterFGaugeT added in v0.0.7

func GetOrRegisterFGaugeT(name string, tagsMap map[string]string, r Registry) FGauge

GetOrRegisterFGaugeT returns an existing FGauge or constructs and registers a new StandardFGauge.

func NewFGauge added in v0.0.7

func NewFGauge() FGauge

NewFGauge constructs a new StandardFGauge.

func NewFunctionalFGauge added in v0.0.7

func NewFunctionalFGauge(f func() float64) FGauge

NewFunctionalGauge constructs a new FunctionalGauge.

func NewRegisteredFGauge added in v0.0.7

func NewRegisteredFGauge(name string, r Registry) FGauge

NewRegisteredFGauge constructs and registers a new StandardFGauge.

func NewRegisteredFGaugeT added in v0.0.7

func NewRegisteredFGaugeT(name string, tagsMap map[string]string, r Registry) FGauge

NewRegisteredFGaugeT constructs and registers a new StandardFGauge.

func NewRegisteredFunctionalFGauge added in v0.0.7

func NewRegisteredFunctionalFGauge(name string, r Registry, f func() float64) FGauge

NewRegisteredFunctionalGauge constructs and registers a new StandardGauge.

func NewRegisteredFunctionalFGaugeT added in v0.0.7

func NewRegisteredFunctionalFGaugeT(name string, tagsMap map[string]string, r Registry, f func() float64) FGauge

NewRegisteredFunctionalGaugeT constructs and registers a new StandardGauge.

type FGaugeSnapshot added in v0.0.7

type FGaugeSnapshot float64

FGaugeSnapshot is a read-only copy of another FGauge.

func (FGaugeSnapshot) Snapshot added in v0.0.7

func (g FGaugeSnapshot) Snapshot() FGauge

Snapshot returns the snapshot.

func (FGaugeSnapshot) Update added in v0.0.7

func (FGaugeSnapshot) Update(float64)

Update panics.

func (FGaugeSnapshot) Value added in v0.0.7

func (g FGaugeSnapshot) Value() float64

Value returns the value at the time the snapshot was taken.

type FHistogram

type FHistogram interface {
	HistogramInterface
	SetLabels([]string) FHistogram
	AddLabelPrefix(string) FHistogram
	SetNameTotal(string) FHistogram
	Snapshot() FHistogram
	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 GetOrRegisterFUHistogram added in v0.0.12

func GetOrRegisterFUHistogram(name string, r Registry, weights []float64, names []string) FHistogram

func GetOrRegisterFUHistogramT added in v0.0.12

func GetOrRegisterFUHistogramT(name string, tagsMap map[string]string, r Registry, weights []float64, names []string) FHistogram

func GetOrRegisterFixedFHistogram added in v0.0.12

func GetOrRegisterFixedFHistogram(name string, r Registry, startVal, endVal, width float64) FHistogram

GetOrRegisterFHistogram returns an existing FHistogram or constructs and registers a new FFixedHistorgam.

func GetOrRegisterFixedFHistogramT added in v0.0.12

func GetOrRegisterFixedFHistogramT(name string, tagsMap map[string]string, r Registry, startVal, endVal, width float64) FHistogram

GetOrRegisterHistogramT returns an existing Histogram or constructs and registers a new FixedHistorgam.

func GetOrRegisterFixedSumFHistogram added in v0.0.10

func GetOrRegisterFixedSumFHistogram(name string, r Registry, startVal, endVal, width float64) FHistogram

GetOrRegisterFHistogram returns an existing FHistogram or constructs and registers a new FixedHistorgam (prometheus-like histogram).

func GetOrRegisterFixedSumFHistogramT added in v0.0.10

func GetOrRegisterFixedSumFHistogramT(name string, tagsMap map[string]string, r Registry, startVal, endVal, width float64) FHistogram

GetOrRegisterSumFHistogramT returns an existing FHistogram or constructs and registers a new FixedHistorgam (prometheus-like histogram).

func GetOrRegisterVSumFHistogram added in v0.0.10

func GetOrRegisterVSumFHistogram(name string, r Registry, weights []float64, names []string) FHistogram

func GetOrRegisterVSumFHistogramT added in v0.0.10

func GetOrRegisterVSumFHistogramT(name string, tagsMap map[string]string, r Registry, weights []float64, names []string) FHistogram

func NewFUHistogram added in v0.0.12

func NewFUHistogram(weights []float64, names []string) FHistogram

func NewFixedFHistogram added in v0.0.12

func NewFixedFHistogram(startVal, endVal, width float64) FHistogram

func NewRegisteredFUHistogram added in v0.0.12

func NewRegisteredFUHistogram(name string, r Registry, weights []float64, names []string) FHistogram

NewRegisteredVHistogram constructs and registers a new VHistogram.

func NewRegisteredFUHistogramT added in v0.0.12

func NewRegisteredFUHistogramT(name string, tagsMap map[string]string, r Registry, weights []float64, names []string) FHistogram

NewRegisteredVHistogramT constructs and registers a new VHistogram.

func NewRegisteredFixedFHistogram added in v0.0.12

func NewRegisteredFixedFHistogram(name string, r Registry, startVal, endVal, width float64) FHistogram

NewRegisteredFixedHistogram constructs and registers a new FixedHistogram.

func NewRegisteredFixedFHistogramT added in v0.0.12

func NewRegisteredFixedFHistogramT(name string, tagsMap map[string]string, r Registry, startVal, endVal, width float64) FHistogram

NewRegisteredFixedHistogramT constructs and registers a new FixedHistogram.

func NewRegisteredFixedSumFHistogram added in v0.0.10

func NewRegisteredFixedSumFHistogram(name string, r Registry, startVal, endVal, width float64) FHistogram

NewRegisteredFixedSumFHistogram constructs and registers a new FixedSumFHistogram (prometheus-like histogram).

func NewRegisteredFixedSumFHistogramT added in v0.0.10

func NewRegisteredFixedSumFHistogramT(name string, tagsMap map[string]string, r Registry, startVal, endVal, width float64) FHistogram

NewRegisteredFixedSumFHistogramT constructs and registers a new FixedSumFHistogram (prometheus-like histogram).

func NewRegisteredVSumFHistogram added in v0.0.10

func NewRegisteredVSumFHistogram(name string, r Registry, weights []float64, names []string) FHistogram

NewRegisteredVSumFHistogram constructs and registers a new VSumFHistogram (prometheus-like histogram).

func NewRegisteredVSumFHistogramT added in v0.0.10

func NewRegisteredVSumFHistogramT(name string, tagsMap map[string]string, r Registry, weights []float64, names []string) FHistogram

NewRegisteredVSumFHistogramT constructs and registers a new VSumFHistogram (prometheus-like histogram).

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() []uint64

func (*FHistogramSnapshot) Interface

func (h *FHistogramSnapshot) Interface() HistogramInterface

for static check compatbility with HistogramInterface

func (*FHistogramSnapshot) IsSummed added in v0.0.4

func (h *FHistogramSnapshot) IsSummed() bool

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() []uint64

func (*FHistogramStorage) Interface

func (h *FHistogramStorage) Interface() HistogramInterface

for static check compatbility with HistogramInterface

func (*FHistogramStorage) IsSummed added in v0.0.4

func (h *FHistogramStorage) IsSummed() bool

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

func GetOrRegisterFRate(name string, r Registry) FRate

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

func GetOrRegisterFRateT(name string, tagsMap map[string]string, r Registry) FRate

GetOrRegisterFRateT returns an existing FRate or constructs and registers a new StandardFRate.

func NewFRate

func NewFRate() FRate

NewFRate constructs a new StandardFRate.

func NewRegisteredFRate

func NewRegisteredFRate(name string, r Registry) FRate

NewRegisteredFRate constructs and registers a new StandardFRate.

func NewRegisteredFRateT

func NewRegisteredFRateT(name string, tagsMap map[string]string, r Registry) FRate

NewRegisteredFRateT constructs and registers a new StandardFRate.

type FRateNames

type FRateNames interface {
	SetName(string) FRate
	Name() string
	SetRateName(string) FRate
	RateName() string
}

type FRateSnapshot

type FRateSnapshot struct {
	FRate float64
	// contains filtered or unexported fields
}

FRateSnapshot is a read-only copy of another FRate.

func (FRateSnapshot) Clear

func (FRateSnapshot) Clear() (float64, float64)

Clear panics.

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) Update

func (FRateSnapshot) Update(float64)

Update panics.

func (FRateSnapshot) UpdateTs

func (FRateSnapshot) UpdateTs(float64, int64)

Update panics.

func (*FRateSnapshot) Values

func (g *FRateSnapshot) Values() (float64, float64)

Value returns the value at the time the snapshot was taken.

type FUHistogram added in v0.0.12

type FUHistogram struct {
	FHistogramStorage
}

A FUHistogram is implementation of FHistogram with varibale-size buckets.

func (*FUHistogram) Add added in v0.0.12

func (h *FUHistogram) Add(v float64)

func (*FUHistogram) AddLabelPrefix added in v0.0.12

func (h *FUHistogram) AddLabelPrefix(labelPrefix string) FHistogram

func (*FUHistogram) SetLabels added in v0.0.12

func (h *FUHistogram) SetLabels(labels []string) FHistogram

func (*FUHistogram) SetNameTotal added in v0.0.12

func (h *FUHistogram) SetNameTotal(total string) FHistogram

func (*FUHistogram) Snapshot added in v0.0.12

func (h *FUHistogram) Snapshot() FHistogram

func (*FUHistogram) Values added in v0.0.12

func (h *FUHistogram) Values() []uint64

type FixedFHistogram added in v0.0.12

type FixedFHistogram struct {
	FHistogramStorage
	// contains filtered or unexported fields
}

A FixedFHistogram is implementation of FHistogram with fixed-size buckets.

func (*FixedFHistogram) Add added in v0.0.12

func (h *FixedFHistogram) Add(v float64)

func (*FixedFHistogram) AddLabelPrefix added in v0.0.12

func (h *FixedFHistogram) AddLabelPrefix(labelPrefix string) FHistogram

func (*FixedFHistogram) SetLabels added in v0.0.12

func (h *FixedFHistogram) SetLabels(labels []string) FHistogram

func (*FixedFHistogram) SetNameTotal added in v0.0.12

func (h *FixedFHistogram) SetNameTotal(total string) FHistogram

type FixedHistogram

type FixedHistogram struct {
	HistogramStorage
	// contains filtered or unexported fields
}

A FixedHistogram is implementation of Histogram with fixed-size buckets.

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 FixedSumFHistogram added in v0.0.10

type FixedSumFHistogram struct {
	FHistogramStorage
	// contains filtered or unexported fields
}

A FixedSumFHistogram is implementation of prometheus-like FHistogram with fixed-size buckets.

func NewFixedSumFHistogram added in v0.0.10

func NewFixedSumFHistogram(startVal, endVal, width float64) *FixedSumFHistogram

func (*FixedSumFHistogram) Add added in v0.0.10

func (h *FixedSumFHistogram) Add(v float64)

func (*FixedSumFHistogram) AddLabelPrefix added in v0.0.10

func (h *FixedSumFHistogram) AddLabelPrefix(labelPrefix string) FHistogram

func (*FixedSumFHistogram) Clear added in v0.0.10

func (h *FixedSumFHistogram) Clear() []uint64

func (*FixedSumFHistogram) IsSummed added in v0.0.10

func (h *FixedSumFHistogram) IsSummed() bool

func (*FixedSumFHistogram) SetLabels added in v0.0.10

func (h *FixedSumFHistogram) SetLabels(labels []string) FHistogram

func (*FixedSumFHistogram) SetNameTotal added in v0.0.10

func (h *FixedSumFHistogram) SetNameTotal(total string) FHistogram

type FixedSumHistogram added in v0.0.4

type FixedSumHistogram struct {
	HistogramStorage
	// contains filtered or unexported fields
}

A FixedSumHistogram is implementation of prometheus-like Histogram with fixed-size buckets.

func NewFixedSumHistogram added in v0.0.4

func NewFixedSumHistogram(startVal, endVal, width int64) *FixedSumHistogram

func (*FixedSumHistogram) Add added in v0.0.4

func (h *FixedSumHistogram) Add(v int64)

func (*FixedSumHistogram) AddLabelPrefix added in v0.0.4

func (h *FixedSumHistogram) AddLabelPrefix(labelPrefix string) Histogram

func (*FixedSumHistogram) Clear added in v0.0.4

func (h *FixedSumHistogram) Clear() []uint64

func (*FixedSumHistogram) IsSummed added in v0.0.4

func (h *FixedSumHistogram) IsSummed() bool

func (*FixedSumHistogram) SetLabels added in v0.0.4

func (h *FixedSumHistogram) SetLabels(labels []string) Histogram

func (*FixedSumHistogram) SetNameTotal added in v0.0.4

func (h *FixedSumHistogram) SetNameTotal(total string) Histogram

type FixedSumUHistogram added in v0.0.8

type FixedSumUHistogram struct {
	UHistogramStorage
	// contains filtered or unexported fields
}

A FixedSumUHistogram is implementation of prometheus-like UHistogram with fixed-size buckets.

func NewFixedSumUHistogram added in v0.0.8

func NewFixedSumUHistogram(startVal, endVal, width uint64) *FixedSumUHistogram

func (*FixedSumUHistogram) Add added in v0.0.8

func (h *FixedSumUHistogram) Add(v uint64)

func (*FixedSumUHistogram) AddLabelPrefix added in v0.0.8

func (h *FixedSumUHistogram) AddLabelPrefix(labelPrefix string) UHistogram

func (*FixedSumUHistogram) Clear added in v0.0.8

func (h *FixedSumUHistogram) Clear() []uint64

func (*FixedSumUHistogram) IsSummed added in v0.0.8

func (h *FixedSumUHistogram) IsSummed() bool

func (*FixedSumUHistogram) SetLabels added in v0.0.8

func (h *FixedSumUHistogram) SetLabels(labels []string) UHistogram

func (*FixedSumUHistogram) SetNameTotal added in v0.0.8

func (h *FixedSumUHistogram) SetNameTotal(total string) UHistogram

type FixedUHistogram added in v0.0.12

type FixedUHistogram struct {
	UHistogramStorage
	// contains filtered or unexported fields
}

A FixedUHistogram is implementation of UHistogram with fixed-size buckets.

func (*FixedUHistogram) Add added in v0.0.12

func (h *FixedUHistogram) Add(v uint64)

func (*FixedUHistogram) AddLabelPrefix added in v0.0.12

func (h *FixedUHistogram) AddLabelPrefix(labelPrefix string) UHistogram

func (*FixedUHistogram) SetLabels added in v0.0.12

func (h *FixedUHistogram) SetLabels(labels []string) UHistogram

func (*FixedUHistogram) SetNameTotal added in v0.0.12

func (h *FixedUHistogram) SetNameTotal(total string) UHistogram

type FunctionalFGauge added in v0.0.7

type FunctionalFGauge struct {
	// contains filtered or unexported fields
}

FunctionalFGauge returns value from given function

func (FunctionalFGauge) Snapshot added in v0.0.7

func (g FunctionalFGauge) Snapshot() FGauge

Snapshot returns the snapshot.

func (FunctionalFGauge) Update added in v0.0.7

func (FunctionalFGauge) Update(float64)

Update panics.

func (FunctionalFGauge) Value added in v0.0.7

func (g FunctionalFGauge) Value() float64

Value returns the gauge's current value.

type FunctionalGauge

type FunctionalGauge struct {
	// contains filtered or unexported fields
}

FunctionalGauge returns value from given function

func (FunctionalGauge) Clear

func (g FunctionalGauge) Clear() int64

Clear panics.

func (FunctionalGauge) Snapshot

func (g FunctionalGauge) Snapshot() Gauge

Snapshot returns the snapshot.

func (FunctionalGauge) Update

func (FunctionalGauge) Update(int64)

Update panics.

func (FunctionalGauge) Value

func (g FunctionalGauge) Value() int64

Value returns the gauge's current value.

type FunctionalUGauge added in v0.0.7

type FunctionalUGauge struct {
	// contains filtered or unexported fields
}

FunctionalUGauge returns value from given function

func (FunctionalUGauge) Clear added in v0.0.7

func (g FunctionalUGauge) Clear() uint64

Clear panics.

func (FunctionalUGauge) Snapshot added in v0.0.7

func (g FunctionalUGauge) Snapshot() UGauge

Snapshot returns the snapshot.

func (FunctionalUGauge) Update added in v0.0.7

func (FunctionalUGauge) Update(uint64)

Update panics.

func (FunctionalUGauge) Value added in v0.0.7

func (g FunctionalUGauge) Value() uint64

Value returns the gauge's current value.

type Gauge

type Gauge interface {
	Snapshot() Gauge
	Clear() int64
	Update(int64)
	Value() int64
}

Gauges hold an int64 value that can be set arbitrarily.

Graphite naming scheme

Plain: {PREFIX}.{NAME}

Tagged: {TAG_PREFIX}.{NAME}

func GetOrRegisterDiffer

func GetOrRegisterDiffer(name string, r Registry, d int64) Gauge

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

func GetOrRegisterDifferT(name string, tagsMap map[string]string, r Registry, d int64) Gauge

GetOrRegisterDifferT returns an existing Differ or constructs and registers a new StandardDiffer.

func GetOrRegisterGauge

func GetOrRegisterGauge(name string, r Registry) Gauge

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

func GetOrRegisterGaugeT(name string, tagsMap map[string]string, r Registry) Gauge

GetOrRegisterGaugeT returns an existing Gauge or constructs and registers a new StandardGauge.

func NewDiffer

func NewDiffer(d int64) Gauge

NewDiffer constructs a new StandardDiffer.

func NewFunctionalGauge

func NewFunctionalGauge(f func() int64) Gauge

NewFunctionalGauge constructs a new FunctionalGauge.

func NewGauge

func NewGauge() Gauge

NewGauge constructs a new StandardGauge.

func NewRegisteredDiffer

func NewRegisteredDiffer(name string, r Registry, d int64) Gauge

NewRegisteredDiffer constructs and registers a new StandardDiffer.

func NewRegisteredDifferT

func NewRegisteredDifferT(name string, tagsMap map[string]string, r Registry, d int64) Gauge

NewRegisteredDifferT constructs and registers a new StandardDiffer.

func NewRegisteredFunctionalGauge

func NewRegisteredFunctionalGauge(name string, r Registry, f func() int64) Gauge

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

func NewRegisteredGauge(name string, r Registry) Gauge

NewRegisteredGauge constructs and registers a new StandardGauge.

func NewRegisteredGaugeT

func NewRegisteredGaugeT(name string, tagsMap map[string]string, r Registry) Gauge

NewRegisteredGaugeT constructs and registers a new StandardGauge.

type GaugeSnapshot

type GaugeSnapshot int64

GaugeSnapshot is a read-only copy of another Gauge.

func (GaugeSnapshot) Clear

func (g GaugeSnapshot) Clear() int64

Clear panics.

func (GaugeSnapshot) Snapshot

func (g GaugeSnapshot) Snapshot() Gauge

Snapshot returns the snapshot.

func (GaugeSnapshot) Update

func (GaugeSnapshot) Update(int64)

Update panics.

func (GaugeSnapshot) Value

func (g GaugeSnapshot) Value() int64

Value returns the value at the time the snapshot was taken.

type Healthcheck

type Healthcheck interface {
	Check() int32
	IsUp() bool
	Status() int32
	Healthy()
	Unhealthy()
}

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
	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

func GetOrRegisterFixedHistogram(name string, r Registry, startVal, endVal, width int64) Histogram

GetOrRegisterHistogram 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

GetOrRegisterHistogramT returns an existing Histogram or constructs and registers a new FixedHistorgam.

func GetOrRegisterFixedSumHistogram added in v0.0.4

func GetOrRegisterFixedSumHistogram(name string, r Registry, startVal, endVal, width int64) Histogram

GetOrRegisterHistogram returns an existing Histogram or constructs and registers a new FixedHistorgam (prometheus-like histogram).

func GetOrRegisterFixedSumHistogramT added in v0.0.4

func GetOrRegisterFixedSumHistogramT(name string, tagsMap map[string]string, r Registry, startVal, endVal, width int64) Histogram

GetOrRegisterSumHistogramT returns an existing Histogram or constructs and registers a new FixedHistorgam (prometheus-like histogram).

func GetOrRegisterVHistogram

func GetOrRegisterVHistogram(name string, r Registry, weights []int64, names []string) Histogram

func GetOrRegisterVHistogramT

func GetOrRegisterVHistogramT(name string, tagsMap map[string]string, r Registry, weights []int64, names []string) Histogram

func GetOrRegisterVSumHistogram added in v0.0.4

func GetOrRegisterVSumHistogram(name string, r Registry, weights []int64, names []string) Histogram

func GetOrRegisterVSumHistogramT added in v0.0.4

func GetOrRegisterVSumHistogramT(name string, tagsMap map[string]string, r Registry, weights []int64, names []string) Histogram

func NewFixedHistogram

func NewFixedHistogram(startVal, endVal, width int64) Histogram

func NewRegisteredFixedHistogram

func NewRegisteredFixedHistogram(name string, r Registry, startVal, endVal, width int64) Histogram

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 NewRegisteredFixedSumHistogram added in v0.0.4

func NewRegisteredFixedSumHistogram(name string, r Registry, startVal, endVal, width int64) Histogram

NewRegisteredFixedSumHistogram constructs and registers a new FixedSumHistogram (prometheus-like histogram).

func NewRegisteredFixedSumHistogramT added in v0.0.4

func NewRegisteredFixedSumHistogramT(name string, tagsMap map[string]string, r Registry, startVal, endVal, width int64) Histogram

NewRegisteredFixedSumHistogramT constructs and registers a new FixedSumHistogram (prometheus-like histogram).

func NewRegisteredVHistogram

func NewRegisteredVHistogram(name string, r Registry, weights []int64, names []string) Histogram

NewRegisteredVHistogram constructs and registers a new VHistogram.

func NewRegisteredVHistogramT

func NewRegisteredVHistogramT(name string, tagsMap map[string]string, r Registry, weights []int64, names []string) Histogram

NewRegisteredVHistogramT constructs and registers a new VHistogram.

func NewRegisteredVSumHistogram added in v0.0.4

func NewRegisteredVSumHistogram(name string, r Registry, weights []int64, names []string) Histogram

NewRegisteredVSumHistogram constructs and registers a new VSumHistogram (prometheus-like histogram).

func NewRegisteredVSumHistogramT added in v0.0.4

func NewRegisteredVSumHistogramT(name string, tagsMap map[string]string, r Registry, weights []int64, names []string) Histogram

NewRegisteredVSumHistogramT constructs and registers a new VSumHistogram (prometheus-like histogram).

func NewVHistogram

func NewVHistogram(weights []int64, labels []string) Histogram

type HistogramInterface

type HistogramInterface interface {
	Clear() []uint64
	Values() []uint64
	Labels() []string
	NameTotal() string
	// Tag aliases values (for le key)
	WeightsAliases() []string
	// If true, is prometheus-like (cummulative, increment in bucket[1]  also increment bucket[0])
	IsSummed() bool
}

A HistogramInterface is some strped (no Weights{}, it's not need in registry Each iterator) version of Histogram interface

Graphite naming scheme

Plain:

{PREFIX}.{NAME}{LABEL_BUCKET1}

{PREFIX}.{NAME}{LABEL_BUCKET2}

{PREFIX}.{NAME}{LABEL_BUCKET_INF}

{PREFIX}.{NAME}{TOTAL}

Tagged:

{TAG_PREFIX}.{NAME}{LABEL_BUCKET1};TAG=VAL;..;le=W1

{TAG_PREFIX}.{NAME}{LABEL_BUCKET2};TAG=VAL;..;le=W2

{TAG_PREFIX}.{NAME}{LABEL_BUCKET_INF};TAG=VAL;..;le=inf

{TAG_PREFIX}{NAME}{TOTAL};TAG=VAL;..

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() []uint64

func (*HistogramSnapshot) Interface

func (h *HistogramSnapshot) Interface() HistogramInterface

for static check compatbility with HistogramInterface

func (HistogramSnapshot) IsSummed added in v0.0.4

func (HistogramSnapshot) IsSummed() bool

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() []uint64

func (*HistogramStorage) Interface

func (h *HistogramStorage) Interface() HistogramInterface

for static check compatbility with HistogramInterface

func (*HistogramStorage) IsSummed added in v0.0.4

func (h *HistogramStorage) IsSummed() bool

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 NameTagged struct {
	Name string
	Tags string
}

type NilCounter

type NilCounter struct{}

NilCounter is a no-op Counter.

func (NilCounter) Add added in v0.0.11

func (NilCounter) Add(i uint64)

Inc is a no-op.

func (NilCounter) Clear

func (NilCounter) Clear() uint64

Clear is a no-op.

func (NilCounter) Count

func (NilCounter) Count() uint64

Count is a no-op.

func (NilCounter) Snapshot

func (NilCounter) Snapshot() Counter

Snapshot is a no-op.

type NilDownCounter

type NilDownCounter struct{}

NilDownCounter is a no-op DownCounter.

func (NilDownCounter) Add added in v0.0.11

func (NilDownCounter) Add(i int64)

Inc is a no-op.

func (NilDownCounter) Clear

func (NilDownCounter) Clear() int64

Clear is a no-op.

func (NilDownCounter) Count

func (NilDownCounter) Count() int64

Count is a no-op.

func (NilDownCounter) Snapshot

func (NilDownCounter) Snapshot() DownCounter

Snapshot is a no-op.

func (NilDownCounter) Sub added in v0.0.11

func (NilDownCounter) Sub(i int64)

type NilFGauge added in v0.0.7

type NilFGauge struct{}

NilGauge is a no-op Gauge.

func (NilFGauge) Snapshot added in v0.0.7

func (NilFGauge) Snapshot() FGauge

Snapshot is a no-op.

func (NilFGauge) Update added in v0.0.7

func (NilFGauge) Update(v float64)

Update is a no-op.

func (NilFGauge) Value added in v0.0.7

func (NilFGauge) Value() float64

Value is a no-op.

type NilFHistogram added in v0.0.12

type NilFHistogram struct{}

func (NilFHistogram) Add added in v0.0.12

func (h NilFHistogram) Add(v float64)

func (NilFHistogram) AddLabelPrefix added in v0.0.12

func (NilFHistogram) AddLabelPrefix(string) FHistogram

func (NilFHistogram) Clear added in v0.0.12

func (h NilFHistogram) Clear() []uint64

func (NilFHistogram) Interface added in v0.0.12

func (h NilFHistogram) Interface() HistogramInterface

func (NilFHistogram) IsSummed added in v0.0.12

func (NilFHistogram) IsSummed() bool

func (NilFHistogram) Labels added in v0.0.12

func (NilFHistogram) Labels() []string

func (NilFHistogram) NameTotal added in v0.0.12

func (NilFHistogram) NameTotal() string

func (NilFHistogram) SetLabels added in v0.0.12

func (NilFHistogram) SetLabels([]string) FHistogram

func (NilFHistogram) SetNameTotal added in v0.0.12

func (NilFHistogram) SetNameTotal(string) FHistogram

func (NilFHistogram) Snapshot added in v0.0.12

func (NilFHistogram) Snapshot() FHistogram

func (NilFHistogram) Values added in v0.0.12

func (NilFHistogram) Values() []uint64

func (NilFHistogram) Weights added in v0.0.12

func (NilFHistogram) Weights() []float64

func (NilFHistogram) WeightsAliases added in v0.0.12

func (NilFHistogram) WeightsAliases() []string

type NilFRate

type NilFRate struct{}

NilFRate is a no-op FRate.

func (NilFRate) Clear

func (NilFRate) Clear() (float64, float64)

Clear is a no-op.

func (NilFRate) Name

func (NilFRate) Name() string

func (NilFRate) RateName

func (NilFRate) RateName() string

func (NilFRate) SetName

func (g NilFRate) SetName(string) FRate

func (NilFRate) SetRateName

func (g NilFRate) SetRateName(string) FRate

func (NilFRate) Snapshot

func (NilFRate) Snapshot() FRate

Snapshot is a no-op.

func (NilFRate) Update

func (NilFRate) Update(float64)

Update is a no-op.

func (NilFRate) UpdateTs

func (NilFRate) UpdateTs(float64, int64)

UpdateTs is a no-op.

func (NilFRate) Values

func (NilFRate) Values() (float64, float64)

Value is a no-op.

type NilGauge

type NilGauge struct{}

NilGauge is a no-op Gauge.

func (NilGauge) Clear

func (NilGauge) Clear() int64

Clear is a no-op.

func (NilGauge) Snapshot

func (NilGauge) Snapshot() Gauge

Snapshot is a no-op.

func (NilGauge) Update

func (NilGauge) Update(v int64)

Update is a no-op.

func (NilGauge) Value

func (NilGauge) Value() int64

Value is a no-op.

type NilHealthcheck

type NilHealthcheck struct{}

NilHealthcheck is a no-op.

func (NilHealthcheck) Check

func (NilHealthcheck) Check() int32

Check is a no-op.

func (NilHealthcheck) Healthy

func (NilHealthcheck) Healthy()

Healthy is a no-op.

func (NilHealthcheck) IsUp

func (NilHealthcheck) IsUp() bool

IsError is a no-op.

func (NilHealthcheck) Status

func (NilHealthcheck) Status() int32

func (NilHealthcheck) Unhealthy

func (NilHealthcheck) Unhealthy()

Unhealthy is a no-op.

type NilHistogram added in v0.0.12

type NilHistogram struct{}

func (NilHistogram) Add added in v0.0.12

func (h NilHistogram) Add(v int64)

func (NilHistogram) AddLabelPrefix added in v0.0.12

func (NilHistogram) AddLabelPrefix(string) Histogram

func (NilHistogram) Clear added in v0.0.12

func (h NilHistogram) Clear() []uint64

func (NilHistogram) Interface added in v0.0.12

func (h NilHistogram) Interface() HistogramInterface

func (NilHistogram) IsSummed added in v0.0.12

func (NilHistogram) IsSummed() bool

func (NilHistogram) Labels added in v0.0.12

func (NilHistogram) Labels() []string

func (NilHistogram) NameTotal added in v0.0.12

func (NilHistogram) NameTotal() string

func (NilHistogram) SetLabels added in v0.0.12

func (NilHistogram) SetLabels([]string) Histogram

func (NilHistogram) SetNameTotal added in v0.0.12

func (NilHistogram) SetNameTotal(string) Histogram

func (NilHistogram) Snapshot added in v0.0.12

func (NilHistogram) Snapshot() Histogram

func (NilHistogram) Values added in v0.0.12

func (NilHistogram) Values() []uint64

func (NilHistogram) Weights added in v0.0.12

func (NilHistogram) Weights() []int64

func (NilHistogram) WeightsAliases added in v0.0.12

func (NilHistogram) WeightsAliases() []string

type NilRate

type NilRate struct{}

NilRate is a no-op Rate.

func (NilRate) Clear

func (NilRate) Clear() (int64, float64)

Clear is a no-op.

func (NilRate) Name

func (NilRate) Name() string

func (NilRate) RateName

func (NilRate) RateName() string

func (NilRate) SetName

func (g NilRate) SetName(string) Rate

func (NilRate) SetRateName

func (g NilRate) SetRateName(string) Rate

func (NilRate) Snapshot

func (NilRate) Snapshot() Rate

Snapshot is a no-op.

func (NilRate) Update

func (NilRate) Update(int64)

Update is a no-op.

func (NilRate) UpdateTs

func (NilRate) UpdateTs(int64, int64)

UpdateTs is a no-op.

func (NilRate) Values

func (NilRate) Values() (int64, float64)

Value is a no-op.

type NilUGauge added in v0.0.7

type NilUGauge struct{}

NilUGauge is a no-op UGauge.

func (NilUGauge) Clear added in v0.0.7

func (NilUGauge) Clear() uint64

Clear is a no-op.

func (NilUGauge) Snapshot added in v0.0.7

func (NilUGauge) Snapshot() UGauge

Snapshot is a no-op.

func (NilUGauge) Update added in v0.0.7

func (NilUGauge) Update(v uint64)

Update is a no-op.

func (NilUGauge) Value added in v0.0.7

func (NilUGauge) Value() uint64

Value is a no-op.

type NilUHistogram added in v0.0.12

type NilUHistogram struct{}

func (NilUHistogram) Add added in v0.0.12

func (h NilUHistogram) Add(v uint64)

func (NilUHistogram) AddLabelPrefix added in v0.0.12

func (NilUHistogram) AddLabelPrefix(string) UHistogram

func (NilUHistogram) Clear added in v0.0.12

func (h NilUHistogram) Clear() []uint64

func (NilUHistogram) Interface added in v0.0.12

func (h NilUHistogram) Interface() HistogramInterface

func (NilUHistogram) IsSummed added in v0.0.12

func (NilUHistogram) IsSummed() bool

func (NilUHistogram) Labels added in v0.0.12

func (NilUHistogram) Labels() []string

func (NilUHistogram) NameTotal added in v0.0.12

func (NilUHistogram) NameTotal() string

func (NilUHistogram) SetLabels added in v0.0.12

func (NilUHistogram) SetLabels([]string) UHistogram

func (NilUHistogram) SetNameTotal added in v0.0.12

func (NilUHistogram) SetNameTotal(string) UHistogram

func (NilUHistogram) Snapshot added in v0.0.12

func (NilUHistogram) Snapshot() UHistogram

func (NilUHistogram) Values added in v0.0.12

func (NilUHistogram) Values() []uint64

func (NilUHistogram) Weights added in v0.0.12

func (NilUHistogram) Weights() []uint64

func (NilUHistogram) WeightsAliases added in v0.0.12

func (NilUHistogram) WeightsAliases() []string

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

func GetOrRegisterRate(name string, r Registry) Rate

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

func GetOrRegisterRateT(name string, tagsMap map[string]string, r Registry) Rate

GetOrRegisterRateT returns an existing Rate or constructs and registers a new StandardRate.

func NewRate

func NewRate() Rate

NewRate constructs a new StandardRate.

func NewRegisteredRate

func NewRegisteredRate(name string, r Registry) Rate

NewRegisteredRate constructs and registers a new StandardRate.

func NewRegisteredRateT

func NewRegisteredRateT(name string, tagsMap map[string]string, r Registry) Rate

NewRegisteredRateT constructs and registers a new StandardRate.

type RateNames

type RateNames interface {
	SetName(string) Rate
	Name() string
	SetRateName(string) Rate
	RateName() string
}

type RateSnapshot

type RateSnapshot struct {
	// contains filtered or unexported fields
}

RateSnapshot is a read-only copy of another Rate.

func (RateSnapshot) Clear

func (RateSnapshot) Clear() (int64, float64)

Clear panics.

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) Update

func (RateSnapshot) Update(int64)

Update panics.

func (RateSnapshot) UpdateTs

func (RateSnapshot) UpdateTs(int64, int64)

Update panics.

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()

func NewRegistry

func NewRegistry() Registry

Create a new registry.

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) Add added in v0.0.11

func (c *StandardCounter) Add(i uint64)

Inc increments the Counter by the given amount.

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) 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) Add added in v0.0.11

func (c *StandardDownCounter) Add(i int64)

Inc increments the DownCounter by the given amount.

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) Snapshot

func (c *StandardDownCounter) Snapshot() DownCounter

Snapshot returns a read-only copy of the DownCounter.

func (*StandardDownCounter) Sub added in v0.0.11

func (c *StandardDownCounter) Sub(i int64)

Dec decrements the DownCounter by the given amount.

type StandardFGauge added in v0.0.7

type StandardFGauge struct {
	// contains filtered or unexported fields
}

StandardFGauge is the standard implementation of a FGauge and uses sync.Mutex to manage a single float64 value.

func (*StandardFGauge) Snapshot added in v0.0.7

func (g *StandardFGauge) Snapshot() FGauge

Snapshot returns a read-only copy of the gauge.

func (*StandardFGauge) Update added in v0.0.7

func (g *StandardFGauge) Update(v float64)

Update updates the gauge's value.

func (*StandardFGauge) Value added in v0.0.7

func (g *StandardFGauge) Value() float64

Value returns the gauge's current value.

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 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) Each

func (r *StandardRegistry) Each(f func(string, string, map[string]string, interface{}) error, minLock bool) error

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 StandardUGauge added in v0.0.7

type StandardUGauge struct {
	// contains filtered or unexported fields
}

StandardUGauge is the standard implementation of a UGauge and uses the sync/atomic package to manage a single int64 value.

func (*StandardUGauge) Clear added in v0.0.7

func (g *StandardUGauge) Clear() uint64

Clear sets the DownCounter to zero.

func (*StandardUGauge) Snapshot added in v0.0.7

func (g *StandardUGauge) Snapshot() UGauge

Snapshot returns a read-only copy of the gauge.

func (*StandardUGauge) Update added in v0.0.7

func (g *StandardUGauge) Update(v uint64)

Update updates the gauge's value.

func (*StandardUGauge) Value added in v0.0.7

func (g *StandardUGauge) Value() uint64

Value returns the gauge's current value.

type SumFHistogramSnapshot added in v0.0.10

type SumFHistogramSnapshot struct {
	// contains filtered or unexported fields
}

func (*SumFHistogramSnapshot) Add added in v0.0.10

func (h *SumFHistogramSnapshot) Add(v float64)

func (SumFHistogramSnapshot) AddLabelPrefix added in v0.0.10

func (SumFHistogramSnapshot) AddLabelPrefix(string) FHistogram

func (*SumFHistogramSnapshot) Clear added in v0.0.10

func (h *SumFHistogramSnapshot) Clear() []uint64

func (*SumFHistogramSnapshot) Interface added in v0.0.10

for static check compatbility with FHistogramInterface

func (SumFHistogramSnapshot) IsSummed added in v0.0.10

func (SumFHistogramSnapshot) IsSummed() bool

func (*SumFHistogramSnapshot) Labels added in v0.0.10

func (h *SumFHistogramSnapshot) Labels() []string

func (*SumFHistogramSnapshot) NameTotal added in v0.0.10

func (h *SumFHistogramSnapshot) NameTotal() string

func (SumFHistogramSnapshot) SetLabels added in v0.0.10

func (SumFHistogramSnapshot) SetNameTotal added in v0.0.10

func (SumFHistogramSnapshot) SetNameTotal(string) FHistogram

func (*SumFHistogramSnapshot) Snapshot added in v0.0.10

func (h *SumFHistogramSnapshot) Snapshot() FHistogram

func (*SumFHistogramSnapshot) Values added in v0.0.10

func (h *SumFHistogramSnapshot) Values() []uint64

func (*SumFHistogramSnapshot) Weights added in v0.0.10

func (h *SumFHistogramSnapshot) Weights() []float64

func (*SumFHistogramSnapshot) WeightsAliases added in v0.0.10

func (h *SumFHistogramSnapshot) WeightsAliases() []string

type SumHistogramSnapshot added in v0.0.4

type SumHistogramSnapshot struct {
	// contains filtered or unexported fields
}

func (*SumHistogramSnapshot) Add added in v0.0.4

func (h *SumHistogramSnapshot) Add(v int64)

func (SumHistogramSnapshot) AddLabelPrefix added in v0.0.4

func (SumHistogramSnapshot) AddLabelPrefix(string) Histogram

func (*SumHistogramSnapshot) Clear added in v0.0.4

func (h *SumHistogramSnapshot) Clear() []uint64

func (*SumHistogramSnapshot) Interface added in v0.0.4

for static check compatbility with HistogramInterface

func (SumHistogramSnapshot) IsSummed added in v0.0.4

func (SumHistogramSnapshot) IsSummed() bool

func (*SumHistogramSnapshot) Labels added in v0.0.4

func (h *SumHistogramSnapshot) Labels() []string

func (*SumHistogramSnapshot) NameTotal added in v0.0.4

func (h *SumHistogramSnapshot) NameTotal() string

func (SumHistogramSnapshot) SetLabels added in v0.0.4

func (SumHistogramSnapshot) SetLabels([]string) Histogram

func (SumHistogramSnapshot) SetNameTotal added in v0.0.4

func (SumHistogramSnapshot) SetNameTotal(string) Histogram

func (*SumHistogramSnapshot) Snapshot added in v0.0.4

func (h *SumHistogramSnapshot) Snapshot() Histogram

func (*SumHistogramSnapshot) Values added in v0.0.4

func (h *SumHistogramSnapshot) Values() []uint64

func (*SumHistogramSnapshot) Weights added in v0.0.4

func (h *SumHistogramSnapshot) Weights() []int64

func (*SumHistogramSnapshot) WeightsAliases added in v0.0.4

func (h *SumHistogramSnapshot) WeightsAliases() []string

type SumUHistogramSnapshot added in v0.0.8

type SumUHistogramSnapshot struct {
	// contains filtered or unexported fields
}

func (*SumUHistogramSnapshot) Add added in v0.0.8

func (h *SumUHistogramSnapshot) Add(v uint64)

func (SumUHistogramSnapshot) AddLabelPrefix added in v0.0.8

func (SumUHistogramSnapshot) AddLabelPrefix(string) UHistogram

func (*SumUHistogramSnapshot) Clear added in v0.0.8

func (h *SumUHistogramSnapshot) Clear() []uint64

func (*SumUHistogramSnapshot) Interface added in v0.0.8

for static check compatbility with UHistogramInterface

func (SumUHistogramSnapshot) IsSummed added in v0.0.8

func (SumUHistogramSnapshot) IsSummed() bool

func (*SumUHistogramSnapshot) Labels added in v0.0.8

func (h *SumUHistogramSnapshot) Labels() []string

func (*SumUHistogramSnapshot) NameTotal added in v0.0.8

func (h *SumUHistogramSnapshot) NameTotal() string

func (SumUHistogramSnapshot) SetLabels added in v0.0.8

func (SumUHistogramSnapshot) SetNameTotal added in v0.0.8

func (SumUHistogramSnapshot) SetNameTotal(string) UHistogram

func (*SumUHistogramSnapshot) Snapshot added in v0.0.8

func (h *SumUHistogramSnapshot) Snapshot() UHistogram

func (*SumUHistogramSnapshot) Values added in v0.0.8

func (h *SumUHistogramSnapshot) Values() []uint64

func (*SumUHistogramSnapshot) Weights added in v0.0.8

func (h *SumUHistogramSnapshot) Weights() []uint64

func (*SumUHistogramSnapshot) WeightsAliases added in v0.0.8

func (h *SumUHistogramSnapshot) WeightsAliases() []string

type UGauge added in v0.0.7

type UGauge interface {
	Snapshot() UGauge
	Clear() uint64
	Update(uint64)
	Value() uint64
}

UGauges hold an int64 value that can be set arbitrarily.

Graphite naming scheme

Plain: {PREFIX}.{NAME}

Tagged: {TAG_PREFIX}.{NAME}

func GetOrRegisterUGauge added in v0.0.7

func GetOrRegisterUGauge(name string, r Registry) UGauge

GetOrRegisterUGauge returns an existing UGauge or constructs and registers a new StandardUGauge.

Example
m := "server.bytes_sent"
g := GetOrRegisterUGauge(m, NewRegistry())
g.Update(47)
fmt.Println(g.Value()) 
Output:

47

func GetOrRegisterUGaugeT added in v0.0.7

func GetOrRegisterUGaugeT(name string, tagsMap map[string]string, r Registry) UGauge

GetOrRegisterUGaugeT returns an existing UGauge or constructs and registers a new StandardUGauge.

func NewFunctionalUGauge added in v0.0.7

func NewFunctionalUGauge(f func() uint64) UGauge

NewFunctionalUGauge constructs a new FunctionalUGauge.

func NewRegisteredFunctionalUGauge added in v0.0.7

func NewRegisteredFunctionalUGauge(name string, r Registry, f func() uint64) UGauge

NewRegisteredFunctionalUGauge constructs and registers a new StandardUGauge.

func NewRegisteredFunctionalUGaugeT added in v0.0.7

func NewRegisteredFunctionalUGaugeT(name string, tagsMap map[string]string, r Registry, f func() uint64) UGauge

NewRegisteredFunctionalUGaugeT constructs and registers a new StandardUGauge.

func NewRegisteredUGauge added in v0.0.7

func NewRegisteredUGauge(name string, r Registry) UGauge

NewRegisteredUGauge constructs and registers a new StandardUGauge.

func NewRegisteredUGaugeT added in v0.0.7

func NewRegisteredUGaugeT(name string, tagsMap map[string]string, r Registry) UGauge

NewRegisteredUGaugeT constructs and registers a new StandardUGauge.

func NewUGauge added in v0.0.7

func NewUGauge() UGauge

NewUGauge constructs a new StandardUGauge.

type UGaugeSnapshot added in v0.0.7

type UGaugeSnapshot uint64

UGaugeSnapshot is a read-only copy of another UGauge.

func (UGaugeSnapshot) Clear added in v0.0.7

func (g UGaugeSnapshot) Clear() uint64

Clear panics.

func (UGaugeSnapshot) Snapshot added in v0.0.7

func (g UGaugeSnapshot) Snapshot() UGauge

Snapshot returns the snapshot.

func (UGaugeSnapshot) Update added in v0.0.7

func (UGaugeSnapshot) Update(uint64)

Update panics.

func (UGaugeSnapshot) Value added in v0.0.7

func (g UGaugeSnapshot) Value() uint64

Value returns the value at the time the snapshot was taken.

type UHistogram

type UHistogram interface {
	HistogramInterface
	SetLabels([]string) UHistogram
	AddLabelPrefix(string) UHistogram
	SetNameTotal(string) UHistogram
	Snapshot() UHistogram
	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 GetOrRegisterFixedSumUHistogram added in v0.0.8

func GetOrRegisterFixedSumUHistogram(name string, r Registry, startVal, endVal, width uint64) UHistogram

GetOrRegisterHistogram returns an existing UHistogram or constructs and registers a new FixedHistorgam (prometheus-like histogram).

func GetOrRegisterFixedSumUHistogramT added in v0.0.8

func GetOrRegisterFixedSumUHistogramT(name string, tagsMap map[string]string, r Registry, startVal, endVal, width uint64) UHistogram

GetOrRegisterSumUHistogramT returns an existing UHistogram or constructs and registers a new FixedHistorgam (prometheus-like histogram).

func GetOrRegisterFixedUHistogram added in v0.0.12

func GetOrRegisterFixedUHistogram(name string, r Registry, startVal, endVal, width uint64) UHistogram

GetOrRegisterHistogram returns an existing Histogram or constructs and registers a new FixedHistorgam.

func GetOrRegisterFixedUHistogramT added in v0.0.12

func GetOrRegisterFixedUHistogramT(name string, tagsMap map[string]string, r Registry, startVal, endVal, width uint64) UHistogram

GetOrRegisterHistogramT returns an existing Histogram or constructs and registers a new FixedHistorgam.

func GetOrRegisterVSumUHistogram added in v0.0.8

func GetOrRegisterVSumUHistogram(name string, r Registry, weights []uint64, names []string) UHistogram

func GetOrRegisterVSumUHistogramT added in v0.0.8

func GetOrRegisterVSumUHistogramT(name string, tagsMap map[string]string, r Registry, weights []uint64, names []string) UHistogram

func GetOrRegisterVUHistogram added in v0.0.12

func GetOrRegisterVUHistogram(name string, r Registry, weights []uint64, names []string) UHistogram

func GetOrRegisterVUHistogramT added in v0.0.12

func GetOrRegisterVUHistogramT(name string, tagsMap map[string]string, r Registry, weights []uint64, names []string) UHistogram

func NewFixedUHistogram added in v0.0.12

func NewFixedUHistogram(startVal, endVal, width uint64) UHistogram

func NewRegisteredFixedSumUHistogram added in v0.0.8

func NewRegisteredFixedSumUHistogram(name string, r Registry, startVal, endVal, width uint64) UHistogram

NewRegisteredFixedSumUHistogram constructs and registers a new FixedSumUHistogram (prometheus-like histogram).

func NewRegisteredFixedSumUHistogramT added in v0.0.8

func NewRegisteredFixedSumUHistogramT(name string, tagsMap map[string]string, r Registry, startVal, endVal, width uint64) UHistogram

NewRegisteredFixedSumUHistogramT constructs and registers a new FixedSumUHistogram (prometheus-like histogram).

func NewRegisteredFixedUHistogram added in v0.0.12

func NewRegisteredFixedUHistogram(name string, r Registry, startVal, endVal, width uint64) UHistogram

NewRegisteredFixedHistogram constructs and registers a new FixedHistogram.

func NewRegisteredFixedUHistogramT added in v0.0.12

func NewRegisteredFixedUHistogramT(name string, tagsMap map[string]string, r Registry, startVal, endVal, width uint64) UHistogram

NewRegisteredFixedHistogramT constructs and registers a new FixedHistogram.

func NewRegisteredVSumUHistogram added in v0.0.8

func NewRegisteredVSumUHistogram(name string, r Registry, weights []uint64, names []string) UHistogram

NewRegisteredVSumUHistogram constructs and registers a new VSumUHistogram (prometheus-like histogram).

func NewRegisteredVSumUHistogramT added in v0.0.8

func NewRegisteredVSumUHistogramT(name string, tagsMap map[string]string, r Registry, weights []uint64, names []string) UHistogram

NewRegisteredVSumUHistogramT constructs and registers a new VSumUHistogram (prometheus-like histogram).

func NewRegisteredVUHistogram added in v0.0.12

func NewRegisteredVUHistogram(name string, r Registry, weights []uint64, names []string) UHistogram

NewRegisteredVHistogram constructs and registers a new VHistogram.

func NewRegisteredVUHistogramT added in v0.0.12

func NewRegisteredVUHistogramT(name string, tagsMap map[string]string, r Registry, weights []uint64, names []string) UHistogram

NewRegisteredVHistogramT constructs and registers a new VHistogram.

func NewVUHistogram added in v0.0.12

func NewVUHistogram(weights []uint64, labels []string) UHistogram

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() []uint64

func (*UHistogramSnapshot) Interface

func (h *UHistogramSnapshot) Interface() HistogramInterface

for static check compatbility with HistogramInterface

func (*UHistogramSnapshot) IsSummed added in v0.0.4

func (h *UHistogramSnapshot) IsSummed() bool

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() []uint64

func (*UHistogramStorage) Interface

func (h *UHistogramStorage) Interface() HistogramInterface

for static check compatbility with HistogramInterface

func (*UHistogramStorage) IsSummed added in v0.0.4

func (h *UHistogramStorage) IsSummed() bool

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 Updated

type Updated interface {
	Tick()
}

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 (*VHistogram) Add

func (h *VHistogram) Add(v int64)

func (*VHistogram) AddLabelPrefix

func (h *VHistogram) AddLabelPrefix(labelPrefix string) Histogram

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

type VSumFHistogram added in v0.0.10

type VSumFHistogram struct {
	FHistogramStorage
}

A VSumFHistogram is implementation of prometheus-like FHistogram with varibale-size buckets.

func NewVSumFHistogram added in v0.0.10

func NewVSumFHistogram(weights []float64, names []string) *VSumFHistogram

func (*VSumFHistogram) Add added in v0.0.10

func (h *VSumFHistogram) Add(v float64)

func (*VSumFHistogram) AddLabelPrefix added in v0.0.10

func (h *VSumFHistogram) AddLabelPrefix(labelPrefix string) FHistogram

func (*VSumFHistogram) Interface added in v0.0.10

func (h *VSumFHistogram) Interface() HistogramInterface

for static check compatbility with FHistogramInterface

func (*VSumFHistogram) IsSummed added in v0.0.10

func (h *VSumFHistogram) IsSummed() bool

func (*VSumFHistogram) SetLabels added in v0.0.10

func (h *VSumFHistogram) SetLabels(labels []string) FHistogram

func (*VSumFHistogram) SetNameTotal added in v0.0.10

func (h *VSumFHistogram) SetNameTotal(total string) FHistogram

func (*VSumFHistogram) Snapshot added in v0.0.10

func (h *VSumFHistogram) Snapshot() FHistogram

func (*VSumFHistogram) Values added in v0.0.10

func (h *VSumFHistogram) Values() []uint64

func (*VSumFHistogram) WeightsAliases added in v0.0.10

func (h *VSumFHistogram) WeightsAliases() []string

type VSumHistogram added in v0.0.4

type VSumHistogram struct {
	HistogramStorage
}

A VSumHistogram is implementation of prometheus-like Histogram with varibale-size buckets.

func NewVSumHistogram added in v0.0.4

func NewVSumHistogram(weights []int64, names []string) *VSumHistogram

func (*VSumHistogram) Add added in v0.0.4

func (h *VSumHistogram) Add(v int64)

func (*VSumHistogram) AddLabelPrefix added in v0.0.4

func (h *VSumHistogram) AddLabelPrefix(labelPrefix string) Histogram

func (*VSumHistogram) Interface added in v0.0.4

func (h *VSumHistogram) Interface() HistogramInterface

for static check compatbility with HistogramInterface

func (*VSumHistogram) IsSummed added in v0.0.4

func (h *VSumHistogram) IsSummed() bool

func (*VSumHistogram) SetLabels added in v0.0.4

func (h *VSumHistogram) SetLabels(labels []string) Histogram

func (*VSumHistogram) SetNameTotal added in v0.0.4

func (h *VSumHistogram) SetNameTotal(total string) Histogram

func (*VSumHistogram) Snapshot added in v0.0.4

func (h *VSumHistogram) Snapshot() Histogram

func (*VSumHistogram) Values added in v0.0.4

func (h *VSumHistogram) Values() []uint64

func (*VSumHistogram) WeightsAliases added in v0.0.4

func (h *VSumHistogram) WeightsAliases() []string

type VSumUHistogram added in v0.0.8

type VSumUHistogram struct {
	UHistogramStorage
}

A VSumUHistogram is implementation of prometheus-like UHistogram with varibale-size buckets.

func NewVSumUHistogram added in v0.0.8

func NewVSumUHistogram(weights []uint64, names []string) *VSumUHistogram

func (*VSumUHistogram) Add added in v0.0.8

func (h *VSumUHistogram) Add(v uint64)

func (*VSumUHistogram) AddLabelPrefix added in v0.0.8

func (h *VSumUHistogram) AddLabelPrefix(labelPrefix string) UHistogram

func (*VSumUHistogram) Interface added in v0.0.8

func (h *VSumUHistogram) Interface() HistogramInterface

for static check compatbility with UHistogramInterface

func (*VSumUHistogram) IsSummed added in v0.0.8

func (h *VSumUHistogram) IsSummed() bool

func (*VSumUHistogram) SetLabels added in v0.0.8

func (h *VSumUHistogram) SetLabels(labels []string) UHistogram

func (*VSumUHistogram) SetNameTotal added in v0.0.8

func (h *VSumUHistogram) SetNameTotal(total string) UHistogram

func (*VSumUHistogram) Snapshot added in v0.0.8

func (h *VSumUHistogram) Snapshot() UHistogram

func (*VSumUHistogram) Values added in v0.0.8

func (h *VSumUHistogram) Values() []uint64

func (*VSumUHistogram) WeightsAliases added in v0.0.8

func (h *VSumUHistogram) WeightsAliases() []string

type VUHistogram added in v0.0.12

type VUHistogram struct {
	UHistogramStorage
}

A VUHistogram is implementation of UHistogram with varibale-size buckets.

func (*VUHistogram) Add added in v0.0.12

func (h *VUHistogram) Add(v uint64)

func (*VUHistogram) AddLabelPrefix added in v0.0.12

func (h *VUHistogram) AddLabelPrefix(labelPrefix string) UHistogram

func (*VUHistogram) SetLabels added in v0.0.12

func (h *VUHistogram) SetLabels(labels []string) UHistogram

func (*VUHistogram) SetNameTotal added in v0.0.12

func (h *VUHistogram) SetNameTotal(total string) UHistogram

func (*VUHistogram) Snapshot added in v0.0.12

func (h *VUHistogram) Snapshot() UHistogram

func (*VUHistogram) Values added in v0.0.12

func (h *VUHistogram) Values() []uint64

type ValTagged

type ValTagged struct {
	I       interface{}
	TagsMap map[string]string
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL