mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 18:02:24 +00:00
cmd/utils: unindent
This commit is contained in:
parent
83b532c4da
commit
f6971a729c
1 changed files with 44 additions and 43 deletions
|
|
@ -1970,58 +1970,59 @@ func RegisterFullSyncTester(stack *node.Node, eth *eth.Ethereum, target common.H
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetupMetrics(cfg *metrics.Config) {
|
func SetupMetrics(cfg *metrics.Config) {
|
||||||
if cfg.Enabled {
|
if !cfg.Enabled {
|
||||||
log.Info("Enabling metrics collection")
|
return
|
||||||
var (
|
}
|
||||||
enableExport = cfg.EnableInfluxDB
|
log.Info("Enabling metrics collection")
|
||||||
enableExportV2 = cfg.EnableInfluxDBV2
|
var (
|
||||||
)
|
enableExport = cfg.EnableInfluxDB
|
||||||
if enableExport && enableExportV2 {
|
enableExportV2 = cfg.EnableInfluxDBV2
|
||||||
Fatalf("Flags %v can't be used at the same time", strings.Join([]string{MetricsEnableInfluxDBFlag.Name, MetricsEnableInfluxDBV2Flag.Name}, ", "))
|
)
|
||||||
|
if enableExport && enableExportV2 {
|
||||||
|
Fatalf("Flags %v can't be used at the same time", strings.Join([]string{MetricsEnableInfluxDBFlag.Name, MetricsEnableInfluxDBV2Flag.Name}, ", "))
|
||||||
|
}
|
||||||
|
if enableExport || enableExportV2 {
|
||||||
|
v1FlagIsSet := cfg.InfluxDBUsername != "" || cfg.InfluxDBPassword != ""
|
||||||
|
v2FlagIsSet := cfg.InfluxDBToken != "" || cfg.InfluxDBOrganization != "" || cfg.InfluxDBBucket != ""
|
||||||
|
|
||||||
|
if enableExport && v2FlagIsSet {
|
||||||
|
Fatalf("Flags --influxdb.metrics.organization, --influxdb.metrics.token, --influxdb.metrics.bucket are only available for influxdb-v2")
|
||||||
|
} else if enableExportV2 && v1FlagIsSet {
|
||||||
|
Fatalf("Flags --influxdb.metrics.username, --influxdb.metrics.password are only available for influxdb-v1")
|
||||||
}
|
}
|
||||||
if enableExport || enableExportV2 {
|
}
|
||||||
v1FlagIsSet := cfg.InfluxDBUsername != "" || cfg.InfluxDBPassword != ""
|
|
||||||
v2FlagIsSet := cfg.InfluxDBToken != "" || cfg.InfluxDBOrganization != "" || cfg.InfluxDBBucket != ""
|
|
||||||
|
|
||||||
if enableExport && v2FlagIsSet {
|
var (
|
||||||
Fatalf("Flags --influxdb.metrics.organization, --influxdb.metrics.token, --influxdb.metrics.bucket are only available for influxdb-v2")
|
endpoint = cfg.InfluxDBEndpoint
|
||||||
} else if enableExportV2 && v1FlagIsSet {
|
database = cfg.InfluxDBDatabase
|
||||||
Fatalf("Flags --influxdb.metrics.username, --influxdb.metrics.password are only available for influxdb-v1")
|
username = cfg.InfluxDBUsername
|
||||||
}
|
password = cfg.InfluxDBPassword
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
token = cfg.InfluxDBToken
|
||||||
endpoint = cfg.InfluxDBEndpoint
|
bucket = cfg.InfluxDBBucket
|
||||||
database = cfg.InfluxDBDatabase
|
organization = cfg.InfluxDBOrganization
|
||||||
username = cfg.InfluxDBUsername
|
)
|
||||||
password = cfg.InfluxDBPassword
|
|
||||||
|
|
||||||
token = cfg.InfluxDBToken
|
if enableExport {
|
||||||
bucket = cfg.InfluxDBBucket
|
tagsMap := SplitTagsFlag(cfg.InfluxDBTags)
|
||||||
organization = cfg.InfluxDBOrganization
|
|
||||||
)
|
|
||||||
|
|
||||||
if enableExport {
|
log.Info("Enabling metrics export to InfluxDB")
|
||||||
tagsMap := SplitTagsFlag(cfg.InfluxDBTags)
|
|
||||||
|
|
||||||
log.Info("Enabling metrics export to InfluxDB")
|
go influxdb.InfluxDBWithTags(metrics.DefaultRegistry, 10*time.Second, endpoint, database, username, password, "geth.", tagsMap)
|
||||||
|
} else if enableExportV2 {
|
||||||
|
tagsMap := SplitTagsFlag(cfg.InfluxDBTags)
|
||||||
|
|
||||||
go influxdb.InfluxDBWithTags(metrics.DefaultRegistry, 10*time.Second, endpoint, database, username, password, "geth.", tagsMap)
|
log.Info("Enabling metrics export to InfluxDB (v2)")
|
||||||
} else if enableExportV2 {
|
|
||||||
tagsMap := SplitTagsFlag(cfg.InfluxDBTags)
|
|
||||||
|
|
||||||
log.Info("Enabling metrics export to InfluxDB (v2)")
|
go influxdb.InfluxDBV2WithTags(metrics.DefaultRegistry, 10*time.Second, endpoint, token, bucket, organization, "geth.", tagsMap)
|
||||||
|
}
|
||||||
|
|
||||||
go influxdb.InfluxDBV2WithTags(metrics.DefaultRegistry, 10*time.Second, endpoint, token, bucket, organization, "geth.", tagsMap)
|
if cfg.HTTP != "" {
|
||||||
}
|
address := net.JoinHostPort(cfg.HTTP, fmt.Sprintf("%d", cfg.Port))
|
||||||
|
log.Info("Enabling stand-alone metrics HTTP endpoint", "address", address)
|
||||||
if cfg.HTTP != "" {
|
exp.Setup(address)
|
||||||
address := net.JoinHostPort(cfg.HTTP, fmt.Sprintf("%d", cfg.Port))
|
} else if cfg.HTTP == "" && cfg.Port != 0 {
|
||||||
log.Info("Enabling stand-alone metrics HTTP endpoint", "address", address)
|
log.Warn(fmt.Sprintf("--%s specified without --%s, metrics server will not start.", MetricsPortFlag.Name, MetricsHTTPFlag.Name))
|
||||||
exp.Setup(address)
|
|
||||||
} else if cfg.HTTP == "" && cfg.Port != 0 {
|
|
||||||
log.Warn(fmt.Sprintf("--%s specified without --%s, metrics server will not start.", MetricsPortFlag.Name, MetricsHTTPFlag.Name))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue