diff --git a/command/server.go b/command/server.go index a8c2232f02..fea95fa870 100644 --- a/command/server.go +++ b/command/server.go @@ -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 {