diff --git a/plugins/metrics/autopeering.go b/plugins/metrics/autopeering.go index 36795f4bf818135c1b47cae0c2c0b624f3ed4f05..a94ee57effc9d53f6bc8ea563c3fbbac4bfa7ef4 100644 --- a/plugins/metrics/autopeering.go +++ b/plugins/metrics/autopeering.go @@ -44,12 +44,14 @@ var ( }) ) +// NeighborDropCount returns the neighbor drop count. func NeighborDropCount() uint64 { neighborMutex.RLock() defer neighborMutex.RUnlock() return neighborDropCount } +// AvgNeighborConnectionLifeTime return the average neighbor connection lifetime. func AvgNeighborConnectionLifeTime() float64 { neighborMutex.RLock() defer neighborMutex.RUnlock() @@ -59,12 +61,14 @@ func AvgNeighborConnectionLifeTime() float64 { return float64(neighborConnectionsLifeTime.Milliseconds()) / float64(neighborDropCount) } +// ConnectionsCount returns the neighbors connections count. func ConnectionsCount() uint64 { distanceMutex.RLock() defer distanceMutex.RUnlock() return connectionsCount } +// AutopeeringDistanceStats returns statistics of the autopeering distance function. func AutopeeringDistanceStats() (min, max uint64, avg float64) { distanceMutex.RLock() defer distanceMutex.RUnlock() diff --git a/plugins/metrics/clients_info.go b/plugins/metrics/clients_info.go index b7b792bf8367cb4219b072a884727e533164d94d..14693cba099785b87714392f1386571eb1ae7eb6 100644 --- a/plugins/metrics/clients_info.go +++ b/plugins/metrics/clients_info.go @@ -10,6 +10,7 @@ import ( "go.uber.org/atomic" ) +// ClientInfo holds info of a client. type ClientInfo struct { OS string Arch string diff --git a/plugins/metrics/db.go b/plugins/metrics/db.go index 78a55a0443839be024e6a1c209e8f98833b86923..256914f079411d885f61883c366ebf02e0e430f2 100644 --- a/plugins/metrics/db.go +++ b/plugins/metrics/db.go @@ -19,6 +19,7 @@ var ( }) ) +// DBSize returns the size of the db. func DBSize() uint64 { return dbSize.Load() } diff --git a/plugins/metrics/network.go b/plugins/metrics/network.go index 9ca96d222783f9621573dbc5837d3a1466701266..3a741d5b2ab47f1f2c3226b2ddaeab6e4733d1c8 100644 --- a/plugins/metrics/network.go +++ b/plugins/metrics/network.go @@ -19,22 +19,27 @@ var ( analysisOutboundBytes atomic.Uint64 ) +// FPCInboundBytes returns the total inbound FPC traffic. func FPCInboundBytes() uint64 { return _FPCInboundBytes.Load() } +// FPCOutboundBytes returns the total outbound FPC traffic. func FPCOutboundBytes() uint64 { return _FPCOutboundBytes.Load() } +// GossipInboundBytes returns the total inbound gossip traffic. func GossipInboundBytes() uint64 { return gossipCurrentRx.Load() } +// GossipOutboundBytes returns the total outbound gossip traffic. func GossipOutboundBytes() uint64 { return gossipCurrentTx.Load() } +// AnalysisOutboundBytes returns the total outbound analysis traffic. func AnalysisOutboundBytes() uint64 { return analysisOutboundBytes.Load() } diff --git a/plugins/metrics/parameters.go b/plugins/metrics/parameters.go index b504f77eb3997f31e65f3f51f3d9e3719766cc5d..b26d64f04181f164c17334a3c7dfd41aa07c3fce 100644 --- a/plugins/metrics/parameters.go +++ b/plugins/metrics/parameters.go @@ -8,14 +8,24 @@ import ( const ( // should always be 1 second + + // MPSMeasurementInterval defines the MPS measurement interval MPSMeasurementInterval = 1 * time.Second + // TPSMeasurementInterval defines the TPS measurement interval TPSMeasurementInterval = 1 * time.Second + // can be adjusted as wished + + // MessageTipsMeasurementInterval defines the Communication-layer tips measurement interval MessageTipsMeasurementInterval = 1 * time.Second - ValueTipsMeasurementInterval = 1 * time.Second - CPUUsageMeasurementInterval = 1 * time.Second - MemUsageMeasurementInterval = 1 * time.Second - SyncedMeasurementInterval = 1 * time.Second + // ValueTipsMeasurementInterval defines the Value-layer tips measurement interval + ValueTipsMeasurementInterval = 1 * time.Second + // CPUUsageMeasurementInterval defines the CPU usage measurement interval + CPUUsageMeasurementInterval = 1 * time.Second + // MemUsageMeasurementInterval defines the mem usage measurement interval + MemUsageMeasurementInterval = 1 * time.Second + // SyncedMeasurementInterval defines the synced measurement interval + SyncedMeasurementInterval = 1 * time.Second ) const ( diff --git a/plugins/metrics/process.go b/plugins/metrics/process.go index 10dc44231219f174824d7186b9f681a0c3e5f2f4..4d448be22364744985ba5a85e5c017734f2ef52a 100644 --- a/plugins/metrics/process.go +++ b/plugins/metrics/process.go @@ -14,8 +14,8 @@ var ( memUsageBytes atomic.Uint64 ) -// CpuUsage returns the current cpu usage -func CpuUsage() float64 { +// CPUUsage returns the current cpu usage +func CPUUsage() float64 { return cpuUsage.Load() } diff --git a/plugins/prometheus/process.go b/plugins/prometheus/process.go index c38a433841f4a532a71adf6253df796875c26a2e..46f5adbf59d78b83ecad9b7856a6f5de7ea14d71 100644 --- a/plugins/prometheus/process.go +++ b/plugins/prometheus/process.go @@ -27,6 +27,6 @@ func registerProcessMetrics() { } func collectProcesskMetrics() { - cpuUsage.Set(float64(metrics.CpuUsage())) + cpuUsage.Set(float64(metrics.CPUUsage())) memUsageBytes.Set(float64(metrics.MemUsage())) }