From 2b94895601c6fe3705d48132896fb5f49a8ddfff Mon Sep 17 00:00:00 2001 From: Hussam Date: Mon, 2 Oct 2023 17:25:49 -0500 Subject: [PATCH] Enhancements --- cmd/go-quai/chaincmd.go | 8 ----- cmd/go-quai/config.go | 18 ---------- cmd/go-quai/main.go | 9 ----- cmd/utils/flags.go | 73 --------------------------------------- core/tx_pool.go | 46 ++++++++++++------------ eth/downloader/metrics.go | 21 ----------- 6 files changed, 23 insertions(+), 152 deletions(-) delete mode 100644 eth/downloader/metrics.go diff --git a/cmd/go-quai/chaincmd.go b/cmd/go-quai/chaincmd.go index cfb935ba25..1a4fd5c3bf 100644 --- a/cmd/go-quai/chaincmd.go +++ b/cmd/go-quai/chaincmd.go @@ -90,12 +90,6 @@ The dumpgenesis command dumps the genesis block configuration in JSON format to utils.MetricsEnabledExpensiveFlag, utils.MetricsHTTPFlag, utils.MetricsPortFlag, - utils.MetricsEnableInfluxDBFlag, - utils.MetricsInfluxDBEndpointFlag, - utils.MetricsInfluxDBDatabaseFlag, - utils.MetricsInfluxDBUsernameFlag, - utils.MetricsInfluxDBPasswordFlag, - utils.MetricsInfluxDBTagsFlag, utils.TxLookupLimitFlag, }, Category: "BLOCKCHAIN COMMANDS", @@ -227,8 +221,6 @@ func importChain(ctx *cli.Context) error { if len(ctx.Args()) < 1 { utils.Fatalf("This command requires an argument.") } - // Start system runtime metrics collection - // go metrics_config.StartProcessMetrics() stack, _ := makeConfigNode(ctx) defer stack.Close() diff --git a/cmd/go-quai/config.go b/cmd/go-quai/config.go index 41ed3a95b3..9cbf36ee29 100644 --- a/cmd/go-quai/config.go +++ b/cmd/go-quai/config.go @@ -206,24 +206,6 @@ func applyMetricConfig(ctx *cli.Context, cfg *quaiConfig) { if ctx.GlobalIsSet(utils.MetricsPortFlag.Name) { cfg.Metrics.Port = ctx.GlobalInt(utils.MetricsPortFlag.Name) } - if ctx.GlobalIsSet(utils.MetricsEnableInfluxDBFlag.Name) { - cfg.Metrics.EnableInfluxDB = ctx.GlobalBool(utils.MetricsEnableInfluxDBFlag.Name) - } - if ctx.GlobalIsSet(utils.MetricsInfluxDBEndpointFlag.Name) { - cfg.Metrics.InfluxDBEndpoint = ctx.GlobalString(utils.MetricsInfluxDBEndpointFlag.Name) - } - if ctx.GlobalIsSet(utils.MetricsInfluxDBDatabaseFlag.Name) { - cfg.Metrics.InfluxDBDatabase = ctx.GlobalString(utils.MetricsInfluxDBDatabaseFlag.Name) - } - if ctx.GlobalIsSet(utils.MetricsInfluxDBUsernameFlag.Name) { - cfg.Metrics.InfluxDBUsername = ctx.GlobalString(utils.MetricsInfluxDBUsernameFlag.Name) - } - if ctx.GlobalIsSet(utils.MetricsInfluxDBPasswordFlag.Name) { - cfg.Metrics.InfluxDBPassword = ctx.GlobalString(utils.MetricsInfluxDBPasswordFlag.Name) - } - if ctx.GlobalIsSet(utils.MetricsInfluxDBTagsFlag.Name) { - cfg.Metrics.InfluxDBTags = ctx.GlobalString(utils.MetricsInfluxDBTagsFlag.Name) - } } func deprecated(field string) bool { diff --git a/cmd/go-quai/main.go b/cmd/go-quai/main.go index 89b1a6a18a..3ad338c60a 100644 --- a/cmd/go-quai/main.go +++ b/cmd/go-quai/main.go @@ -157,15 +157,9 @@ var ( } metricsFlags = []cli.Flag{ - utils.MetricsEnableInfluxDBFlag, utils.MetricsEnabledExpensiveFlag, utils.MetricsEnabledFlag, utils.MetricsHTTPFlag, - utils.MetricsInfluxDBDatabaseFlag, - utils.MetricsInfluxDBEndpointFlag, - utils.MetricsInfluxDBPasswordFlag, - utils.MetricsInfluxDBTagsFlag, - utils.MetricsInfluxDBUsernameFlag, utils.MetricsPortFlag, } ) @@ -253,9 +247,6 @@ func prepare(ctx *cli.Context) { ctx.GlobalSet(utils.CacheFlag.Name, strconv.Itoa(128)) } - // Start metrics export if enabled - // utils.SetupMetrics(ctx) - // Start system runtime metrics collection if ctx.GlobalIsSet(utils.MetricsEnabledFlag.Name) { log.Info("Starting metrics") diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 565e1d36ce..5be43573b0 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -582,31 +582,6 @@ var ( Usage: "Metrics HTTP server listening port", Value: metrics_config.DefaultConfig.Port, } - MetricsEnableInfluxDBFlag = cli.BoolFlag{ - Name: "metrics.influxdb", - Usage: "Enable metrics export/push to an external InfluxDB database", - } - MetricsInfluxDBEndpointFlag = cli.StringFlag{ - Name: "metrics.influxdb.endpoint", - Usage: "InfluxDB API endpoint to report metrics to", - Value: metrics_config.DefaultConfig.InfluxDBEndpoint, - } - MetricsInfluxDBDatabaseFlag = cli.StringFlag{ - Name: "metrics.influxdb.database", - Usage: "InfluxDB database name to push reported metrics to", - Value: metrics_config.DefaultConfig.InfluxDBDatabase, - } - MetricsInfluxDBUsernameFlag = cli.StringFlag{ - Name: "metrics.influxdb.username", - Usage: "Username to authorize access to the database", - Value: metrics_config.DefaultConfig.InfluxDBUsername, - } - MetricsInfluxDBPasswordFlag = cli.StringFlag{ - Name: "metrics.influxdb.password", - Usage: "Password to authorize access to the database", - Value: metrics_config.DefaultConfig.InfluxDBPassword, - } - // Output flags ShowColorsFlag = cli.BoolFlag{ Name: "showcolors", @@ -618,16 +593,6 @@ var ( Usage: "Write log messages to stdout", } - // Tags are part of every measurement sent to InfluxDB. Queries on tags are faster in InfluxDB. - // For example `host` tag could be used so that we can group all nodes and average a measurement - // across all of them, but also so that we can select a specific node and inspect its measurements. - // https://docs.influxdata.com/influxdb/v1.4/concepts/key_concepts/#tag-key - MetricsInfluxDBTagsFlag = cli.StringFlag{ - Name: "metrics.influxdb.tags", - Usage: "Comma-separated InfluxDB tags (key/values) attached to all measurements", - Value: metrics_config.DefaultConfig.InfluxDBTags, - } - RegionFlag = cli.IntFlag{ Name: "region", Usage: "Quai Region flag", @@ -1637,44 +1602,6 @@ func RegisterQuaiStatsService(stack *node.Node, backend quaiapi.Backend, url str } } -// func SetupMetrics(ctx *cli.Context) { -// if metrics_config.Enabled { -// log.Info("Enabling metrics collection") - -// var ( -// enableExport = ctx.GlobalBool(MetricsEnableInfluxDBFlag.Name) -// endpoint = ctx.GlobalString(MetricsInfluxDBEndpointFlag.Name) -// database = ctx.GlobalString(MetricsInfluxDBDatabaseFlag.Name) -// username = ctx.GlobalString(MetricsInfluxDBUsernameFlag.Name) -// password = ctx.GlobalString(MetricsInfluxDBPasswordFlag.Name) -// ) - -// if enableExport { -// tagsMap := SplitTagsFlag(ctx.GlobalString(MetricsInfluxDBTagsFlag.Name)) - -// log.Info("Enabling metrics export to InfluxDB") - -// go influxdb.InfluxDBWithTags(metrics.DefaultRegistry, 10*time.Second, endpoint, database, username, password, "quai.", tagsMap, false) -// } - -// if ctx.GlobalIsSet(MetricsHTTPFlag.Name) { -// address := fmt.Sprintf("%s:%d", ctx.GlobalString(MetricsHTTPFlag.Name), ctx.GlobalInt(MetricsPortFlag.Name)) -// log.Info("Enabling stand-alone metrics HTTP endpoint", "address", address) -// // exp.Setup(address) -// m := http.NewServeMux() -// // m.Handle("/debug/metrics", exp.ExpHandler(metrics.DefaultRegistry)) -// // m.Handle("/debug/metrics/prometheus", prometheus.Handler(metrics.DefaultRegistry)) -// m.Handle("/debug/metrics/prometheus", prometheus.Handler()) -// log.Info("Starting metrics server", "addr", fmt.Sprintf("http://%s/debug/metrics", address)) -// go func() { -// if err := http.ListenAndServe(address, m); err != nil { -// log.Error("Failure in running metrics server", "err", err) -// } -// }() -// } -// } -// } - func SplitTagsFlag(tagsFlag string) map[string]string { tags := strings.Split(tagsFlag, ",") tagsMap := map[string]string{} diff --git a/core/tx_pool.go b/core/tx_pool.go index da897d9340..77097ad5d7 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -287,29 +287,29 @@ type newSender struct { // transactions from the network. func NewTxPool(config TxPoolConfig, chainconfig *params.ChainConfig, chain blockChain) *TxPool { - // // Pending pool metrics - // pendingDiscardMeter.Set(0) - // pendingReplaceMeter.Set(0) - // pendingRateLimitMeter.Set(0) - // pendingNofundsMeter.Set(0) - - // // Metrics for the queued pool - // queuedDiscardMeter.Set(0) - // queuedReplaceMeter.Set(0) - // queuedRateLimitMeter.Set(0) - // queuedNofundsMeter.Set(0) - // queuedEvictionMeter.Set(0) - - // // General tx metrics - // knownTxMeter.Set(0) - // validTxMeter.Set(0) - // invalidTxMeter.Set(0) - // underpricedTxMeter.Set(0) - // overflowedTxMeter.Set(0) - - // pendingGauge.Set(0) - // queuedGauge.Set(0) - // localGauge.Set(0) + // Pending pool metrics + pendingDiscardMeter.Set(0) + pendingReplaceMeter.Set(0) + pendingRateLimitMeter.Set(0) + pendingNofundsMeter.Set(0) + + // Metrics for the queued pool + queuedDiscardMeter.Set(0) + queuedReplaceMeter.Set(0) + queuedRateLimitMeter.Set(0) + queuedNofundsMeter.Set(0) + queuedEvictionMeter.Set(0) + + // General tx metrics + knownTxMeter.Set(0) + validTxMeter.Set(0) + invalidTxMeter.Set(0) + underpricedTxMeter.Set(0) + overflowedTxMeter.Set(0) + + pendingGauge.Set(0) + queuedGauge.Set(0) + localGauge.Set(0) // Sanitize the input to ensure no vulnerable gas prices are set config = (&config).sanitize() diff --git a/eth/downloader/metrics.go b/eth/downloader/metrics.go deleted file mode 100644 index b026432bf7..0000000000 --- a/eth/downloader/metrics.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -// Contains the metrics collected by the downloader. - -package downloader - -var ()