Skip to content
Snippets Groups Projects
Unverified Commit 8af9f97c authored by capossele's avatar capossele
Browse files

:chart_with_upwards_trend: Start setting prometheus metrics

parent e5a6a2ad
Branches
No related tags found
No related merge requests found
......@@ -202,6 +202,8 @@ func onRoundExecuted(roundStats *vote.RoundStats) {
log.Debugw("Error while writing to connection", "Description", err)
return
}
// trigger AnalysisOutboundBytes event
metrics.Events().AnalysisOutboundBytes.Trigger(uint64(len(data)))
}
}
......
......@@ -14,6 +14,8 @@ var (
previousNeighbors = make(map[identity.ID]gossipTrafficMetric)
gossipOldTx uint32
gossipOldRx uint32
analysisOutboundBytes *uint64
)
func FPCInboundBytes() uint64 {
......@@ -24,6 +26,10 @@ func FPCOutboundBytes() uint64 {
return atomic.LoadUint64(_FPCOutboundBytes)
}
func AnalysisOutboundBytes() uint64 {
return atomic.LoadUint64(analysisOutboundBytes)
}
type gossipTrafficMetric struct {
BytesRead uint32
BytesWritten uint32
......
......@@ -40,6 +40,9 @@ func configure(_ *node.Plugin) {
metrics.Events().FPCOutboundBytes.Attach(events.NewClosure(func(amountBytes uint64) {
atomic.AddUint64(_FPCOutboundBytes, amountBytes)
}))
metrics.Events().AnalysisOutboundBytes.Attach(events.NewClosure(func(amountBytes uint64) {
atomic.AddUint64(analysisOutboundBytes, amountBytes)
}))
metrics.Events().CPUUsage.Attach(events.NewClosure(func(cpuPercent float64) {
cpuLock.Lock()
defer cpuLock.Unlock()
......
package prometheus
import (
"github.com/iotaledger/goshimmer/plugins/metrics"
"github.com/prometheus/client_golang/prometheus"
)
var (
messagesPerSecond prometheus.Gauge
fpcInboundBytes prometheus.Gauge
fpcOutboundBytes prometheus.Gauge
analysisOutboundBytes prometheus.Gauge
)
func init() {
messagesPerSecond = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "iota_messages_per_second",
Help: "Number of messages per second.",
})
// Network
fpcInboundBytes = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "FPC_inbound_bytes",
Help: "FPC RX network traffic [bytes].",
})
fpcOutboundBytes = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "fpc_outbound_bytes",
Help: "FPC TX network traffic [bytes].",
})
analysisOutboundBytes = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "analysis_outbound_bytes",
Help: "Analysis client TX network traffic [bytes].",
})
registry.MustRegister(messagesPerSecond)
registry.MustRegister(fpcInboundBytes)
registry.MustRegister(fpcOutboundBytes)
registry.MustRegister(analysisOutboundBytes)
addCollect(collectLocalMetrics)
}
func collectLocalMetrics() {
messagesPerSecond.Set(float64(metrics.ReceivedMessagesPerSecond()))
fpcInboundBytes.Set(float64(metrics.FPCInboundBytes()))
fpcOutboundBytes.Set(float64(metrics.FPCOutboundBytes()))
analysisOutboundBytes.Set(float64(metrics.AnalysisOutboundBytes()))
}
package prometheus
import (
"github.com/iotaledger/goshimmer/plugins/metrics"
"github.com/prometheus/client_golang/prometheus"
)
var (
messagesPerSecond prometheus.Gauge
)
func init() {
messagesPerSecond = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "iota_messages_per_second",
Help: "Number of messages per second.",
})
registry.MustRegister(messagesPerSecond)
addCollect(collectServer)
}
func collectServer() {
messagesPerSecond.Set(float64(metrics.ReceivedMessagesPerSecond()))
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment