Skip to content

Commit

Permalink
feat: added gauge metric for tracking ignored duplicate messages (Cha…
Browse files Browse the repository at this point in the history
  • Loading branch information
maschad committed Feb 15, 2023
1 parent 64780ed commit 6c8c0c2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2022,6 +2022,7 @@ export class GossipSub extends EventEmitter<GossipsubEvents> implements PubSub<G
// This message has already been seen. We don't re-publish messages that have already
// been published on the network.
if (ignoreDuplicateMessages) {
this.metrics?.onIgnoreDuplicateMsg(topic)
return { recipients: [] }
}
throw Error('PublishError.Duplicate')
Expand Down
11 changes: 11 additions & 0 deletions src/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,12 @@ export function getMetrics(
labelNames: ['topic']
}),

duplicateMsgIgnored: register.gauge<{ topic: TopicLabel }>({
name: 'gossisub_duplicate_msg_ignored_total',
help: 'Total count of duplicate message ignored by topic',
labelNames: ['topic']
}),

/* Metrics related to scoring */
/** Total times score() is called */
scoreFnCalls: register.gauge({
Expand Down Expand Up @@ -629,6 +635,11 @@ export function getMetrics(
}
},

onIgnoreDuplicateMsg(topicStr: TopicStr): void {
const topic = this.toTopic(topicStr)
this.duplicateMsgIgnored.inc({ topic }, 1)
},

onRpcRecv(rpc: IRPC, rpcBytes: number): void {
this.rpcRecvBytes.inc(rpcBytes)
this.rpcRecvCount.inc(1)
Expand Down

0 comments on commit 6c8c0c2

Please sign in to comment.