Skip to content

Increase resolution of delay metrics #217

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

Merged
merged 1 commit into from
Mar 24, 2022
Merged
Show file tree
Hide file tree
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
25 changes: 19 additions & 6 deletions ts/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,16 +341,24 @@ export function getMetrics(
labelNames: ['topic', 'error']
}),
/** Track duplicate message delivery time */
duplicateMsgDelivery: register.histogram<{ topic: TopicLabel }>({
duplicateMsgDeliveryDelay: register.histogram({
name: 'gossisub_duplicate_msg_delivery_delay_seconds',
help: 'Time since the 1st duplicated message validated',
labelNames: ['topic'],
buckets: [
0.25 * opts.minMeshMessageDeliveriesWindow,
0.5 * opts.minMeshMessageDeliveriesWindow,
1 * opts.minMeshMessageDeliveriesWindow,
2 * opts.minMeshMessageDeliveriesWindow
2 * opts.minMeshMessageDeliveriesWindow,
4 * opts.minMeshMessageDeliveriesWindow
]
}),
/** Total count of late msg delivery total by topic */
duplicateMsgLateDelivery: register.gauge<{ topic: TopicLabel }>({
name: 'gossisub_duplicate_msg_late_delivery_total',
help: 'Total count of late duplicate message delivery by topic, which triggers P3 penalty',
labelNames: ['topic']
}),

/* Metrics related to scoring */
/** Total times score() is called */
Expand Down Expand Up @@ -403,9 +411,11 @@ export function getMetrics(
name: 'gossipsub_peer_stat_behaviour_penalty',
help: 'Current peer stat behaviour_penalty at each scrape',
buckets: [
0.25 * opts.behaviourPenaltyThreshold,
0.5 * opts.behaviourPenaltyThreshold,
1 * opts.behaviourPenaltyThreshold,
2 * opts.behaviourPenaltyThreshold
2 * opts.behaviourPenaltyThreshold,
4 * opts.behaviourPenaltyThreshold
]
}),

Expand Down Expand Up @@ -592,9 +602,12 @@ export function getMetrics(
this.msgReceivedInvalid.inc({ topic, error }, 1)
},

onDuplicateMsgDelivery(topicStr: TopicStr, deliveryDelayMs: number): void {
const topic = this.toTopic(topicStr)
this.duplicateMsgDelivery.observe({ topic }, deliveryDelayMs / 1000)
onDuplicateMsgDelivery(topicStr: TopicStr, deliveryDelayMs: number, isLateDelivery: boolean): void {
this.duplicateMsgDeliveryDelay.observe(deliveryDelayMs / 1000)
if (isLateDelivery) {
const topic = this.toTopic(topicStr)
this.duplicateMsgLateDelivery.inc({ topic }, 1)
}
},

onRpcRecv(rpc: IRPC, rpcBytes: number): void {
Expand Down
5 changes: 3 additions & 2 deletions ts/score/peer-score.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,10 @@ export class PeerScore {
// delivery window.
if (validatedTime !== undefined) {
const deliveryDelayMs = now - validatedTime
this.metrics?.onDuplicateMsgDelivery(topic, deliveryDelayMs)
const isLateDelivery = deliveryDelayMs > tparams.meshMessageDeliveriesWindow
this.metrics?.onDuplicateMsgDelivery(topic, deliveryDelayMs, isLateDelivery)

if (deliveryDelayMs > tparams.meshMessageDeliveriesWindow) {
if (isLateDelivery) {
return
}
}
Expand Down