diff --git a/cmd/collector/main.go b/cmd/collector/main.go index e67ad4447fc..2b38a732951 100644 --- a/cmd/collector/main.go +++ b/cmd/collector/main.go @@ -95,6 +95,9 @@ func main() { c.Start(collectorOpts) svc.RunAndThen(func() { + if err := c.Close(); err != nil { + logger.Error("failed to cleanly close the collector", zap.Error(err)) + } if closer, ok := spanWriter.(io.Closer); ok { err := closer.Close() if err != nil { @@ -102,9 +105,6 @@ func main() { } } - if err := c.Close(); err != nil { - logger.Error("failed to cleanly close the collector", zap.Error(err)) - } }) return nil },