From 5017907785d63e2283321148dbc3e03bd676afa2 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Thu, 17 Dec 2015 16:38:17 -0500 Subject: [PATCH] Move telemetry metrics up to fix one possible race, but deeper problems in go-metrics can't be solved with this --- command/server.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/command/server.go b/command/server.go index a8c2232f0..fea95fa87 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 {