Skip to content
Snippets Groups Projects
Commit caaf3c10 authored by Levente Pap's avatar Levente Pap
Browse files

Refactor DBStats metrics collection, update default params

parent 6877d3bd
Branches
No related tags found
No related merge requests found
...@@ -6,12 +6,15 @@ import ( ...@@ -6,12 +6,15 @@ import (
const ( const (
// CfgMetricsLocal defines the config flag to enable/disable local metrics. // CfgMetricsLocal defines the config flag to enable/disable local metrics.
CfgMetricsLocal = "metrics.local" CfgMetricsLocal = "metrics.local.enable"
// CfgMetricsLocalDB defines the config flag to enable/disable local database metrics.
CfgMetricsLocalDB = "metrics.local.db"
// CfgMetricsGlobal defines the config flag to enable/disable global metrics. // CfgMetricsGlobal defines the config flag to enable/disable global metrics.
CfgMetricsGlobal = "metrics.global" CfgMetricsGlobal = "metrics.global.enable"
) )
func init() { func init() {
flag.Bool(CfgMetricsLocal, true, "include local metrics") flag.Bool(CfgMetricsLocal, true, "include local metrics")
flag.Bool(CfgMetricsLocalDB, false, "include local database metrics")
flag.Bool(CfgMetricsGlobal, false, "include global metrics") flag.Bool(CfgMetricsGlobal, false, "include global metrics")
} }
...@@ -47,7 +47,7 @@ func configure(_ *node.Plugin) { ...@@ -47,7 +47,7 @@ func configure(_ *node.Plugin) {
} }
func run(_ *node.Plugin) { func run(_ *node.Plugin) {
log.Infof("Starting %s ...", PluginName)
if config.Node().GetBool(CfgMetricsLocal) { if config.Node().GetBool(CfgMetricsLocal) {
registerLocalMetrics() registerLocalMetrics()
} }
...@@ -58,7 +58,8 @@ func run(_ *node.Plugin) { ...@@ -58,7 +58,8 @@ func run(_ *node.Plugin) {
} }
// create a background worker that update the metrics every second // create a background worker that update the metrics every second
if err := daemon.BackgroundWorker("Metrics Updater", func(shutdownSignal <-chan struct{}) { if err := daemon.BackgroundWorker("Metrics Updater[1s]", func(shutdownSignal <-chan struct{}) {
defer log.Infof("Stopping Metrics Updater[1s] ... done")
if config.Node().GetBool(CfgMetricsLocal) { if config.Node().GetBool(CfgMetricsLocal) {
timeutil.Ticker(func() { timeutil.Ticker(func() {
measureCPUUsage() measureCPUUsage()
...@@ -68,7 +69,6 @@ func run(_ *node.Plugin) { ...@@ -68,7 +69,6 @@ func run(_ *node.Plugin) {
measureValueTips() measureValueTips()
measureReceivedMPS() measureReceivedMPS()
measureRequestQueueSize() measureRequestQueueSize()
measureDBStats()
// gossip network traffic // gossip network traffic
g := gossipCurrentTraffic() g := gossipCurrentTraffic()
...@@ -79,10 +79,23 @@ func run(_ *node.Plugin) { ...@@ -79,10 +79,23 @@ func run(_ *node.Plugin) {
if config.Node().GetBool(CfgMetricsGlobal) { if config.Node().GetBool(CfgMetricsGlobal) {
timeutil.Ticker(calculateNetworkDiameter, 1*time.Minute, shutdownSignal) timeutil.Ticker(calculateNetworkDiameter, 1*time.Minute, shutdownSignal)
} }
log.Infof("Stopping Metrics Updater[1s] ...")
}, shutdown.PriorityMetrics); err != nil { }, shutdown.PriorityMetrics); err != nil {
log.Panicf("Failed to start as daemon: %s", err) log.Panicf("Failed to start as daemon: %s", err)
} }
if config.Node().GetBool(CfgMetricsLocalDB) {
// create a background worker that updates the db metrics every 20 second
if err := daemon.BackgroundWorker("Metrics Updater[DB]", func(shutdownSignal <-chan struct{}) {
defer log.Infof("Stopping Metrics Updater[DB] ... done")
timeutil.Ticker(func() {
measureDBStats()
}, 20*time.Second, shutdownSignal)
log.Infof("Stopping Metrics Updater[DB] ...")
}, shutdown.PriorityMetrics); err != nil {
log.Panicf("Failed to start as daemon: %s", err)
}
}
} }
func registerLocalMetrics() { func registerLocalMetrics() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment