aboutsummaryrefslogtreecommitdiffstats
path: root/swarm/storage/memstore.go
diff options
context:
space:
mode:
authorAnton Evangelatov <anton.evangelatov@gmail.com>2018-02-23 21:19:59 +0800
committerBalint Gabor <balint.g@gmail.com>2018-02-23 21:19:59 +0800
commitdcca613a0b4c6ce56e52f4607cf71f4f1338db8f (patch)
tree298e858e042df9d515aa091a79902ee9bf6d9f7b /swarm/storage/memstore.go
parentb677a07d36c957c4221bae952189559ac0c70537 (diff)
downloaddexon-dcca613a0b4c6ce56e52f4607cf71f4f1338db8f.tar
dexon-dcca613a0b4c6ce56e52f4607cf71f4f1338db8f.tar.gz
dexon-dcca613a0b4c6ce56e52f4607cf71f4f1338db8f.tar.bz2
dexon-dcca613a0b4c6ce56e52f4607cf71f4f1338db8f.tar.lz
dexon-dcca613a0b4c6ce56e52f4607cf71f4f1338db8f.tar.xz
dexon-dcca613a0b4c6ce56e52f4607cf71f4f1338db8f.tar.zst
dexon-dcca613a0b4c6ce56e52f4607cf71f4f1338db8f.zip
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
Diffstat (limited to 'swarm/storage/memstore.go')
-rw-r--r--swarm/storage/memstore.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/swarm/storage/memstore.go b/swarm/storage/memstore.go
index 3cb25ac62..d6be54220 100644
--- a/swarm/storage/memstore.go
+++ b/swarm/storage/memstore.go
@@ -23,6 +23,13 @@ import (
"sync"
"github.com/ethereum/go-ethereum/log"
+ "github.com/ethereum/go-ethereum/metrics"
+)
+
+//metrics variables
+var (
+ memstorePutCounter = metrics.NewRegisteredCounter("storage.db.memstore.put.count", nil)
+ memstoreRemoveCounter = metrics.NewRegisteredCounter("storage.db.memstore.rm.count", nil)
)
const (
@@ -130,6 +137,10 @@ func (s *MemStore) setCapacity(c uint) {
s.capacity = c
}
+func (s *MemStore) Counter() uint {
+ return s.entryCnt
+}
+
// entry (not its copy) is going to be in MemStore
func (s *MemStore) Put(entry *Chunk) {
if s.capacity == 0 {
@@ -145,6 +156,8 @@ func (s *MemStore) Put(entry *Chunk) {
s.accessCnt++
+ memstorePutCounter.Inc(1)
+
node := s.memtree
bitpos := uint(0)
for node.entry == nil {
@@ -289,6 +302,7 @@ func (s *MemStore) removeOldest() {
}
if node.entry.SData != nil {
+ memstoreRemoveCounter.Inc(1)
node.entry = nil
s.entryCnt--
}