swarm: LocalStore metrics
* swarm/shed: remove metrics fields from DB struct * swarm/schunk: add String methods to modes * swarm/storage/localstore: add metrics and traces * swarm/chunk: unknown modes without spaces in String methods * swarm/storage/localstore: remove bin number from pull subscription metrics * swarm/storage/localstore: add resetting time metrics and code improvements
This commit is contained in:
committed by
Anton Evangelatov
parent
993b145f25
commit
c1213bd00c
@@ -18,8 +18,13 @@ package localstore
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/metrics"
|
||||
"github.com/ethereum/go-ethereum/swarm/chunk"
|
||||
"github.com/ethereum/go-ethereum/swarm/spancontext"
|
||||
olog "github.com/opentracing/opentracing-go/log"
|
||||
"github.com/syndtr/goleveldb/leveldb"
|
||||
)
|
||||
|
||||
@@ -27,8 +32,21 @@ import (
|
||||
// chunk represented by the address.
|
||||
// Set is required to implement chunk.Store
|
||||
// interface.
|
||||
func (db *DB) Set(_ context.Context, mode chunk.ModeSet, addr chunk.Address) (err error) {
|
||||
return db.set(mode, addr)
|
||||
func (db *DB) Set(ctx context.Context, mode chunk.ModeSet, addr chunk.Address) (err error) {
|
||||
metricName := fmt.Sprintf("localstore.Set.%s", mode)
|
||||
|
||||
ctx, sp := spancontext.StartSpan(ctx, metricName)
|
||||
defer sp.Finish()
|
||||
sp.LogFields(olog.String("ref", addr.String()), olog.String("mode-set", mode.String()))
|
||||
|
||||
metrics.GetOrRegisterCounter(metricName, nil).Inc(1)
|
||||
defer totalTimeMetric(metricName, time.Now())
|
||||
|
||||
err = db.set(mode, addr)
|
||||
if err != nil {
|
||||
metrics.GetOrRegisterCounter(metricName+".error", nil).Inc(1)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// set updates database indexes for a specific
|
||||
|
Reference in New Issue
Block a user