Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ export function getMetrics(
help: 'Number of times we include peers in a topic mesh for random reasons',
labelNames: ['topic']
}),
meshPeerInclusionEventsTotal: register.gauge<{ topic: TopicLabel }>({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can rename these metrics. I think "inclusion/churn" is a bit more confusing than "add/remove"

name: 'gossipsub_mesh_peer_inclusion_events_total',
help: 'Number of times we include peers in a topic mesh for all reasons',
labelNames: ['topic']
}),
meshPeerInclusionEventsSubscribed: register.gauge<{ topic: TopicLabel }>({
name: 'gossipsub_mesh_peer_inclusion_events_subscribed_total',
help: 'Number of times we include peers in a topic mesh for subscribed reasons',
Expand Down Expand Up @@ -240,6 +245,11 @@ export function getMetrics(
}),
/** Number of times we remove peers in a topic mesh for different reasons.
* = rust-libp2p `mesh_peer_churn_events` */
meshPeerChurnEventsTotal: register.gauge<{ topic: TopicLabel }>({
name: 'gossipsub_peer_churn_events_total',
help: 'Number of times we remove peers in a topic mesh for all reasons',
labelNames: ['topic']
}),
meshPeerChurnEventsDisconnected: register.gauge<{ topic: TopicLabel }>({
name: 'gossipsub_peer_churn_events_disconnected_total',
help: 'Number of times we remove peers in a topic mesh for disconnected reasons',
Expand Down Expand Up @@ -700,6 +710,7 @@ export function getMetrics(
/** Register the inclusion of peers in our mesh due to some reason. */
onAddToMesh(topicStr: TopicStr, reason: InclusionReason, count: number): void {
const topic = this.toTopic(topicStr)
this.meshPeerInclusionEventsTotal.inc({ topic }, count)
switch (reason) {
case InclusionReason.Fanout:
this.meshPeerInclusionEventsFanout.inc({ topic }, count)
Expand Down Expand Up @@ -732,6 +743,7 @@ export function getMetrics(
// - on_disconnect() Churn::Ds
onRemoveFromMesh(topicStr: TopicStr, reason: ChurnReason, count: number): void {
const topic = this.toTopic(topicStr)
this.meshPeerChurnEventsTotal.inc({ topic }, count)
switch (reason) {
case ChurnReason.Dc:
this.meshPeerChurnEventsDisconnected.inc({ topic }, count)
Expand Down