diff options
author | Elad <theman@elad.im> | 2018-12-11 16:21:58 +0800 |
---|---|---|
committer | Anton Evangelatov <anton.evangelatov@gmail.com> | 2018-12-11 16:21:58 +0800 |
commit | bb724080cac9fa36ec6b638cfd5cf0e54bc23362 (patch) | |
tree | 355425051728e3c3dd89565feefc46a81a3302f7 /swarm/storage | |
parent | b2aac658b0e366f128eda5e057e8e1bf5ec4e427 (diff) | |
download | dexon-bb724080cac9fa36ec6b638cfd5cf0e54bc23362.tar dexon-bb724080cac9fa36ec6b638cfd5cf0e54bc23362.tar.gz dexon-bb724080cac9fa36ec6b638cfd5cf0e54bc23362.tar.bz2 dexon-bb724080cac9fa36ec6b638cfd5cf0e54bc23362.tar.lz dexon-bb724080cac9fa36ec6b638cfd5cf0e54bc23362.tar.xz dexon-bb724080cac9fa36ec6b638cfd5cf0e54bc23362.tar.zst dexon-bb724080cac9fa36ec6b638cfd5cf0e54bc23362.zip |
cmd/swarm, metrics, swarm/api/client, swarm/storage, swarm/metrics, swarm/api/http: add instrumentation (#18274)
Diffstat (limited to 'swarm/storage')
-rw-r--r-- | swarm/storage/chunker.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/swarm/storage/chunker.go b/swarm/storage/chunker.go index 40292e88f..cbe65372a 100644 --- a/swarm/storage/chunker.go +++ b/swarm/storage/chunker.go @@ -22,6 +22,7 @@ import ( "fmt" "io" "sync" + "time" "github.com/ethereum/go-ethereum/metrics" ch "github.com/ethereum/go-ethereum/swarm/chunk" @@ -410,10 +411,14 @@ func (r *LazyChunkReader) Size(ctx context.Context, quitC chan bool) (n int64, e log.Debug("lazychunkreader.size", "addr", r.addr) if r.chunkData == nil { + + startTime := time.Now() chunkData, err := r.getter.Get(cctx, Reference(r.addr)) if err != nil { + metrics.GetOrRegisterResettingTimer("lcr.getter.get.err", nil).UpdateSince(startTime) return 0, err } + metrics.GetOrRegisterResettingTimer("lcr.getter.get", nil).UpdateSince(startTime) r.chunkData = chunkData s := r.chunkData.Size() log.Debug("lazychunkreader.size", "key", r.addr, "size", s) @@ -542,8 +547,10 @@ func (r *LazyChunkReader) join(b []byte, off int64, eoff int64, depth int, treeS wg.Add(1) go func(j int64) { childAddress := chunkData[8+j*r.hashSize : 8+(j+1)*r.hashSize] + startTime := time.Now() chunkData, err := r.getter.Get(r.ctx, Reference(childAddress)) if err != nil { + metrics.GetOrRegisterResettingTimer("lcr.getter.get.err", nil).UpdateSince(startTime) log.Debug("lazychunkreader.join", "key", fmt.Sprintf("%x", childAddress), "err", err) select { case errC <- fmt.Errorf("chunk %v-%v not found; key: %s", off, off+treeSize, fmt.Sprintf("%x", childAddress)): @@ -551,6 +558,7 @@ func (r *LazyChunkReader) join(b []byte, off int64, eoff int64, depth int, treeS } return } + metrics.GetOrRegisterResettingTimer("lcr.getter.get", nil).UpdateSince(startTime) if l := len(chunkData); l < 9 { select { case errC <- fmt.Errorf("chunk %v-%v incomplete; key: %s, data length %v", off, off+treeSize, fmt.Sprintf("%x", childAddress), l): |