mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-11 14:33:52 +00:00
added service name in config and flags (#238)
This commit is contained in:
parent
78ba316bcb
commit
87f9b91b25
3 changed files with 20 additions and 3 deletions
|
|
@ -38,6 +38,9 @@ type Config struct {
|
||||||
// Chain is the chain to sync with
|
// Chain is the chain to sync with
|
||||||
Chain string `hcl:"chain,optional"`
|
Chain string `hcl:"chain,optional"`
|
||||||
|
|
||||||
|
// Name, or identity of the node
|
||||||
|
Name string `hcl:"name,optional"`
|
||||||
|
|
||||||
// Whitelist is a list of required (block number, hash) pairs to accept
|
// Whitelist is a list of required (block number, hash) pairs to accept
|
||||||
Whitelist map[string]string `hcl:"whitelist,optional"`
|
Whitelist map[string]string `hcl:"whitelist,optional"`
|
||||||
|
|
||||||
|
|
@ -365,6 +368,7 @@ type AccountsConfig struct {
|
||||||
func DefaultConfig() *Config {
|
func DefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
Chain: "mainnet",
|
Chain: "mainnet",
|
||||||
|
Name: Hostname(),
|
||||||
Whitelist: map[string]string{},
|
Whitelist: map[string]string{},
|
||||||
LogLevel: "INFO",
|
LogLevel: "INFO",
|
||||||
DataDir: defaultDataDir(),
|
DataDir: defaultDataDir(),
|
||||||
|
|
@ -885,3 +889,11 @@ func defaultDataDir() string {
|
||||||
return filepath.Join(home, ".bor")
|
return filepath.Join(home, ".bor")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Hostname() string {
|
||||||
|
hostname, err := os.Hostname()
|
||||||
|
if err != nil {
|
||||||
|
return "bor"
|
||||||
|
}
|
||||||
|
return hostname
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,11 @@ func (c *Command) Flags() *flagset.Flagset {
|
||||||
Usage: "Name of the chain to sync",
|
Usage: "Name of the chain to sync",
|
||||||
Value: &c.cliConfig.Chain,
|
Value: &c.cliConfig.Chain,
|
||||||
})
|
})
|
||||||
|
f.StringFlag(&flagset.StringFlag{
|
||||||
|
Name: "name",
|
||||||
|
Usage: "Name/Identity of the node",
|
||||||
|
Value: &c.cliConfig.Name,
|
||||||
|
})
|
||||||
f.StringFlag(&flagset.StringFlag{
|
f.StringFlag(&flagset.StringFlag{
|
||||||
Name: "log-level",
|
Name: "log-level",
|
||||||
Usage: "Set log level for the server",
|
Usage: "Set log level for the server",
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ func NewServer(config *Config) (*Server, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := srv.setupMetrics(config.Telemetry); err != nil {
|
if err := srv.setupMetrics(config.Telemetry, config.Name); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -133,7 +133,7 @@ func (s *Server) Stop() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) setupMetrics(config *TelemetryConfig) error {
|
func (s *Server) setupMetrics(config *TelemetryConfig, serviceName string) error {
|
||||||
metrics.Enabled = config.Enabled
|
metrics.Enabled = config.Enabled
|
||||||
metrics.EnabledExpensive = config.Expensive
|
metrics.EnabledExpensive = config.Expensive
|
||||||
|
|
||||||
|
|
@ -195,7 +195,7 @@ func (s *Server) setupMetrics(config *TelemetryConfig) error {
|
||||||
res, err := resource.New(ctx,
|
res, err := resource.New(ctx,
|
||||||
resource.WithAttributes(
|
resource.WithAttributes(
|
||||||
// the service name used to display traces in backends
|
// the service name used to display traces in backends
|
||||||
semconv.ServiceNameKey.String("bor"), // TODO: use the service name from the config
|
semconv.ServiceNameKey.String(serviceName),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue