[#426] cmd/neofs-node: Fix metric option in local storage

`WithMetrics` can't make nil check without reflection so we
have to explicitly check if metrics enabled outside of
engine constructor.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2021-03-16 14:19:32 +03:00 committed by Leonard Lyubich
parent 892b4f4f12
commit 7131e6f339

View file

@ -462,10 +462,12 @@ func (c *cfg) LocalAddress() *network.Address {
func initLocalStorage(c *cfg) {
initShardOptions(c)
ls := engine.New(
engine.WithLogger(c.log),
engine.WithMetrics(c.metricsCollector),
)
engineOpts := []engine.Option{engine.WithLogger(c.log)}
if c.metricsCollector != nil {
engineOpts = append(engineOpts, engine.WithMetrics(c.metricsCollector))
}
ls := engine.New(engineOpts...)
for _, opts := range c.cfgObject.cfgLocalStorage.shardOpts {
id, err := ls.AddShard(opts...)