-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Target metrics #1811
base: main
Are you sure you want to change the base?
Target metrics #1811
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,35 +8,65 @@ import ( | |
"github.com/prometheus/client_golang/prometheus" | ||
) | ||
|
||
const namespace = "gossiper" | ||
|
||
type metrics struct { | ||
txsReceived prometheus.Counter | ||
seenTxsReceived prometheus.Counter | ||
txsGossiped prometheus.Counter | ||
txsReceived prometheus.Counter | ||
seenTxsReceived prometheus.Counter | ||
txsGossiped prometheus.Counter | ||
selectTxsToGossipCount prometheus.Counter | ||
selectTxsToGossipSum prometheus.Gauge | ||
selectedTxsToGossip prometheus.Counter | ||
targetTxsSum prometheus.Gauge | ||
} | ||
|
||
func newMetrics(r prometheus.Registerer) (*metrics, error) { | ||
m := &metrics{ | ||
txsReceived: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: "gossiper", | ||
Namespace: namespace, | ||
Name: "txs_received", | ||
Help: "number of txs received over gossip", | ||
}), | ||
txsGossiped: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: "gossiper", | ||
Namespace: namespace, | ||
Name: "txs_gossiped", | ||
Help: "number of txs gossiped", | ||
}), | ||
seenTxsReceived: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: "gossiper", | ||
Namespace: namespace, | ||
Name: "seen_txs_received", | ||
Help: "number of txs received over gossip that were already seen", | ||
}), | ||
selectTxsToGossipCount: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: namespace, | ||
Name: "select_txs_to_gossip_count", | ||
Help: "number of times gossiper iterates mempool to select txs for gossip", | ||
}), | ||
selectTxsToGossipSum: prometheus.NewGauge(prometheus.GaugeOpts{ | ||
Namespace: namespace, | ||
Name: "select_txs_to_gossip_sum", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's not obvious this + |
||
Help: "sum of time spent iterating mempool to select txs for gossip", | ||
}), | ||
selectedTxsToGossip: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: namespace, | ||
Name: "selected_txs_to_gossip", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we call this |
||
Help: "number of txs selected for gossip", | ||
}), | ||
targetTxsSum: prometheus.NewGauge(prometheus.GaugeOpts{ | ||
Namespace: namespace, | ||
Name: "target_txs_sum", | ||
Help: "sum of time spent selecting target for txs gossip", | ||
}), | ||
} | ||
errs := wrappers.Errs{} | ||
errs.Add( | ||
r.Register(m.txsReceived), | ||
r.Register(m.txsGossiped), | ||
r.Register(m.seenTxsReceived), | ||
r.Register(m.selectTxsToGossipCount), | ||
r.Register(m.selectTxsToGossipSum), | ||
r.Register(m.selectedTxsToGossip), | ||
r.Register(m.targetTxsSum), | ||
) | ||
return m, errs.Err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a specific reason to use a Gauge? I feel like only Inc/Add method are used to represent the metric.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm was just copying how we had handled durations elsewhere. This will never decrease, so we could use a counter instead.