Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion cmd/shisui/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"slices"
"strings"
"syscall"
"time"

"os"

Expand All @@ -22,6 +23,7 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/internal/flags"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/p2p/discover/portalwire"
"github.com/ethereum/go-ethereum/p2p/enode"
Expand Down Expand Up @@ -78,11 +80,26 @@ var (
utils.PortalDataCapacityFlag,
utils.PortalLogLevelFlag,
}
metricsFlags = []cli.Flag{
utils.MetricsEnabledFlag,
utils.MetricsHTTPFlag,
utils.MetricsPortFlag,
utils.MetricsEnableInfluxDBFlag,
utils.MetricsInfluxDBEndpointFlag,
utils.MetricsInfluxDBDatabaseFlag,
utils.MetricsInfluxDBUsernameFlag,
utils.MetricsInfluxDBPasswordFlag,
utils.MetricsInfluxDBTagsFlag,
utils.MetricsEnableInfluxDBV2Flag,
utils.MetricsInfluxDBTokenFlag,
utils.MetricsInfluxDBBucketFlag,
utils.MetricsInfluxDBOrganizationFlag,
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to add new flags or just use the flags in geth?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! Thanks, I will remove those redundant flags. The only issue is that the flags inherit default value from geth, for instance: --metrics.influxdb.bucket value (default: "geth"). In my opinion it is a very insignificant issue, it worth to do to avoid code redundance.

)

func init() {
app.Action = shisui
app.Flags = flags.Merge(portalProtocolFlags, historyRpcFlags)
app.Flags = flags.Merge(portalProtocolFlags, historyRpcFlags, metricsFlags)
flags.AutoEnvVars(app.Flags, "SHISUI")
}

Expand All @@ -96,6 +113,12 @@ func main() {
func shisui(ctx *cli.Context) error {
setDefaultLogger(ctx.Int(utils.PortalLogLevelFlag.Name))

// Start metrics export if enabled
utils.SetupMetrics(ctx)

// Start system runtime metrics collection
go metrics.CollectProcessMetrics(3 * time.Second)

config, err := getPortalConfig(ctx)
if err != nil {
return nil
Expand Down
20 changes: 20 additions & 0 deletions metrics/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,23 @@ var DefaultConfig = Config{
InfluxDBBucket: "geth",
InfluxDBOrganization: "geth",
}

// ShisuiDefaultConfig is the default config for metrics used in shisui.
var ShisuiDefaultConfig = Config{
Enabled: false,
EnabledExpensive: false,
HTTP: "127.0.0.1",
Port: 6060,
EnableInfluxDB: false,
InfluxDBEndpoint: "http://localhost:8086",
InfluxDBDatabase: "shisui",
InfluxDBUsername: "test",
InfluxDBPassword: "test",
InfluxDBTags: "host=localhost",

// influxdbv2-specific flags
EnableInfluxDBV2: false,
InfluxDBToken: "test",
InfluxDBBucket: "shisui",
InfluxDBOrganization: "shisui",
}