[#1863] node: Fix shard id in the object counter metrics
If shard ID is stored in metabase (it is not the first time boot), read it, set it, use it (not a generated one) in the metrics writer. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
8714fc42b5
commit
31c623636d
5 changed files with 21 additions and 5 deletions
|
@ -23,19 +23,25 @@ type metricsWithID struct {
|
|||
mw MetricRegister
|
||||
}
|
||||
|
||||
func (m metricsWithID) SetObjectCounter(objectType string, v uint64) {
|
||||
func (m *metricsWithID) SetShardID(id string) {
|
||||
// concurrent settings are not expected =>
|
||||
// no mutex protection
|
||||
m.id = id
|
||||
}
|
||||
|
||||
func (m *metricsWithID) SetObjectCounter(objectType string, v uint64) {
|
||||
m.mw.SetObjectCounter(m.id, objectType, v)
|
||||
}
|
||||
|
||||
func (m metricsWithID) AddToObjectCounter(objectType string, delta int) {
|
||||
func (m *metricsWithID) AddToObjectCounter(objectType string, delta int) {
|
||||
m.mw.AddToObjectCounter(m.id, objectType, delta)
|
||||
}
|
||||
|
||||
func (m metricsWithID) IncObjectCounter(objectType string) {
|
||||
func (m *metricsWithID) IncObjectCounter(objectType string) {
|
||||
m.mw.AddToObjectCounter(m.id, objectType, +1)
|
||||
}
|
||||
|
||||
func (m metricsWithID) DecObjectCounter(objectType string) {
|
||||
func (m *metricsWithID) DecObjectCounter(objectType string) {
|
||||
m.mw.AddToObjectCounter(m.id, objectType, -1)
|
||||
}
|
||||
|
||||
|
@ -67,7 +73,7 @@ func (e *StorageEngine) createShard(opts []shard.Option) (*shard.Shard, error) {
|
|||
|
||||
if e.metrics != nil {
|
||||
opts = append(opts, shard.WithMetricsWriter(
|
||||
metricsWithID{
|
||||
&metricsWithID{
|
||||
id: id.String(),
|
||||
mw: e.metrics,
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue