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

:chart_with_upwards_trend: Prometheus FPC data collection

parent 5d5ef57c
No related branches found
No related tags found
No related merge requests found
...@@ -41,7 +41,7 @@ func FailedConflicts() uint64 { ...@@ -41,7 +41,7 @@ func FailedConflicts() uint64 {
return atomic.LoadUint64(&failedConflictCount) return atomic.LoadUint64(&failedConflictCount)
} }
// AverageRoundsToFinalize returns the average number fo rounds it takes to finalize conflicts since the start of the node. // AverageRoundsToFinalize returns the average number of rounds it takes to finalize conflicts since the start of the node.
func AverageRoundsToFinalize() float64 { func AverageRoundsToFinalize() float64 {
avLock.RLock() avLock.RLock()
defer avLock.RUnlock() defer avLock.RUnlock()
......
...@@ -11,7 +11,7 @@ import ( ...@@ -11,7 +11,7 @@ import (
func TestActiveConflicts(t *testing.T) { func TestActiveConflicts(t *testing.T) {
// initialized to 0 // initialized to 0
assert.Equal(t, ActiveConflicts(), (uint64)(0)) assert.Equal(t, ActiveConflicts(), (uint64)(0))
stats := vote.RoundStats{ stats := &vote.RoundStats{
ActiveVoteContexts: map[string]*vote.Context{ ActiveVoteContexts: map[string]*vote.Context{
"test1": &vote.Context{}, "test1": &vote.Context{},
"test2": &vote.Context{}, "test2": &vote.Context{},
......
package prometheus
import (
"github.com/iotaledger/goshimmer/plugins/metrics"
"github.com/prometheus/client_golang/prometheus"
)
var (
activeConflicts prometheus.Gauge
finalizedConflicts prometheus.Gauge
failedConflicts prometheus.Gauge
avgRoundToFin prometheus.Gauge
queryRx prometheus.Gauge
queryOpRx prometheus.Gauge
queryReplyNotRx prometheus.Gauge
queryOpReplyNotRx prometheus.Gauge
)
func init() {
activeConflicts = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "fpc_active_conflicts",
Help: "number of currently active conflicts",
})
finalizedConflicts = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "fpc_finalized_conflicts",
Help: "number of finalized conflicts since the start of the node",
})
failedConflicts = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "fpc_failed_conflicts",
Help: "number of failed conflicts since the start of the node",
})
avgRoundToFin = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "fpc_avg_rounds_to_finalize",
Help: "average number of rounds it takes to finalize conflicts since the start of the node",
})
queryRx = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "fpc_queries_received",
Help: "number of received voting queries",
})
queryOpRx = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "fpc_queries_opinion_received",
Help: " number of received opinion queries",
})
queryReplyNotRx = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "fpc_query_replies_not_received",
Help: "number of sent but unanswered queries for conflict opinions",
})
queryOpReplyNotRx = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "fpc_query_opinion_replies_not_received",
Help: " number of opinions that the node failed to gather from peers",
})
registry.MustRegister(activeConflicts)
registry.MustRegister(finalizedConflicts)
registry.MustRegister(failedConflicts)
registry.MustRegister(avgRoundToFin)
registry.MustRegister(queryRx)
registry.MustRegister(queryOpRx)
registry.MustRegister(queryReplyNotRx)
registry.MustRegister(queryOpReplyNotRx)
addCollect(collectFPCMetrics)
}
func collectFPCMetrics() {
activeConflicts.Set(float64(metrics.ActiveConflicts()))
finalizedConflicts.Set(float64(metrics.FinalizedConflict()))
failedConflicts.Set(float64(metrics.FailedConflicts()))
avgRoundToFin.Set(metrics.AverageRoundsToFinalize())
queryRx.Set(float64(metrics.FPCQueryReceived()))
queryOpRx.Set(float64(metrics.FPCOpinionQueryReceived()))
queryReplyNotRx.Set(float64(metrics.FPCQueryReplyErrors()))
queryOpReplyNotRx.Set(float64(metrics.FPCOpinionQueryReplyErrors()))
}
package prometheus
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment