Move telemetry metrics up to fix one possible race, but deeper problems in go-metrics can't be solved with this

This commit is contained in:
Jeff Mitchell 2015-12-17 16:38:17 -05:00
parent 3145b666c3
commit 5017907785
1 changed files with 8 additions and 6 deletions

View File

@ -104,6 +104,14 @@ func (c *ServerCommand) Run(args []string) int {
Writer: logGate,
}, "", log.LstdFlags)
// Initialize telemetry; if this is done after the core is created,
// because we are using a global telemetry object, it can be a data
// race between writing metrics from core and the object being set
if err := c.setupTelementry(config); err != nil {
c.Ui.Error(fmt.Sprintf("Error initializing telemetry: %s", err))
return 1
}
// Initialize the backend
backend, err := physical.NewBackend(
config.Backend.Type, config.Backend.Config)
@ -233,12 +241,6 @@ func (c *ServerCommand) Run(args []string) int {
}
}
// Initialize the telemetry
if err := c.setupTelementry(config); err != nil {
c.Ui.Error(fmt.Sprintf("Error initializing telemetry: %s", err))
return 1
}
// Initialize the listeners
lns := make([]net.Listener, 0, len(config.Listeners))
for i, lnConfig := range config.Listeners {