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,9 +18,14 @@ 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/shed"
|
||||
"github.com/ethereum/go-ethereum/swarm/spancontext"
|
||||
olog "github.com/opentracing/opentracing-go/log"
|
||||
"github.com/syndtr/goleveldb/leveldb"
|
||||
)
|
||||
|
||||
@@ -28,8 +33,21 @@ import (
|
||||
// on the Putter mode, it updates required indexes.
|
||||
// Put is required to implement chunk.Store
|
||||
// interface.
|
||||
func (db *DB) Put(_ context.Context, mode chunk.ModePut, ch chunk.Chunk) (exists bool, err error) {
|
||||
return db.put(mode, chunkToItem(ch))
|
||||
func (db *DB) Put(ctx context.Context, mode chunk.ModePut, ch chunk.Chunk) (exists bool, err error) {
|
||||
metricName := fmt.Sprintf("localstore.Put.%s", mode)
|
||||
|
||||
ctx, sp := spancontext.StartSpan(ctx, metricName)
|
||||
defer sp.Finish()
|
||||
sp.LogFields(olog.String("ref", ch.Address().String()), olog.String("mode-put", mode.String()))
|
||||
|
||||
metrics.GetOrRegisterCounter(metricName, nil).Inc(1)
|
||||
defer totalTimeMetric(metricName, time.Now())
|
||||
|
||||
exists, err = db.put(mode, chunkToItem(ch))
|
||||
if err != nil {
|
||||
metrics.GetOrRegisterCounter(metricName+".error", nil).Inc(1)
|
||||
}
|
||||
return exists, err
|
||||
}
|
||||
|
||||
// put stores Item to database and updates other
|
||||
|
||||
Reference in New Issue
Block a user