Documentation ¶
Index ¶
- Variables
- func GetOrRegisterCounter(name string) metrics.Counter
- func GetOrRegisterGauge(name string) metrics.Gauge
- func GetOrRegisterGaugeFloat64(name string) metrics.GaugeFloat64
- func GetOrRegisterHistogram(name string) metrics.Histogram
- func GetOrRegisterMeter(name string) metrics.Meter
- func GetOrRegisterTimer(name string) metrics.Timer
- func Init(config MetricsConfig)
- func MustInitFromViper()
- type InfluxDbConfig
- type MetricsConfig
Constants ¶
This section is empty.
Variables ¶
var ( // default metrics registry DefaultRegistry = metrics.NewRegistry() )
Functions ¶
func GetOrRegisterCounter ¶
GetOrRegisterCounter gets an existed or registers a new counter from default registry by a specified metrics name.
func GetOrRegisterGauge ¶
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 ¶
GetOrRegisterHistogram gets an existed or registers a new histogram from default registry by a specified metrics name.
func GetOrRegisterMeter ¶
GetOrRegisterMeter gets an existed or registers a new meter from default registry by a specified metrics name.
func GetOrRegisterTimer ¶
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.,