@aztec/p2p 1.0.0-staging.1 → 1.0.0-staging.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/services/libp2p/instrumentation.d.ts +8 -1
- package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
- package/dest/services/libp2p/instrumentation.js +130 -2
- package/dest/services/libp2p/libp2p_service.d.ts +4 -1
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +15 -3
- package/package.json +13 -13
- package/src/services/libp2p/instrumentation.ts +122 -3
- package/src/services/libp2p/libp2p_service.ts +15 -4
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import type { Timer } from '@aztec/foundation/timer';
|
|
2
|
-
import
|
|
2
|
+
import { TopicType } from '@aztec/stdlib/p2p';
|
|
3
3
|
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
4
4
|
export declare class P2PInstrumentation {
|
|
5
5
|
private messageValidationDuration;
|
|
6
6
|
private messagePrevalidationCount;
|
|
7
|
+
private messageLatency;
|
|
8
|
+
private aggLatencyHisto;
|
|
9
|
+
private aggValidationHisto;
|
|
10
|
+
private aggLatencyMetrics;
|
|
11
|
+
private aggValidationMetrics;
|
|
7
12
|
constructor(client: TelemetryClient, name: string);
|
|
8
13
|
recordMessageValidation(topicName: TopicType, timerOrMs: Timer | number): void;
|
|
9
14
|
incMessagePrevalidationStatus(passed: boolean, topicName: TopicType | undefined): void;
|
|
15
|
+
recordMessageLatency(topicName: TopicType, timerOrMs: Timer | number): void;
|
|
16
|
+
private aggregate;
|
|
10
17
|
}
|
|
11
18
|
//# sourceMappingURL=instrumentation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../../src/services/libp2p/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,
|
|
1
|
+
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../../src/services/libp2p/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAML,KAAK,eAAe,EAGrB,MAAM,yBAAyB,CAAC;AAIjC,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,yBAAyB,CAAY;IAC7C,OAAO,CAAC,yBAAyB,CAAgB;IACjD,OAAO,CAAC,cAAc,CAAY;IAElC,OAAO,CAAC,eAAe,CAA6C;IACpE,OAAO,CAAC,kBAAkB,CAA6C;IAEvE,OAAO,CAAC,iBAAiB,CAAiE;IAC1F,OAAO,CAAC,oBAAoB,CAAiE;gBAEjF,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM;IAkF1C,uBAAuB,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,GAAG,MAAM;IAavE,6BAA6B,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,GAAG,SAAS;IAI/E,oBAAoB,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,GAAG,MAAM;IAa3E,OAAO,CAAC,SAAS,CAkBf;CACH"}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
import { TopicType } from '@aztec/stdlib/p2p';
|
|
1
2
|
import { Attributes, Metrics, ValueType } from '@aztec/telemetry-client';
|
|
3
|
+
import { createHistogram } from 'node:perf_hooks';
|
|
2
4
|
export class P2PInstrumentation {
|
|
3
5
|
messageValidationDuration;
|
|
4
6
|
messagePrevalidationCount;
|
|
7
|
+
messageLatency;
|
|
8
|
+
aggLatencyHisto = new Map();
|
|
9
|
+
aggValidationHisto = new Map();
|
|
10
|
+
aggLatencyMetrics;
|
|
11
|
+
aggValidationMetrics;
|
|
5
12
|
constructor(client, name){
|
|
6
13
|
const meter = client.getMeter(name);
|
|
7
14
|
this.messageValidationDuration = meter.createHistogram(Metrics.P2P_GOSSIP_MESSAGE_VALIDATION_DURATION, {
|
|
@@ -13,12 +20,84 @@ export class P2PInstrumentation {
|
|
|
13
20
|
description: 'How many message pass/fail prevalidation',
|
|
14
21
|
valueType: ValueType.INT
|
|
15
22
|
});
|
|
23
|
+
this.messageLatency = meter.createHistogram(Metrics.P2P_GOSSIP_MESSAGE_LATENCY, {
|
|
24
|
+
unit: 'ms',
|
|
25
|
+
description: 'P2P message latency',
|
|
26
|
+
valueType: ValueType.INT
|
|
27
|
+
});
|
|
28
|
+
this.aggLatencyMetrics = {
|
|
29
|
+
avg: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_LATENCY_AVG, {
|
|
30
|
+
valueType: ValueType.DOUBLE,
|
|
31
|
+
description: 'AVG msg latency',
|
|
32
|
+
unit: 'ms'
|
|
33
|
+
}),
|
|
34
|
+
max: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_LATENCY_MAX, {
|
|
35
|
+
valueType: ValueType.DOUBLE,
|
|
36
|
+
description: 'MAX msg latency',
|
|
37
|
+
unit: 'ms'
|
|
38
|
+
}),
|
|
39
|
+
min: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_LATENCY_MIN, {
|
|
40
|
+
valueType: ValueType.DOUBLE,
|
|
41
|
+
description: 'MIN msg latency',
|
|
42
|
+
unit: 'ms'
|
|
43
|
+
}),
|
|
44
|
+
p50: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_LATENCY_P50, {
|
|
45
|
+
valueType: ValueType.DOUBLE,
|
|
46
|
+
description: 'P50 msg latency',
|
|
47
|
+
unit: 'ms'
|
|
48
|
+
}),
|
|
49
|
+
p90: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_LATENCY_P90, {
|
|
50
|
+
valueType: ValueType.DOUBLE,
|
|
51
|
+
description: 'P90 msg latency',
|
|
52
|
+
unit: 'ms'
|
|
53
|
+
})
|
|
54
|
+
};
|
|
55
|
+
this.aggValidationMetrics = {
|
|
56
|
+
avg: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_VALIDATION_DURATION_AVG, {
|
|
57
|
+
valueType: ValueType.DOUBLE,
|
|
58
|
+
description: 'AVG msg validation',
|
|
59
|
+
unit: 'ms'
|
|
60
|
+
}),
|
|
61
|
+
max: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_VALIDATION_DURATION_MAX, {
|
|
62
|
+
valueType: ValueType.DOUBLE,
|
|
63
|
+
description: 'MAX msg validation',
|
|
64
|
+
unit: 'ms'
|
|
65
|
+
}),
|
|
66
|
+
min: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_VALIDATION_DURATION_MIN, {
|
|
67
|
+
valueType: ValueType.DOUBLE,
|
|
68
|
+
description: 'MIN msg validation',
|
|
69
|
+
unit: 'ms'
|
|
70
|
+
}),
|
|
71
|
+
p50: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_VALIDATION_DURATION_P50, {
|
|
72
|
+
valueType: ValueType.DOUBLE,
|
|
73
|
+
description: 'P50 msg validation',
|
|
74
|
+
unit: 'ms'
|
|
75
|
+
}),
|
|
76
|
+
p90: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_VALIDATION_DURATION_P90, {
|
|
77
|
+
valueType: ValueType.DOUBLE,
|
|
78
|
+
description: 'P90 msg validation',
|
|
79
|
+
unit: 'ms'
|
|
80
|
+
})
|
|
81
|
+
};
|
|
82
|
+
meter.addBatchObservableCallback(this.aggregate, [
|
|
83
|
+
...Object.values(this.aggValidationMetrics),
|
|
84
|
+
...Object.values(this.aggLatencyMetrics)
|
|
85
|
+
]);
|
|
16
86
|
}
|
|
17
87
|
recordMessageValidation(topicName, timerOrMs) {
|
|
18
|
-
const ms = typeof timerOrMs === 'number' ? timerOrMs : timerOrMs.ms();
|
|
19
|
-
this.messageValidationDuration.record(
|
|
88
|
+
const ms = Math.ceil(typeof timerOrMs === 'number' ? timerOrMs : timerOrMs.ms());
|
|
89
|
+
this.messageValidationDuration.record(ms, {
|
|
20
90
|
[Attributes.TOPIC_NAME]: topicName
|
|
21
91
|
});
|
|
92
|
+
let validationHistogram = this.aggValidationHisto.get(topicName);
|
|
93
|
+
if (!validationHistogram) {
|
|
94
|
+
validationHistogram = createHistogram({
|
|
95
|
+
min: 1,
|
|
96
|
+
max: 5 * 60 * 1000
|
|
97
|
+
}); // 5 mins
|
|
98
|
+
this.aggValidationHisto.set(topicName, validationHistogram);
|
|
99
|
+
}
|
|
100
|
+
validationHistogram.record(Math.max(ms, 1));
|
|
22
101
|
}
|
|
23
102
|
incMessagePrevalidationStatus(passed, topicName) {
|
|
24
103
|
this.messagePrevalidationCount.add(1, {
|
|
@@ -26,4 +105,53 @@ export class P2PInstrumentation {
|
|
|
26
105
|
[Attributes.OK]: passed
|
|
27
106
|
});
|
|
28
107
|
}
|
|
108
|
+
recordMessageLatency(topicName, timerOrMs) {
|
|
109
|
+
const ms = Math.ceil(typeof timerOrMs === 'number' ? timerOrMs : timerOrMs.ms());
|
|
110
|
+
this.messageLatency.record(ms, {
|
|
111
|
+
[Attributes.TOPIC_NAME]: topicName
|
|
112
|
+
});
|
|
113
|
+
let latencyHistogram = this.aggLatencyHisto.get(topicName);
|
|
114
|
+
if (!latencyHistogram) {
|
|
115
|
+
latencyHistogram = createHistogram({
|
|
116
|
+
min: 1,
|
|
117
|
+
max: 24 * 60 * 60 * 1000
|
|
118
|
+
}); // 24hrs
|
|
119
|
+
this.aggLatencyHisto.set(topicName, latencyHistogram);
|
|
120
|
+
}
|
|
121
|
+
latencyHistogram.record(Math.max(ms, 1));
|
|
122
|
+
}
|
|
123
|
+
aggregate = (res)=>{
|
|
124
|
+
for (const [metrics, histograms] of [
|
|
125
|
+
[
|
|
126
|
+
this.aggLatencyMetrics,
|
|
127
|
+
this.aggLatencyHisto
|
|
128
|
+
],
|
|
129
|
+
[
|
|
130
|
+
this.aggValidationMetrics,
|
|
131
|
+
this.aggValidationHisto
|
|
132
|
+
]
|
|
133
|
+
]){
|
|
134
|
+
for (const topicName of Object.values(TopicType)){
|
|
135
|
+
const histogram = histograms.get(topicName);
|
|
136
|
+
if (!histogram) {
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
res.observe(metrics.avg, histogram.mean, {
|
|
140
|
+
[Attributes.TOPIC_NAME]: topicName
|
|
141
|
+
});
|
|
142
|
+
res.observe(metrics.max, histogram.max, {
|
|
143
|
+
[Attributes.TOPIC_NAME]: topicName
|
|
144
|
+
});
|
|
145
|
+
res.observe(metrics.min, histogram.min, {
|
|
146
|
+
[Attributes.TOPIC_NAME]: topicName
|
|
147
|
+
});
|
|
148
|
+
res.observe(metrics.p50, histogram.percentile(50), {
|
|
149
|
+
[Attributes.TOPIC_NAME]: topicName
|
|
150
|
+
});
|
|
151
|
+
res.observe(metrics.p90, histogram.percentile(90), {
|
|
152
|
+
[Attributes.TOPIC_NAME]: topicName
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
};
|
|
29
157
|
}
|
|
@@ -114,7 +114,10 @@ export declare class LibP2PService<T extends P2PClientType = P2PClientType.Full>
|
|
|
114
114
|
* @returns The number of recipients the data was sent to.
|
|
115
115
|
*/
|
|
116
116
|
private publishToTopic;
|
|
117
|
-
protected preValidateReceivedMessage(msg: Message, msgId: string, source: PeerId):
|
|
117
|
+
protected preValidateReceivedMessage(msg: Message, msgId: string, source: PeerId): {
|
|
118
|
+
result: boolean;
|
|
119
|
+
topicType?: TopicType;
|
|
120
|
+
};
|
|
118
121
|
/**
|
|
119
122
|
* Handles a new gossip message that was received by the client.
|
|
120
123
|
* @param topic - The message's topic.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libp2p_service.d.ts","sourceRoot":"","sources":["../../../src/services/libp2p/libp2p_service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AC,IAAI,CAAC;IAmB/C;;;;;;;;;OASG;YACW,uBAAuB;IAuBrC;;;;;OAKG;YACW,cAAc;IA4B5B;;;;;;;;;;OAUG;YACW,wBAAwB;IAuBtC;;;;;OAKG;IAOU,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAUjG;;;;;OAKG;IAIU,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;IAWnF,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;YAI7B,WAAW;YAcX,UAAU;CAYzB"}
|
|
@@ -389,10 +389,16 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
389
389
|
if (!validator || !validator.addMessage(msgId)) {
|
|
390
390
|
this.instrumentation.incMessagePrevalidationStatus(false, topicType);
|
|
391
391
|
this.node.services.pubsub.reportMessageValidationResult(msgId, source.toString(), TopicValidatorResult.Ignore);
|
|
392
|
-
return
|
|
392
|
+
return {
|
|
393
|
+
result: false,
|
|
394
|
+
topicType
|
|
395
|
+
};
|
|
393
396
|
}
|
|
394
397
|
this.instrumentation.incMessagePrevalidationStatus(true, topicType);
|
|
395
|
-
return
|
|
398
|
+
return {
|
|
399
|
+
result: true,
|
|
400
|
+
topicType
|
|
401
|
+
};
|
|
396
402
|
}
|
|
397
403
|
/**
|
|
398
404
|
* Handles a new gossip message that was received by the client.
|
|
@@ -407,8 +413,14 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
407
413
|
messageId: p2pMessage.id,
|
|
408
414
|
messageLatency
|
|
409
415
|
});
|
|
410
|
-
|
|
416
|
+
const preValidationResult = this.preValidateReceivedMessage(msg, msgId, source);
|
|
417
|
+
if (!preValidationResult.result) {
|
|
411
418
|
return;
|
|
419
|
+
} else if (preValidationResult.topicType !== undefined) {
|
|
420
|
+
// guard against clock skew & DST
|
|
421
|
+
if (messageLatency > 0) {
|
|
422
|
+
this.instrumentation.recordMessageLatency(preValidationResult.topicType, messageLatency);
|
|
423
|
+
}
|
|
412
424
|
}
|
|
413
425
|
if (msg.topic === this.topicStrings[TopicType.tx]) {
|
|
414
426
|
await this.handleGossipedTx(p2pMessage.payload, msgId, source);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/p2p",
|
|
3
|
-
"version": "1.0.0-staging.
|
|
3
|
+
"version": "1.0.0-staging.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -67,17 +67,17 @@
|
|
|
67
67
|
]
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@aztec/constants": "1.0.0-staging.
|
|
71
|
-
"@aztec/epoch-cache": "1.0.0-staging.
|
|
72
|
-
"@aztec/ethereum": "1.0.0-staging.
|
|
73
|
-
"@aztec/foundation": "1.0.0-staging.
|
|
74
|
-
"@aztec/kv-store": "1.0.0-staging.
|
|
75
|
-
"@aztec/noir-contracts.js": "1.0.0-staging.
|
|
76
|
-
"@aztec/noir-protocol-circuits-types": "1.0.0-staging.
|
|
77
|
-
"@aztec/protocol-contracts": "1.0.0-staging.
|
|
78
|
-
"@aztec/simulator": "1.0.0-staging.
|
|
79
|
-
"@aztec/stdlib": "1.0.0-staging.
|
|
80
|
-
"@aztec/telemetry-client": "1.0.0-staging.
|
|
70
|
+
"@aztec/constants": "1.0.0-staging.2",
|
|
71
|
+
"@aztec/epoch-cache": "1.0.0-staging.2",
|
|
72
|
+
"@aztec/ethereum": "1.0.0-staging.2",
|
|
73
|
+
"@aztec/foundation": "1.0.0-staging.2",
|
|
74
|
+
"@aztec/kv-store": "1.0.0-staging.2",
|
|
75
|
+
"@aztec/noir-contracts.js": "1.0.0-staging.2",
|
|
76
|
+
"@aztec/noir-protocol-circuits-types": "1.0.0-staging.2",
|
|
77
|
+
"@aztec/protocol-contracts": "1.0.0-staging.2",
|
|
78
|
+
"@aztec/simulator": "1.0.0-staging.2",
|
|
79
|
+
"@aztec/stdlib": "1.0.0-staging.2",
|
|
80
|
+
"@aztec/telemetry-client": "1.0.0-staging.2",
|
|
81
81
|
"@chainsafe/discv5": "9.0.0",
|
|
82
82
|
"@chainsafe/enr": "3.0.0",
|
|
83
83
|
"@chainsafe/libp2p-gossipsub": "13.0.0",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"xxhash-wasm": "^1.1.0"
|
|
108
108
|
},
|
|
109
109
|
"devDependencies": {
|
|
110
|
-
"@aztec/archiver": "1.0.0-staging.
|
|
110
|
+
"@aztec/archiver": "1.0.0-staging.2",
|
|
111
111
|
"@jest/globals": "^30.0.0",
|
|
112
112
|
"@types/jest": "^30.0.0",
|
|
113
113
|
"@types/node": "^22.15.17",
|
|
@@ -1,17 +1,28 @@
|
|
|
1
1
|
import type { Timer } from '@aztec/foundation/timer';
|
|
2
|
-
import
|
|
2
|
+
import { TopicType } from '@aztec/stdlib/p2p';
|
|
3
3
|
import {
|
|
4
4
|
Attributes,
|
|
5
|
+
type BatchObservableResult,
|
|
5
6
|
type Histogram,
|
|
6
7
|
Metrics,
|
|
8
|
+
type ObservableGauge,
|
|
7
9
|
type TelemetryClient,
|
|
8
10
|
type UpDownCounter,
|
|
9
11
|
ValueType,
|
|
10
12
|
} from '@aztec/telemetry-client';
|
|
11
13
|
|
|
14
|
+
import { type RecordableHistogram, createHistogram } from 'node:perf_hooks';
|
|
15
|
+
|
|
12
16
|
export class P2PInstrumentation {
|
|
13
17
|
private messageValidationDuration: Histogram;
|
|
14
18
|
private messagePrevalidationCount: UpDownCounter;
|
|
19
|
+
private messageLatency: Histogram;
|
|
20
|
+
|
|
21
|
+
private aggLatencyHisto = new Map<TopicType, RecordableHistogram>();
|
|
22
|
+
private aggValidationHisto = new Map<TopicType, RecordableHistogram>();
|
|
23
|
+
|
|
24
|
+
private aggLatencyMetrics: Record<'min' | 'max' | 'p50' | 'p90' | 'avg', ObservableGauge>;
|
|
25
|
+
private aggValidationMetrics: Record<'min' | 'max' | 'p50' | 'p90' | 'avg', ObservableGauge>;
|
|
15
26
|
|
|
16
27
|
constructor(client: TelemetryClient, name: string) {
|
|
17
28
|
const meter = client.getMeter(name);
|
|
@@ -26,14 +37,122 @@ export class P2PInstrumentation {
|
|
|
26
37
|
description: 'How many message pass/fail prevalidation',
|
|
27
38
|
valueType: ValueType.INT,
|
|
28
39
|
});
|
|
40
|
+
|
|
41
|
+
this.messageLatency = meter.createHistogram(Metrics.P2P_GOSSIP_MESSAGE_LATENCY, {
|
|
42
|
+
unit: 'ms',
|
|
43
|
+
description: 'P2P message latency',
|
|
44
|
+
valueType: ValueType.INT,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
this.aggLatencyMetrics = {
|
|
48
|
+
avg: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_LATENCY_AVG, {
|
|
49
|
+
valueType: ValueType.DOUBLE,
|
|
50
|
+
description: 'AVG msg latency',
|
|
51
|
+
unit: 'ms',
|
|
52
|
+
}),
|
|
53
|
+
max: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_LATENCY_MAX, {
|
|
54
|
+
valueType: ValueType.DOUBLE,
|
|
55
|
+
description: 'MAX msg latency',
|
|
56
|
+
unit: 'ms',
|
|
57
|
+
}),
|
|
58
|
+
min: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_LATENCY_MIN, {
|
|
59
|
+
valueType: ValueType.DOUBLE,
|
|
60
|
+
description: 'MIN msg latency',
|
|
61
|
+
unit: 'ms',
|
|
62
|
+
}),
|
|
63
|
+
p50: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_LATENCY_P50, {
|
|
64
|
+
valueType: ValueType.DOUBLE,
|
|
65
|
+
description: 'P50 msg latency',
|
|
66
|
+
unit: 'ms',
|
|
67
|
+
}),
|
|
68
|
+
p90: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_LATENCY_P90, {
|
|
69
|
+
valueType: ValueType.DOUBLE,
|
|
70
|
+
description: 'P90 msg latency',
|
|
71
|
+
unit: 'ms',
|
|
72
|
+
}),
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
this.aggValidationMetrics = {
|
|
76
|
+
avg: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_VALIDATION_DURATION_AVG, {
|
|
77
|
+
valueType: ValueType.DOUBLE,
|
|
78
|
+
description: 'AVG msg validation',
|
|
79
|
+
unit: 'ms',
|
|
80
|
+
}),
|
|
81
|
+
max: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_VALIDATION_DURATION_MAX, {
|
|
82
|
+
valueType: ValueType.DOUBLE,
|
|
83
|
+
description: 'MAX msg validation',
|
|
84
|
+
unit: 'ms',
|
|
85
|
+
}),
|
|
86
|
+
min: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_VALIDATION_DURATION_MIN, {
|
|
87
|
+
valueType: ValueType.DOUBLE,
|
|
88
|
+
description: 'MIN msg validation',
|
|
89
|
+
unit: 'ms',
|
|
90
|
+
}),
|
|
91
|
+
p50: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_VALIDATION_DURATION_P50, {
|
|
92
|
+
valueType: ValueType.DOUBLE,
|
|
93
|
+
description: 'P50 msg validation',
|
|
94
|
+
unit: 'ms',
|
|
95
|
+
}),
|
|
96
|
+
p90: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_VALIDATION_DURATION_P90, {
|
|
97
|
+
valueType: ValueType.DOUBLE,
|
|
98
|
+
description: 'P90 msg validation',
|
|
99
|
+
unit: 'ms',
|
|
100
|
+
}),
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
meter.addBatchObservableCallback(this.aggregate, [
|
|
104
|
+
...Object.values(this.aggValidationMetrics),
|
|
105
|
+
...Object.values(this.aggLatencyMetrics),
|
|
106
|
+
]);
|
|
29
107
|
}
|
|
30
108
|
|
|
31
109
|
public recordMessageValidation(topicName: TopicType, timerOrMs: Timer | number) {
|
|
32
|
-
const ms = typeof timerOrMs === 'number' ? timerOrMs : timerOrMs.ms();
|
|
33
|
-
this.messageValidationDuration.record(
|
|
110
|
+
const ms = Math.ceil(typeof timerOrMs === 'number' ? timerOrMs : timerOrMs.ms());
|
|
111
|
+
this.messageValidationDuration.record(ms, { [Attributes.TOPIC_NAME]: topicName });
|
|
112
|
+
|
|
113
|
+
let validationHistogram = this.aggValidationHisto.get(topicName);
|
|
114
|
+
if (!validationHistogram) {
|
|
115
|
+
validationHistogram = createHistogram({ min: 1, max: 5 * 60 * 1000 }); // 5 mins
|
|
116
|
+
this.aggValidationHisto.set(topicName, validationHistogram);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
validationHistogram.record(Math.max(ms, 1));
|
|
34
120
|
}
|
|
35
121
|
|
|
36
122
|
public incMessagePrevalidationStatus(passed: boolean, topicName: TopicType | undefined) {
|
|
37
123
|
this.messagePrevalidationCount.add(1, { [Attributes.TOPIC_NAME]: topicName, [Attributes.OK]: passed });
|
|
38
124
|
}
|
|
125
|
+
|
|
126
|
+
public recordMessageLatency(topicName: TopicType, timerOrMs: Timer | number) {
|
|
127
|
+
const ms = Math.ceil(typeof timerOrMs === 'number' ? timerOrMs : timerOrMs.ms());
|
|
128
|
+
this.messageLatency.record(ms, { [Attributes.TOPIC_NAME]: topicName });
|
|
129
|
+
|
|
130
|
+
let latencyHistogram = this.aggLatencyHisto.get(topicName);
|
|
131
|
+
if (!latencyHistogram) {
|
|
132
|
+
latencyHistogram = createHistogram({ min: 1, max: 24 * 60 * 60 * 1000 }); // 24hrs
|
|
133
|
+
this.aggLatencyHisto.set(topicName, latencyHistogram);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
latencyHistogram.record(Math.max(ms, 1));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
private aggregate = (res: BatchObservableResult) => {
|
|
140
|
+
for (const [metrics, histograms] of [
|
|
141
|
+
[this.aggLatencyMetrics, this.aggLatencyHisto],
|
|
142
|
+
[this.aggValidationMetrics, this.aggValidationHisto],
|
|
143
|
+
] as const) {
|
|
144
|
+
for (const topicName of Object.values(TopicType)) {
|
|
145
|
+
const histogram = histograms.get(topicName);
|
|
146
|
+
if (!histogram) {
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
res.observe(metrics.avg, histogram.mean, { [Attributes.TOPIC_NAME]: topicName });
|
|
151
|
+
res.observe(metrics.max, histogram.max, { [Attributes.TOPIC_NAME]: topicName });
|
|
152
|
+
res.observe(metrics.min, histogram.min, { [Attributes.TOPIC_NAME]: topicName });
|
|
153
|
+
res.observe(metrics.p50, histogram.percentile(50), { [Attributes.TOPIC_NAME]: topicName });
|
|
154
|
+
res.observe(metrics.p90, histogram.percentile(90), { [Attributes.TOPIC_NAME]: topicName });
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
};
|
|
39
158
|
}
|
|
@@ -537,7 +537,11 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
537
537
|
return result.recipients.length;
|
|
538
538
|
}
|
|
539
539
|
|
|
540
|
-
protected preValidateReceivedMessage(
|
|
540
|
+
protected preValidateReceivedMessage(
|
|
541
|
+
msg: Message,
|
|
542
|
+
msgId: string,
|
|
543
|
+
source: PeerId,
|
|
544
|
+
): { result: boolean; topicType?: TopicType } {
|
|
541
545
|
let topicType: TopicType | undefined;
|
|
542
546
|
|
|
543
547
|
switch (msg.topic) {
|
|
@@ -560,12 +564,12 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
560
564
|
if (!validator || !validator.addMessage(msgId)) {
|
|
561
565
|
this.instrumentation.incMessagePrevalidationStatus(false, topicType);
|
|
562
566
|
this.node.services.pubsub.reportMessageValidationResult(msgId, source.toString(), TopicValidatorResult.Ignore);
|
|
563
|
-
return false;
|
|
567
|
+
return { result: false, topicType };
|
|
564
568
|
}
|
|
565
569
|
|
|
566
570
|
this.instrumentation.incMessagePrevalidationStatus(true, topicType);
|
|
567
571
|
|
|
568
|
-
return true;
|
|
572
|
+
return { result: true, topicType };
|
|
569
573
|
}
|
|
570
574
|
|
|
571
575
|
/**
|
|
@@ -583,8 +587,15 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
583
587
|
messageLatency,
|
|
584
588
|
});
|
|
585
589
|
|
|
586
|
-
|
|
590
|
+
const preValidationResult = this.preValidateReceivedMessage(msg, msgId, source);
|
|
591
|
+
|
|
592
|
+
if (!preValidationResult.result) {
|
|
587
593
|
return;
|
|
594
|
+
} else if (preValidationResult.topicType !== undefined) {
|
|
595
|
+
// guard against clock skew & DST
|
|
596
|
+
if (messageLatency > 0) {
|
|
597
|
+
this.instrumentation.recordMessageLatency(preValidationResult.topicType, messageLatency);
|
|
598
|
+
}
|
|
588
599
|
}
|
|
589
600
|
|
|
590
601
|
if (msg.topic === this.topicStrings[TopicType.tx]) {
|