Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

Commit

Permalink
Add API to reset bandwidth counters
Browse files Browse the repository at this point in the history
  • Loading branch information
kpp committed Nov 1, 2019
1 parent f94ed8d commit 7dbbdcc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ require (
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550
)

//replace github.com/libp2p/go-flow-metrics v0.0.1 => github.com/kpp/go-flow-metrics v0.0.2-0.20191101005412-ce5ebda5e4a4 // Stebalien's version

replace github.com/libp2p/go-flow-metrics v0.0.1 => github.com/kpp/go-flow-metrics v0.0.2-0.20191031231915-edeb2d90f222 // kpp's version

go 1.12
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 h1:FOOIBWrEkLgmlgGfMuZT83xIwfPDxEI2OHu6xUmJMFE=
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kpp/go-flow-metrics v0.0.2-0.20191031231915-edeb2d90f222 h1:6Pnw+RUnFR7FY6wEQbqFj+aPrp7bMptn02jEAruMPLk=
github.com/kpp/go-flow-metrics v0.0.2-0.20191031231915-edeb2d90f222/go.mod h1:HeoSNUrOJVK1jEpDqVEiUOIXqhbnS27omG0uWU5slZs=
github.com/kpp/go-flow-metrics v0.0.2-0.20191101005412-ce5ebda5e4a4 h1:wZFgH2qCaRIN+wb0B8e2HuI2JzdrLOMvVxU0cqvZB2g=
github.com/kpp/go-flow-metrics v0.0.2-0.20191101005412-ce5ebda5e4a4/go.mod h1:HeoSNUrOJVK1jEpDqVEiUOIXqhbnS27omG0uWU5slZs=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
Expand Down
12 changes: 12 additions & 0 deletions metrics/bandwidth.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,15 @@ func (bwc *BandwidthCounter) GetBandwidthByProtocol() map[protocol.ID]Stats {

return protocols
}

// Reset clears all stats.
func (bwc *BandwidthCounter) Reset() {
bwc.totalIn.Reset()
bwc.totalOut.Reset()

bwc.protocolIn.Clear()
bwc.protocolOut.Clear()

bwc.peerIn.Clear()
bwc.peerOut.Clear()
}

0 comments on commit 7dbbdcc

Please sign in to comment.