Skip to content
Snippets Groups Projects
Unverified Commit a615445b authored by Levente Pap's avatar Levente Pap
Browse files

Fixes after merge

parent a544fc34
Branches
No related tags found
No related merge requests found
package metrics
import (
"go.uber.org/atomic"
)
// ReceivedMessagesPerSecond retrieves the current messages per second number.
func ReceivedMessagesPerSecond() uint64 {
return measuredReceivedMPS.Load()
}
// counter for the received MPS
var mpsReceivedSinceLastMeasurement atomic.Uint64
// measured value of the received MPS
var measuredReceivedMPS atomic.Uint64
// increases the received MPS counter
func increaseReceivedMPSCounter() {
mpsReceivedSinceLastMeasurement.Add(1)
}
// measures the received MPS value
func measureReceivedMPS() {
// sample the current counter value into a measured MPS value
sampledMPS := mpsReceivedSinceLastMeasurement.Load()
// store the measured value
measuredReceivedMPS.Store(sampledMPS)
// reset the counter
mpsReceivedSinceLastMeasurement.Store(0)
// trigger events for outside listeners
Events.ReceivedMPSUpdated.Trigger(sampledMPS)
}
......@@ -21,5 +21,5 @@ func init() {
}
func collectLocalMetrics() {
messagesPerSecond.Set(float64(metrics.ReceivedMessagesPerSecond()))
messagesPerSecond.Set(float64(metrics.MPS()))
}
......@@ -10,7 +10,7 @@ require (
github.com/docker/go-units v0.4.0 // indirect
github.com/drand/drand v0.8.1
github.com/iotaledger/goshimmer v0.1.3
github.com/iotaledger/hive.go v0.0.0-20200610104211-d603429af242
github.com/iotaledger/hive.go v0.0.0-20200615181744-3ab0cddc15cf
github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
github.com/stretchr/testify v1.5.1
)
......
......@@ -148,6 +148,7 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/iotaledger/hive.go v0.0.0-20200610104211-d603429af242 h1:uHMFmfrP6O6lp1lCHT6lpFwHFWYk77V0nUlGbhneQHI=
github.com/iotaledger/hive.go v0.0.0-20200610104211-d603429af242/go.mod h1:zwZhaE4ZeglpTrbmbwdnVPMI5XdRu2RmByi3Qn0ztmU=
github.com/iotaledger/hive.go v0.0.0-20200615181744-3ab0cddc15cf/go.mod h1:zwZhaE4ZeglpTrbmbwdnVPMI5XdRu2RmByi3Qn0ztmU=
github.com/iotaledger/iota.go v1.0.0-beta.9/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8=
github.com/iotaledger/iota.go v1.0.0-beta.14/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment