From 7131e6f3392e4a4cb7e7234a552322732a556fc8 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Tue, 16 Mar 2021 14:19:32 +0300 Subject: [PATCH] [#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 --- cmd/neofs-node/config.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index 6bd971a4b6..9afd42e6bb 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -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...)