metrics

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// default metrics registry
	DefaultRegistry = metrics.NewRegistry()
)

Functions

func GetOrRegisterCounter

func GetOrRegisterCounter(name string) metrics.Counter

GetOrRegisterCounter gets an existed or registers a new counter from default registry by a specified metrics name.

func GetOrRegisterGauge

func GetOrRegisterGauge(name string) metrics.Gauge

GetOrRegisterGauge gets an existed or registers a new gauge from default registry by a specified metrics name.

func GetOrRegisterGaugeFloat64

func GetOrRegisterGaugeFloat64(name string) metrics.GaugeFloat64

GetOrRegisterGaugeFloat64 gets an existed or registers a new gauge from default registry by a specified metrics name.

func GetOrRegisterHistogram

func GetOrRegisterHistogram(name string) metrics.Histogram

GetOrRegisterHistogram gets an existed or registers a new histogram from default registry by a specified metrics name.

func GetOrRegisterMeter

func GetOrRegisterMeter(name string) metrics.Meter

GetOrRegisterMeter gets an existed or registers a new meter from default registry by a specified metrics name.

func GetOrRegisterTimer

func GetOrRegisterTimer(name string) metrics.Timer

GetOrRegisterTimer gets an existed or registers a new timer from default registry by a specified metrics name.

func Init

func Init(config MetricsConfig)

Init inits metrics with provided metrics configurations.

func MustInitFromViper

func MustInitFromViper()

MustInitFromViper inits metrics from viper settings. This should be called before any metric (e.g. timer, histogram) created. Because `metrics.Enabled` in go-ethereum is `false` by default, which leads to noop metric created for static variables in any package.

Note that viper must be initialized before this, otherwise metrics settings may not be loaded correctly. Besides, this init will panic and exit if any error happens.

Types

type InfluxDbConfig

type InfluxDbConfig struct {
	// host path
	Host string `default:"http://127.0.0.1:8086"`
	// database name
	Db string `default:"metrics_db"`
	// authenticated username
	Username string
	// authenticated password
	Password string
}

InfluxDbConfig influxdb configurations.

type MetricsConfig

type MetricsConfig struct {
	// switch to turn on or off metrics
	Enabled bool
	// namespace for metrics reporting
	Namespace string
	// interval to report metrics to influxdb
	ReportInterval time.Duration `default:"10s"`
	// settings for influxdb to be reported to
	InfluxDb *InfluxDbConfig
}

MetricsConfig metrics configurations such as influxdb settings.,

Jump to

Keyboard shortcuts

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