adapter

package
v5.6.14+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2018 License: Apache-2.0 Imports: 8 Imported by: 352

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Accept = withVarFilter(func(st state) state {
	st.action = actAccept
	return st
})
View Source
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
})

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

View Source
var ToLowerName = ModifyName(strings.ToLower)

ToLowerName converts all metric names to lower-case

View Source
var ToUpperName = ModifyName(strings.ToUpper)

ToUpperName converts all metric name to upper-case

Functions

func NameIn

func NameIn(names ...string) func(string) bool

NameIn checks a metrics name matching any of the set names

Types

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, 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, 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) 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.

Jump to

Keyboard shortcuts

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