forked from TrueCloudLab/frostfs-node
[#1410] engine: Provide the default implementation to MetricsRegister
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
9206ce5cd2
commit
9a87acb87a
11 changed files with 77 additions and 55 deletions
|
@ -116,9 +116,7 @@ func (e *StorageEngine) AddShard(ctx context.Context, opts ...shard.Option) (*sh
|
|||
return nil, fmt.Errorf("could not add %s shard: %w", sh.ID().String(), err)
|
||||
}
|
||||
|
||||
if e.cfg.metrics != nil {
|
||||
e.cfg.metrics.SetMode(sh.ID().String(), sh.GetMode())
|
||||
}
|
||||
e.cfg.metrics.SetMode(sh.ID().String(), sh.GetMode())
|
||||
|
||||
return sh.ID(), nil
|
||||
}
|
||||
|
@ -152,28 +150,26 @@ func (e *StorageEngine) appendMetrics(id *shard.ID, opts []shard.Option) []shard
|
|||
e.mtx.RLock()
|
||||
defer e.mtx.RUnlock()
|
||||
|
||||
if e.metrics != nil {
|
||||
opts = append(opts,
|
||||
shard.WithMetricsWriter(
|
||||
&metricsWithID{
|
||||
id: id.String(),
|
||||
mw: e.metrics,
|
||||
},
|
||||
),
|
||||
shard.WithWriteCacheMetrics(
|
||||
&writeCacheMetrics{
|
||||
shardID: id.String(),
|
||||
metrics: e.metrics.WriteCache(),
|
||||
},
|
||||
),
|
||||
shard.WithGCMetrics(
|
||||
&gcMetrics{
|
||||
storage: e.metrics.GC(),
|
||||
shardID: id.String(),
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
opts = append(opts,
|
||||
shard.WithMetricsWriter(
|
||||
&metricsWithID{
|
||||
id: id.String(),
|
||||
mw: e.metrics,
|
||||
},
|
||||
),
|
||||
shard.WithWriteCacheMetrics(
|
||||
&writeCacheMetrics{
|
||||
shardID: id.String(),
|
||||
metrics: e.metrics.WriteCache(),
|
||||
},
|
||||
),
|
||||
shard.WithGCMetrics(
|
||||
&gcMetrics{
|
||||
storage: e.metrics.GC(),
|
||||
shardID: id.String(),
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
return opts
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue