Skip to content

Commit 10eae93

Browse files
committed
Increase resolution of delay metrics
1 parent ca7733f commit 10eae93

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

ts/metrics.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -341,16 +341,24 @@ export function getMetrics(
341341
labelNames: ['topic', 'error']
342342
}),
343343
/** Track duplicate message delivery time */
344-
duplicateMsgDelivery: register.histogram<{ topic: TopicLabel }>({
344+
duplicateMsgDeliveryDelay: register.histogram({
345345
name: 'gossisub_duplicate_msg_delivery_delay_seconds',
346346
help: 'Time since the 1st duplicated message validated',
347347
labelNames: ['topic'],
348348
buckets: [
349+
0.25 * opts.minMeshMessageDeliveriesWindow,
349350
0.5 * opts.minMeshMessageDeliveriesWindow,
350351
1 * opts.minMeshMessageDeliveriesWindow,
351-
2 * opts.minMeshMessageDeliveriesWindow
352+
2 * opts.minMeshMessageDeliveriesWindow,
353+
4 * opts.minMeshMessageDeliveriesWindow
352354
]
353355
}),
356+
/** Total count of late msg delivery total by topic */
357+
duplicateMsgLateDelivery: register.gauge<{ topic: TopicLabel }>({
358+
name: 'gossisub_duplicate_msg_late_delivery_total',
359+
help: 'Total count of late duplicate message delivery by topic, which triggers P3 penalty',
360+
labelNames: ['topic']
361+
}),
354362

355363
/* Metrics related to scoring */
356364
/** Total times score() is called */
@@ -403,9 +411,11 @@ export function getMetrics(
403411
name: 'gossipsub_peer_stat_behaviour_penalty',
404412
help: 'Current peer stat behaviour_penalty at each scrape',
405413
buckets: [
414+
0.25 * opts.behaviourPenaltyThreshold,
406415
0.5 * opts.behaviourPenaltyThreshold,
407416
1 * opts.behaviourPenaltyThreshold,
408-
2 * opts.behaviourPenaltyThreshold
417+
2 * opts.behaviourPenaltyThreshold,
418+
4 * opts.behaviourPenaltyThreshold
409419
]
410420
}),
411421

@@ -592,9 +602,12 @@ export function getMetrics(
592602
this.msgReceivedInvalid.inc({ topic, error }, 1)
593603
},
594604

595-
onDuplicateMsgDelivery(topicStr: TopicStr, deliveryDelayMs: number): void {
596-
const topic = this.toTopic(topicStr)
597-
this.duplicateMsgDelivery.observe({ topic }, deliveryDelayMs / 1000)
605+
onDuplicateMsgDelivery(topicStr: TopicStr, deliveryDelayMs: number, isLateDelivery: boolean): void {
606+
this.duplicateMsgDeliveryDelay.observe(deliveryDelayMs / 1000)
607+
if (isLateDelivery) {
608+
const topic = this.toTopic(topicStr)
609+
this.duplicateMsgLateDelivery.inc({ topic }, 1)
610+
}
598611
},
599612

600613
onRpcRecv(rpc: IRPC, rpcBytes: number): void {

ts/score/peer-score.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,9 +477,10 @@ export class PeerScore {
477477
// delivery window.
478478
if (validatedTime !== undefined) {
479479
const deliveryDelayMs = now - validatedTime
480-
this.metrics?.onDuplicateMsgDelivery(topic, deliveryDelayMs)
480+
const isLateDelivery = deliveryDelayMs > tparams.meshMessageDeliveriesWindow
481+
this.metrics?.onDuplicateMsgDelivery(topic, deliveryDelayMs, isLateDelivery)
481482

482-
if (deliveryDelayMs > tparams.meshMessageDeliveriesWindow) {
483+
if (isLateDelivery) {
483484
return
484485
}
485486
}

0 commit comments

Comments
 (0)