mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 23:26:44 +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 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 map[string]string `hcl:"whitelist,optional"`
|
||||
|
||||
|
|
@ -365,6 +368,7 @@ type AccountsConfig struct {
|
|||
func DefaultConfig() *Config {
|
||||
return &Config{
|
||||
Chain: "mainnet",
|
||||
Name: Hostname(),
|
||||
Whitelist: map[string]string{},
|
||||
LogLevel: "INFO",
|
||||
DataDir: defaultDataDir(),
|
||||
|
|
@ -885,3 +889,11 @@ func defaultDataDir() string {
|
|||
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",
|
||||
Value: &c.cliConfig.Chain,
|
||||
})
|
||||
f.StringFlag(&flagset.StringFlag{
|
||||
Name: "name",
|
||||
Usage: "Name/Identity of the node",
|
||||
Value: &c.cliConfig.Name,
|
||||
})
|
||||
f.StringFlag(&flagset.StringFlag{
|
||||
Name: "log-level",
|
||||
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
|
||||
}
|
||||
|
||||
|
|
@ -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.EnabledExpensive = config.Expensive
|
||||
|
||||
|
|
@ -195,7 +195,7 @@ func (s *Server) setupMetrics(config *TelemetryConfig) error {
|
|||
res, err := resource.New(ctx,
|
||||
resource.WithAttributes(
|
||||
// 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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue