swarm: initial instrumentation (#15969)
* swarm: initial instrumentation with go-metrics * swarm: initialise metrics collection and add ResettingTimer to HTTP requests * swarm: update metrics flags names. remove redundant Timer. * swarm: rename method for periodically updating gauges * swarm: finalise metrics after feedback * swarm/network: always init kad metrics containers * swarm/network: off-by-one index in metrics containers * swarm, metrics: resolved conflicts
This commit is contained in:
committed by
Balint Gabor
parent
b677a07d36
commit
dcca613a0b
@ -23,6 +23,8 @@ import (
|
||||
"io"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/metrics"
|
||||
)
|
||||
|
||||
/*
|
||||
@ -63,6 +65,11 @@ var (
|
||||
errOperationTimedOut = errors.New("operation timed out")
|
||||
)
|
||||
|
||||
//metrics variables
|
||||
var (
|
||||
newChunkCounter = metrics.NewRegisteredCounter("storage.chunks.new", nil)
|
||||
)
|
||||
|
||||
type TreeChunker struct {
|
||||
branches int64
|
||||
hashFunc SwarmHasher
|
||||
@ -298,6 +305,13 @@ func (self *TreeChunker) hashChunk(hasher SwarmHash, job *hashJob, chunkC chan *
|
||||
job.parentWg.Done()
|
||||
|
||||
if chunkC != nil {
|
||||
//NOTE: this increases the chunk count even if the local node already has this chunk;
|
||||
//on file upload the node will increase this counter even if the same file has already been uploaded
|
||||
//So it should be evaluated whether it is worth keeping this counter
|
||||
//and/or actually better track when the chunk is Put to the local database
|
||||
//(which may question the need for disambiguation when a completely new chunk has been created
|
||||
//and/or a chunk is being put to the local DB; for chunk tracking it may be worth distinguishing
|
||||
newChunkCounter.Inc(1)
|
||||
chunkC <- newChunk
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user