Documentation
¶
Index ¶
- Variables
- func NameIn(names ...string) func(string) bool
- type ClearOnVisitHistogram
- func (h *ClearOnVisitHistogram) Clear()
- func (h *ClearOnVisitHistogram) Count() int64
- func (h *ClearOnVisitHistogram) Max() int64
- func (h *ClearOnVisitHistogram) Mean() float64
- func (h *ClearOnVisitHistogram) Min() int64
- func (h *ClearOnVisitHistogram) Percentile(p float64) float64
- func (h *ClearOnVisitHistogram) Percentiles(ps []float64) []float64
- func (h *ClearOnVisitHistogram) Sample() metrics.Sample
- func (h *ClearOnVisitHistogram) Snapshot() metrics.Histogram
- func (h *ClearOnVisitHistogram) StdDev() float64
- func (h *ClearOnVisitHistogram) Sum() int64
- func (h *ClearOnVisitHistogram) Update(v int64)
- func (h *ClearOnVisitHistogram) Variance() float64
- type ClearOnVisitHistogramSnapshot
- func (*ClearOnVisitHistogramSnapshot) Clear()
- func (h *ClearOnVisitHistogramSnapshot) Count() int64
- func (h *ClearOnVisitHistogramSnapshot) Max() int64
- func (h *ClearOnVisitHistogramSnapshot) Mean() float64
- func (h *ClearOnVisitHistogramSnapshot) Min() int64
- func (h *ClearOnVisitHistogramSnapshot) Percentile(p float64) float64
- func (h *ClearOnVisitHistogramSnapshot) Percentiles(ps []float64) []float64
- func (h *ClearOnVisitHistogramSnapshot) Sample() metrics.Sample
- func (h *ClearOnVisitHistogramSnapshot) Snapshot() metrics.Histogram
- func (h *ClearOnVisitHistogramSnapshot) StdDev() float64
- func (h *ClearOnVisitHistogramSnapshot) Sum() int64
- func (*ClearOnVisitHistogramSnapshot) Update(int64)
- func (h *ClearOnVisitHistogramSnapshot) Variance() float64
- type GoMetricsRegistry
- func (r *GoMetricsRegistry) Each(f func(string, interface{}))
- func (r *GoMetricsRegistry) Get(name string) interface{}
- func (r *GoMetricsRegistry) GetAll() map[string]map[string]interface{}
- func (r *GoMetricsRegistry) GetOrRegister(name string, metric interface{}) interface{}
- func (r *GoMetricsRegistry) Register(name string, metric interface{}) error
- func (r *GoMetricsRegistry) RunHealthchecks()
- func (r *GoMetricsRegistry) Unregister(name string)
- func (r *GoMetricsRegistry) UnregisterAll()
- type MetricFilter
- func ApplyIf(pred func(name string) bool, filters ...MetricFilter) MetricFilter
- func ModifyName(f func(string) string) MetricFilter
- func NameReplace(old, new string) MetricFilter
- func Rename(from, to string) MetricFilter
- func ReportIf(pred func(string) bool) MetricFilter
- func ReportNames(names ...string) MetricFilter
- func Whitelist(names ...string) MetricFilter
- func WhitelistIf(pred func(string) bool) MetricFilter
Constants ¶
This section is empty.
Variables ¶
var Accept = withVarFilter(func(st state) state {
st.action = actAccept
return st
})
var GoMetricsNilify = withVarFilter(func(st state) state { if st.action != actIgnore { return st } switch st.metric.(type) { case *metrics.StandardCounter: st.metric = metrics.NilCounter{} case *metrics.StandardEWMA: st.metric = metrics.NilEWMA{} case *metrics.StandardGauge: st.metric = metrics.NilGauge{} case *metrics.StandardGaugeFloat64: st.metric = metrics.NilGaugeFloat64{} case *metrics.StandardHealthcheck: st.metric = metrics.NilHealthcheck{} case *metrics.StandardHistogram: st.metric = metrics.NilHistogram{} case *metrics.StandardMeter: st.metric = metrics.NilMeter{} case *metrics.StandardTimer: st.metric = metrics.NilTimer{} } return st })
GoMetricsNilify MetricFilter used to convert all metrics not being accepted by the filters to be replace with a Noop-metric. This can be used to disable metrics in go-metrics users lazily generating metrics via GetOrRegister.
var ToLowerName = ModifyName(strings.ToLower)
ToLowerName converts all metric names to lower-case
var ToUpperName = ModifyName(strings.ToUpper)
ToUpperName converts all metric name to upper-case
Functions ¶
Types ¶
type ClearOnVisitHistogram ¶ added in v0.22.0
type ClearOnVisitHistogram struct {
// contains filtered or unexported fields
}
ClearOnVisitHistogram is the same as a go-metrics StandardHistogram except that when you visit it, it calls clear on the underlying sample.
func NewClearOnVisitHistogram ¶ added in v0.22.0
func NewClearOnVisitHistogram(s metrics.Sample) *ClearOnVisitHistogram
NewClearOnVisitHistogram constructs a new ClearOnVisitHistogram from a go-metrics Sample.
func (*ClearOnVisitHistogram) Clear ¶ added in v0.22.0
func (h *ClearOnVisitHistogram) Clear()
Clear clears the histogram and its sample.
func (*ClearOnVisitHistogram) Count ¶ added in v0.22.0
func (h *ClearOnVisitHistogram) Count() int64
Count returns the number of samples recorded since the histogram was last cleared.
func (*ClearOnVisitHistogram) Max ¶ added in v0.22.0
func (h *ClearOnVisitHistogram) Max() int64
Max returns the maximum value in the sample.
func (*ClearOnVisitHistogram) Mean ¶ added in v0.22.0
func (h *ClearOnVisitHistogram) Mean() float64
Mean returns the mean of the values in the sample.
func (*ClearOnVisitHistogram) Min ¶ added in v0.22.0
func (h *ClearOnVisitHistogram) Min() int64
Min returns the minimum value in the sample.
func (*ClearOnVisitHistogram) Percentile ¶ added in v0.22.0
func (h *ClearOnVisitHistogram) Percentile(p float64) float64
Percentile returns an arbitrary percentile of the values in the sample.
func (*ClearOnVisitHistogram) Percentiles ¶ added in v0.22.0
func (h *ClearOnVisitHistogram) Percentiles(ps []float64) []float64
Percentiles returns a slice of arbitrary percentiles of the values in the sample.
func (*ClearOnVisitHistogram) Sample ¶ added in v0.22.0
func (h *ClearOnVisitHistogram) Sample() metrics.Sample
Sample returns the Sample underlying the histogram.
func (*ClearOnVisitHistogram) Snapshot ¶ added in v0.22.0
func (h *ClearOnVisitHistogram) Snapshot() metrics.Histogram
Snapshot returns a read-only copy of the histogram.
func (*ClearOnVisitHistogram) StdDev ¶ added in v0.22.0
func (h *ClearOnVisitHistogram) StdDev() float64
StdDev returns the standard deviation of the values in the sample.
func (*ClearOnVisitHistogram) Sum ¶ added in v0.22.0
func (h *ClearOnVisitHistogram) Sum() int64
Sum returns the sum in the sample.
func (*ClearOnVisitHistogram) Update ¶ added in v0.22.0
func (h *ClearOnVisitHistogram) Update(v int64)
Update samples a new value.
func (*ClearOnVisitHistogram) Variance ¶ added in v0.22.0
func (h *ClearOnVisitHistogram) Variance() float64
Variance returns the variance of the values in the sample.
type ClearOnVisitHistogramSnapshot ¶ added in v0.22.0
type ClearOnVisitHistogramSnapshot struct {
// contains filtered or unexported fields
}
ClearOnVisitHistogramSnapshot is a read-only copy of another Histogram. This is analogous to a go-metrics HistogramSnapshot
func (*ClearOnVisitHistogramSnapshot) Clear ¶ added in v0.22.0
func (*ClearOnVisitHistogramSnapshot) Clear()
Clear panics.
func (*ClearOnVisitHistogramSnapshot) Count ¶ added in v0.22.0
func (h *ClearOnVisitHistogramSnapshot) Count() int64
Count returns the number of samples recorded at the time the snapshot was taken.
func (*ClearOnVisitHistogramSnapshot) Max ¶ added in v0.22.0
func (h *ClearOnVisitHistogramSnapshot) Max() int64
Max returns the maximum value in the sample at the time the snapshot was taken.
func (*ClearOnVisitHistogramSnapshot) Mean ¶ added in v0.22.0
func (h *ClearOnVisitHistogramSnapshot) Mean() float64
Mean returns the mean of the values in the sample at the time the snapshot was taken.
func (*ClearOnVisitHistogramSnapshot) Min ¶ added in v0.22.0
func (h *ClearOnVisitHistogramSnapshot) Min() int64
Min returns the minimum value in the sample at the time the snapshot was taken.
func (*ClearOnVisitHistogramSnapshot) Percentile ¶ added in v0.22.0
func (h *ClearOnVisitHistogramSnapshot) Percentile(p float64) float64
Percentile returns an arbitrary percentile of values in the sample at the time the snapshot was taken.
func (*ClearOnVisitHistogramSnapshot) Percentiles ¶ added in v0.22.0
func (h *ClearOnVisitHistogramSnapshot) Percentiles(ps []float64) []float64
Percentiles returns a slice of arbitrary percentiles of values in the sample at the time the snapshot was taken.
func (*ClearOnVisitHistogramSnapshot) Sample ¶ added in v0.22.0
func (h *ClearOnVisitHistogramSnapshot) Sample() metrics.Sample
Sample returns the Sample underlying the histogram.
func (*ClearOnVisitHistogramSnapshot) Snapshot ¶ added in v0.22.0
func (h *ClearOnVisitHistogramSnapshot) Snapshot() metrics.Histogram
Snapshot returns the snapshot.
func (*ClearOnVisitHistogramSnapshot) StdDev ¶ added in v0.22.0
func (h *ClearOnVisitHistogramSnapshot) StdDev() float64
StdDev returns the standard deviation of the values in the sample at the time the snapshot was taken.
func (*ClearOnVisitHistogramSnapshot) Sum ¶ added in v0.22.0
func (h *ClearOnVisitHistogramSnapshot) Sum() int64
Sum returns the sum in the sample at the time the snapshot was taken.
func (*ClearOnVisitHistogramSnapshot) Update ¶ added in v0.22.0
func (*ClearOnVisitHistogramSnapshot) Update(int64)
Update panics.
func (*ClearOnVisitHistogramSnapshot) Variance ¶ added in v0.22.0
func (h *ClearOnVisitHistogramSnapshot) Variance() float64
Variance returns the variance of inputs at the time the snapshot was taken.
type GoMetricsRegistry ¶
type GoMetricsRegistry struct {
// contains filtered or unexported fields
}
GoMetricsRegistry wraps a monitoring.Registry for filtering and registering go-metrics based metrics with the monitoring package. GoMetricsRegistry implements the go-metrics.Registry interface.
Note: with the go-metrics using `interface{}`, there is no guarantee
a variable satisfying any of go-metrics interfaces is returned. It's recommended to not mix go-metrics with other metrics types in the same namespace.
func GetGoMetrics ¶
func GetGoMetrics(parent *monitoring.Registry, name string, logger *logp.Logger, filters ...MetricFilter) *GoMetricsRegistry
GetGoMetrics wraps an existing monitoring.Registry with `name` into a GoMetricsRegistry for using the registry with go-metrics.Registry. If the monitoring.Registry does not exist yet, a new one will be generated.
Note: with users of go-metrics potentially removing any metric at runtime,
it's recommended to have the underlying registry being generated with `monitoring.IgnorePublishExpvar`.
func NewGoMetrics ¶
func NewGoMetrics(parent *monitoring.Registry, name string, logger *logp.Logger, filters ...MetricFilter) *GoMetricsRegistry
NewGoMetrics creates and registers a new GoMetricsRegistry with the parent registry.
func (*GoMetricsRegistry) Each ¶
func (r *GoMetricsRegistry) Each(f func(string, interface{}))
Each only iterates the shadowed metrics, not registered to the monitoring package, as those metrics are owned by monitoring.Registry only.
func (*GoMetricsRegistry) Get ¶
func (r *GoMetricsRegistry) Get(name string) interface{}
Get retrieves a registered metric by name. If the name is unknown, Get returns nil.
Note: with the return values being `interface{}`, there is no guarantee
a variable satisfying any of go-metrics interfaces is returned. It's recommended to not mix go-metrics with other metrics types in one namespace.
func (*GoMetricsRegistry) GetAll ¶
func (r *GoMetricsRegistry) GetAll() map[string]map[string]interface{}
GetAll retrieves all registered metrics.
func (*GoMetricsRegistry) GetOrRegister ¶
func (r *GoMetricsRegistry) GetOrRegister(name string, metric interface{}) interface{}
GetOrRegister retries an existing metric via `Get` or registers a new one if the metric is unknown. For lazy instantiation metric can be a function.
func (*GoMetricsRegistry) Register ¶
func (r *GoMetricsRegistry) Register(name string, metric interface{}) error
Register adds a new metric. An error is returned if the metric is already known.
func (*GoMetricsRegistry) RunHealthchecks ¶
func (r *GoMetricsRegistry) RunHealthchecks()
RunHealthchecks is a noop, required to satisfy the metrics.Registry interface.
func (*GoMetricsRegistry) Unregister ¶
func (r *GoMetricsRegistry) Unregister(name string)
Unregister removes a metric.
func (*GoMetricsRegistry) UnregisterAll ¶
func (r *GoMetricsRegistry) UnregisterAll()
UnregisterAll calls `Clear` on the underlying monitoring.Registry
type MetricFilter ¶
type MetricFilter func(*metricFilters) *metricFilters
MetricFilter type used to defined and combine filters.
func ApplyIf ¶
func ApplyIf(pred func(name string) bool, filters ...MetricFilter) MetricFilter
func ModifyName ¶
func ModifyName(f func(string) string) MetricFilter
ModifyName changes a metric its name using the provided function.
func NameReplace ¶
func NameReplace(old, new string) MetricFilter
NameReplace replaces substrings in a metrics names with `new`.
func Rename ¶
func Rename(from, to string) MetricFilter
Rename renames a metric to `to`, if the names matches `from` If the name matches, it will be automatically white-listed.
func ReportIf ¶
func ReportIf(pred func(string) bool) MetricFilter
ReportIf sets variable report mode for all metrics satisfying the predicate.
func ReportNames ¶
func ReportNames(names ...string) MetricFilter
ReportNames enables reporting for all metrics matching any of the given names.
func Whitelist ¶
func Whitelist(names ...string) MetricFilter
Whitelist sets a list of metric names to be accepted.
func WhitelistIf ¶
func WhitelistIf(pred func(string) bool) MetricFilter
WhitelistIf will accept a metric if the metrics name matches the given predicate.