@aztec/telemetry-client 0.0.1-commit.42ee6df9b → 0.0.1-commit.431c48d

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.
Files changed (58) hide show
  1. package/dest/attributes.d.ts +12 -2
  2. package/dest/attributes.d.ts.map +1 -1
  3. package/dest/attributes.js +6 -1
  4. package/dest/config.d.ts +3 -1
  5. package/dest/config.d.ts.map +1 -1
  6. package/dest/config.js +17 -9
  7. package/dest/index.d.ts +2 -1
  8. package/dest/index.d.ts.map +1 -1
  9. package/dest/index.js +1 -0
  10. package/dest/json_rpc_server_metrics.d.ts +27 -0
  11. package/dest/json_rpc_server_metrics.d.ts.map +1 -0
  12. package/dest/json_rpc_server_metrics.js +154 -0
  13. package/dest/lmdb_metrics.d.ts +2 -2
  14. package/dest/lmdb_metrics.d.ts.map +1 -1
  15. package/dest/metrics.d.ts +39 -4
  16. package/dest/metrics.d.ts.map +1 -1
  17. package/dest/metrics.js +210 -17
  18. package/dest/monitored_batch_span_processor.d.ts +29 -0
  19. package/dest/monitored_batch_span_processor.d.ts.map +1 -0
  20. package/dest/monitored_batch_span_processor.js +75 -0
  21. package/dest/otel.d.ts +6 -1
  22. package/dest/otel.d.ts.map +1 -1
  23. package/dest/otel.js +99 -4
  24. package/dest/otel_propagation.d.ts +4 -1
  25. package/dest/otel_propagation.d.ts.map +1 -1
  26. package/dest/otel_propagation.js +64 -6
  27. package/dest/start.d.ts +1 -1
  28. package/dest/start.d.ts.map +1 -1
  29. package/dest/start.js +1 -1
  30. package/dest/telemetry.d.ts +5 -3
  31. package/dest/telemetry.d.ts.map +1 -1
  32. package/dest/vendor/attributes.d.ts +2 -1
  33. package/dest/vendor/attributes.d.ts.map +1 -1
  34. package/dest/vendor/attributes.js +1 -0
  35. package/dest/wrappers/index.d.ts +1 -2
  36. package/dest/wrappers/index.d.ts.map +1 -1
  37. package/dest/wrappers/index.js +0 -1
  38. package/dest/wrappers/json_rpc_server.d.ts +1 -1
  39. package/dest/wrappers/json_rpc_server.d.ts.map +1 -1
  40. package/dest/wrappers/json_rpc_server.js +6 -1
  41. package/package.json +3 -3
  42. package/src/attributes.ts +14 -1
  43. package/src/config.ts +24 -9
  44. package/src/index.ts +1 -0
  45. package/src/json_rpc_server_metrics.ts +151 -0
  46. package/src/metrics.ts +228 -17
  47. package/src/monitored_batch_span_processor.ts +100 -0
  48. package/src/otel.ts +69 -3
  49. package/src/otel_propagation.ts +63 -5
  50. package/src/start.ts +6 -1
  51. package/src/telemetry.ts +6 -2
  52. package/src/vendor/attributes.ts +1 -0
  53. package/src/wrappers/index.ts +0 -1
  54. package/src/wrappers/json_rpc_server.ts +13 -2
  55. package/dest/wrappers/l2_block_stream.d.ts +0 -16
  56. package/dest/wrappers/l2_block_stream.d.ts.map +0 -1
  57. package/dest/wrappers/l2_block_stream.js +0 -400
  58. package/src/wrappers/l2_block_stream.ts +0 -41
package/src/attributes.ts CHANGED
@@ -18,6 +18,8 @@
18
18
  export const HTTP_REQUEST_HOST = 'http.header.request.host';
19
19
  export const HTTP_RESPONSE_STATUS_CODE = 'http.response.status_code';
20
20
 
21
+ export const JSON_RPC_REJECTION_REASON = 'aztec.json_rpc.rejection_reason';
22
+
21
23
  /** The Aztec network identifier */
22
24
  export const NETWORK_NAME = 'aztec.network_name';
23
25
 
@@ -45,6 +47,8 @@ export const BLOCK_NUMBER = 'aztec.block.number';
45
47
  export const BLOCK_HASH = 'aztec.block.hash';
46
48
  /** The slot number */
47
49
  export const SLOT_NUMBER = 'aztec.slot.number';
50
+ /** Whether an event happened before or after a slot boundary. */
51
+ export const SLOT_BOUNDARY_SIDE = 'aztec.slot_boundary_side';
48
52
  /** The checkpoint number */
49
53
  export const CHECKPOINT_NUMBER = 'aztec.checkpoint.number';
50
54
  /** The parent's block number */
@@ -61,6 +65,8 @@ export const EPOCH_SIZE = 'aztec.epoch.size';
61
65
  export const BLOCK_PROPOSER = 'aztec.block.proposer';
62
66
  /** The epoch number */
63
67
  export const EPOCH_NUMBER = 'aztec.epoch.number';
68
+ /** Kind of an EpochSession: 'full' or 'partial'. */
69
+ export const EPOCH_SESSION_KIND = 'aztec.epoch_session.kind';
64
70
  /** The tx hash */
65
71
  export const TX_HASH = 'aztec.tx.hash';
66
72
  /** Generic attribute representing whether the action was successful or not */
@@ -69,6 +75,8 @@ export const OK = 'aztec.ok';
69
75
  export const STATUS = 'aztec.status';
70
76
  /** Generic error type attribute */
71
77
  export const ERROR_TYPE = 'aztec.error_type';
78
+ /** The cause of an archiver prune (unproven / uncheckpointed / l1_conflict / orphan / l1_mismatch) */
79
+ export const PRUNE_TYPE = 'aztec.archiver.prune_type';
72
80
  /** The type of the transaction */
73
81
  export const L1_TX_TYPE = 'aztec.l1.tx_type';
74
82
  /** The L1 address of the entity that sent a transaction to L1 */
@@ -94,7 +102,6 @@ export const VALIDATOR_STATUS = 'aztec.validator_status';
94
102
 
95
103
  export const P2P_ID = 'aztec.p2p.id';
96
104
  export const P2P_REQ_RESP_PROTOCOL = 'aztec.p2p.req_resp.protocol';
97
- export const P2P_REQ_RESP_BATCH_REQUESTS_COUNT = 'aztec.p2p.req_resp.batch_requests_count';
98
105
  /** The state of a peer (Healthy, Disconnect, Banned) */
99
106
  export const P2P_PEER_SCORE_STATE = 'aztec.p2p.peer_score_state';
100
107
  export const POOL_NAME = 'aztec.pool.name';
@@ -128,6 +135,12 @@ export const NODEJS_EVENT_LOOP_STATE = 'nodejs.eventloop.state';
128
135
 
129
136
  export const TOPIC_NAME = 'aztec.gossip.topic_name';
130
137
 
138
+ /** Stage of gossiped tx validation (deserialize, fast_validation_setup, fast_validation, pool_precheck, proof_verify, pool_add) */
139
+ export const TX_VALIDATION_STAGE = 'aztec.p2p.tx_validation_stage';
140
+
141
+ /** Operation type enqueued on the mempool serial queue */
142
+ export const MEMPOOL_OPERATION = 'aztec.mempool.operation';
143
+
131
144
  /** The reason a transaction was evicted from the tx pool */
132
145
  export const TX_POOL_EVICTION_REASON = 'aztec.mempool.eviction_reason';
133
146
 
package/src/config.ts CHANGED
@@ -1,4 +1,9 @@
1
- import { type ConfigMappingsType, booleanConfigHelper, getConfigFromMappings } from '@aztec/foundation/config';
1
+ import {
2
+ type ConfigMappingsType,
3
+ booleanConfigHelper,
4
+ getConfigFromMappings,
5
+ numberConfigHelper,
6
+ } from '@aztec/foundation/config';
2
7
 
3
8
  export interface TelemetryClientConfig {
4
9
  metricsCollectorUrl?: URL;
@@ -12,35 +17,35 @@ export interface TelemetryClientConfig {
12
17
  otelExportTimeoutMs: number;
13
18
  otelExcludeMetrics: string[];
14
19
  otelIncludeMetrics: string[];
20
+ otelMinTraceDurationMs: number;
21
+ otelBspMaxQueueSize: number;
15
22
  }
16
23
 
17
24
  export const telemetryClientConfigMappings: ConfigMappingsType<TelemetryClientConfig> = {
18
25
  metricsCollectorUrl: {
19
26
  env: 'OTEL_EXPORTER_OTLP_METRICS_ENDPOINT',
20
27
  description: 'The URL of the telemetry collector for metrics',
21
- parseEnv: (val: string) => val && new URL(val),
28
+ parseEnv: (val: string) => new URL(val),
22
29
  },
23
30
  tracesCollectorUrl: {
24
31
  env: 'OTEL_EXPORTER_OTLP_TRACES_ENDPOINT',
25
32
  description: 'The URL of the telemetry collector for traces',
26
- parseEnv: (val: string) => val && new URL(val),
33
+ parseEnv: (val: string) => new URL(val),
27
34
  },
28
35
  logsCollectorUrl: {
29
36
  env: 'OTEL_EXPORTER_OTLP_LOGS_ENDPOINT',
30
37
  description: 'The URL of the telemetry collector for logs',
31
- parseEnv: (val: string) => val && new URL(val),
38
+ parseEnv: (val: string) => new URL(val),
32
39
  },
33
40
  otelCollectIntervalMs: {
34
41
  env: 'OTEL_COLLECT_INTERVAL_MS',
35
42
  description: 'The interval at which to collect metrics',
36
- defaultValue: 60000, // Default extracted from otel client
37
- parseEnv: (val: string) => parseInt(val),
43
+ ...numberConfigHelper(60000),
38
44
  },
39
45
  otelExportTimeoutMs: {
40
46
  env: 'OTEL_EXPORT_TIMEOUT_MS',
41
47
  description: 'The timeout for exporting metrics',
42
- defaultValue: 30000, // Default extracted from otel client
43
- parseEnv: (val: string) => parseInt(val),
48
+ ...numberConfigHelper(30000),
44
49
  },
45
50
  otelExcludeMetrics: {
46
51
  env: 'OTEL_EXCLUDE_METRICS',
@@ -54,6 +59,16 @@ export const telemetryClientConfigMappings: ConfigMappingsType<TelemetryClientCo
54
59
  : [],
55
60
  defaultValue: [],
56
61
  },
62
+ otelMinTraceDurationMs: {
63
+ env: 'OTEL_MIN_TRACE_DURATION_MS',
64
+ description: 'The minimum successful trace duration to export in milliseconds. Set to 0 to export all traces.',
65
+ ...numberConfigHelper(10),
66
+ },
67
+ otelBspMaxQueueSize: {
68
+ env: 'OTEL_BSP_MAX_QUEUE_SIZE',
69
+ description: 'The maximum number of completed spans to queue before export.',
70
+ ...numberConfigHelper(16384),
71
+ },
57
72
  otelIncludeMetrics: {
58
73
  env: 'OTEL_INCLUDE_METRICS',
59
74
  description: 'A list of metric prefixes to include in export (ignored if OTEL_EXCLUDE_METRICS is set)',
@@ -70,7 +85,7 @@ export const telemetryClientConfigMappings: ConfigMappingsType<TelemetryClientCo
70
85
  publicMetricsCollectorUrl: {
71
86
  env: 'PUBLIC_OTEL_EXPORTER_OTLP_METRICS_ENDPOINT',
72
87
  description: 'A URL to publish a subset of metrics for public consumption',
73
- parseEnv: (val: string) => val && new URL(val),
88
+ parseEnv: (val: string) => new URL(val),
74
89
  },
75
90
  publicMetricsCollectFrom: {
76
91
  env: 'PUBLIC_OTEL_COLLECT_FROM',
package/src/index.ts CHANGED
@@ -8,3 +8,4 @@ export * from './l1_metrics.js';
8
8
  export * from './wrappers/index.js';
9
9
  export * from './start.js';
10
10
  export * from './otel_propagation.js';
11
+ export * from './json_rpc_server_metrics.js';
@@ -0,0 +1,151 @@
1
+ import { Timer } from '@aztec/foundation/timer';
2
+
3
+ import type Koa from 'koa';
4
+
5
+ import * as Attributes from './attributes.js';
6
+ import * as Metrics from './metrics.js';
7
+ import { getTelemetryClient } from './start.js';
8
+ import type { Histogram, MetricAttributesType, TelemetryClient, UpDownCounter } from './telemetry.js';
9
+ import { ATTR_JSONRPC_METHOD, ATTR_JSONRPC_SERVICE } from './vendor/attributes.js';
10
+
11
+ const BATCH_SIZE_BUCKETS = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000];
12
+
13
+ /** Fixed reasons for rejecting an RPC request before dispatching it to a registered handler. */
14
+ export type JsonRpcRejectionReason =
15
+ | 'unauthorized'
16
+ | 'parse_error'
17
+ | 'invalid_request'
18
+ | 'method_not_found'
19
+ | 'bad_request'
20
+ | 'internal_error';
21
+
22
+ /** Records bounded-cardinality metrics for registered JSON-RPC calls, rejected requests, and batches. */
23
+ export class JsonRpcServerMetrics {
24
+ private readonly requestCount: UpDownCounter;
25
+ private readonly requestDuration: Histogram;
26
+ private readonly requestValidationDuration: Histogram;
27
+ private readonly rejectedRequestCount: UpDownCounter;
28
+ private readonly batchCount: UpDownCounter;
29
+ private readonly batchDuration: Histogram;
30
+ private readonly batchSize: Histogram;
31
+
32
+ constructor(telemetry: TelemetryClient) {
33
+ const meter = telemetry.getMeter('JsonRpcServer');
34
+ this.requestCount = meter.createUpDownCounter(Metrics.JSON_RPC_SERVER_REQUEST_COUNT);
35
+ this.requestDuration = meter.createHistogram(Metrics.JSON_RPC_SERVER_REQUEST_DURATION);
36
+ this.requestValidationDuration = meter.createHistogram(Metrics.JSON_RPC_SERVER_REQUEST_VALIDATION_DURATION);
37
+ this.rejectedRequestCount = meter.createUpDownCounter(Metrics.JSON_RPC_SERVER_REJECTED_REQUEST_COUNT);
38
+ this.batchCount = meter.createUpDownCounter(Metrics.JSON_RPC_SERVER_BATCH_COUNT);
39
+ this.batchDuration = meter.createHistogram(Metrics.JSON_RPC_SERVER_BATCH_DURATION);
40
+ this.batchSize = meter.createHistogram(Metrics.JSON_RPC_SERVER_BATCH_SIZE, {
41
+ advice: { explicitBucketBoundaries: BATCH_SIZE_BUCKETS },
42
+ });
43
+ }
44
+
45
+ /** Records the outcome and handler duration of a registered RPC method. */
46
+ public recordRequest(fullMethod: string, durationMs: number, ok: boolean): void {
47
+ const [service, method] = splitJsonRpcMethod(fullMethod);
48
+ const attributes: MetricAttributesType = {
49
+ ...(service === undefined ? {} : { [ATTR_JSONRPC_SERVICE]: service }),
50
+ [ATTR_JSONRPC_METHOD]: method,
51
+ [Attributes.OK]: ok,
52
+ };
53
+ this.requestCount.add(1, attributes);
54
+ this.requestDuration.record(durationMs, attributes);
55
+ }
56
+
57
+ /** Records a pre-dispatch rejection using a fixed reason. */
58
+ public recordRejectedRequest(reason: JsonRpcRejectionReason): void {
59
+ this.rejectedRequestCount.add(1, { [Attributes.JSON_RPC_REJECTION_REASON]: reason });
60
+ }
61
+
62
+ /** Records the duration and outcome of validating a registered RPC method's parameters. */
63
+ public recordRequestValidation(fullMethod: string, durationMs: number, ok: boolean): void {
64
+ const [service, method] = splitJsonRpcMethod(fullMethod);
65
+ this.requestValidationDuration.record(durationMs, {
66
+ ...(service === undefined ? {} : { [ATTR_JSONRPC_SERVICE]: service }),
67
+ [ATTR_JSONRPC_METHOD]: method,
68
+ [Attributes.OK]: ok,
69
+ });
70
+ }
71
+
72
+ /** Records the outcome, processing duration, and number of calls in a batch envelope. */
73
+ public recordBatch(size: number, durationMs: number, ok: boolean): void {
74
+ const attributes = { [Attributes.OK]: ok };
75
+ this.batchCount.add(1, attributes);
76
+ this.batchDuration.record(durationMs, attributes);
77
+ this.batchSize.record(size, attributes);
78
+ }
79
+ }
80
+
81
+ let metricsOwner: TelemetryClient | undefined;
82
+ let metrics: JsonRpcServerMetrics | undefined;
83
+
84
+ export function getJsonRpcServerMetrics(): JsonRpcServerMetrics {
85
+ const telemetry = getTelemetryClient();
86
+ if (metricsOwner !== telemetry) {
87
+ metricsOwner = telemetry;
88
+ metrics = new JsonRpcServerMetrics(telemetry);
89
+ }
90
+ return metrics!;
91
+ }
92
+
93
+ export function getOtelJsonRpcServerMetricsMiddleware(
94
+ metricsProvider: () => Pick<JsonRpcServerMetrics, 'recordBatch' | 'recordRejectedRequest'> = getJsonRpcServerMetrics,
95
+ ): (ctx: Koa.Context, next: () => Promise<void>) => Promise<void> {
96
+ return async function otelJsonRpcServerMetrics(ctx, next) {
97
+ const timer = new Timer();
98
+ await next();
99
+
100
+ const requestBody = (ctx.request as { body?: unknown }).body;
101
+ if (Array.isArray(requestBody)) {
102
+ metricsProvider().recordBatch(requestBody.length, timer.ms(), Array.isArray(ctx.body));
103
+ }
104
+
105
+ for (const reason of getRejectionReasons(ctx.status, ctx.body)) {
106
+ metricsProvider().recordRejectedRequest(reason);
107
+ }
108
+ };
109
+ }
110
+
111
+ export function splitJsonRpcMethod(fullMethod: string): [service: string | undefined, method: string] {
112
+ const separator = fullMethod.indexOf('_');
113
+ return separator === -1 ? [undefined, fullMethod] : [fullMethod.slice(0, separator), fullMethod.slice(separator + 1)];
114
+ }
115
+
116
+ function getRejectionReasons(status: number, response: unknown): JsonRpcRejectionReason[] {
117
+ if (status === 401) {
118
+ return ['unauthorized'];
119
+ }
120
+
121
+ const responses = Array.isArray(response) ? response : [response];
122
+ return responses.flatMap(item => {
123
+ const code = getErrorCode(item);
124
+ if (code === -32700) {
125
+ return ['parse_error'];
126
+ }
127
+ if (code === -32601) {
128
+ return ['method_not_found'];
129
+ }
130
+ if (code === -32600) {
131
+ return ['invalid_request'];
132
+ }
133
+ if (code === -32603) {
134
+ return ['internal_error'];
135
+ }
136
+ if (code === -32000) {
137
+ return ['bad_request'];
138
+ }
139
+ return [];
140
+ });
141
+ }
142
+
143
+ function getErrorCode(response: unknown): number | undefined {
144
+ if (!response || typeof response !== 'object' || !('error' in response)) {
145
+ return undefined;
146
+ }
147
+ const error = response.error;
148
+ return error && typeof error === 'object' && 'code' in error && typeof error.code === 'number'
149
+ ? error.code
150
+ : undefined;
151
+ }
package/src/metrics.ts CHANGED
@@ -33,6 +33,46 @@ export interface MetricDefinition {
33
33
  readonly valueType?: ValueType;
34
34
  }
35
35
 
36
+ export const JSON_RPC_SERVER_REQUEST_COUNT: MetricDefinition = {
37
+ name: 'aztec.json_rpc.server.request_count',
38
+ description: 'Number of completed JSON-RPC server requests',
39
+ valueType: ValueType.INT,
40
+ };
41
+ export const JSON_RPC_SERVER_REQUEST_DURATION: MetricDefinition = {
42
+ name: 'aztec.json_rpc.server.request_duration',
43
+ description: 'JSON-RPC server request handler duration',
44
+ unit: 'ms',
45
+ valueType: ValueType.DOUBLE,
46
+ };
47
+ export const JSON_RPC_SERVER_REQUEST_VALIDATION_DURATION: MetricDefinition = {
48
+ name: 'aztec.json_rpc.server.request_validation_duration',
49
+ description: 'JSON-RPC server request parameter validation duration',
50
+ unit: 'ms',
51
+ valueType: ValueType.DOUBLE,
52
+ };
53
+ export const JSON_RPC_SERVER_REJECTED_REQUEST_COUNT: MetricDefinition = {
54
+ name: 'aztec.json_rpc.server.rejected_request_count',
55
+ description: 'Number of JSON-RPC requests rejected before handler dispatch',
56
+ valueType: ValueType.INT,
57
+ };
58
+ export const JSON_RPC_SERVER_BATCH_COUNT: MetricDefinition = {
59
+ name: 'aztec.json_rpc.server.batch_count',
60
+ description: 'Number of JSON-RPC batches received',
61
+ valueType: ValueType.INT,
62
+ };
63
+ export const JSON_RPC_SERVER_BATCH_DURATION: MetricDefinition = {
64
+ name: 'aztec.json_rpc.server.batch_duration',
65
+ description: 'JSON-RPC batch processing duration',
66
+ unit: 'ms',
67
+ valueType: ValueType.DOUBLE,
68
+ };
69
+ export const JSON_RPC_SERVER_BATCH_SIZE: MetricDefinition = {
70
+ name: 'aztec.json_rpc.server.batch_size',
71
+ description: 'Number of requests in a JSON-RPC batch',
72
+ unit: 'requests',
73
+ valueType: ValueType.INT,
74
+ };
75
+
36
76
  export const BLOB_SINK_STORE_REQUESTS: MetricDefinition = {
37
77
  name: 'aztec.blob_sink.store_request_count',
38
78
  description: 'Number of blob store requests',
@@ -162,7 +202,7 @@ export const MEMPOOL_TX_ADDED_COUNT: MetricDefinition = {
162
202
  };
163
203
  export const MEMPOOL_TX_MINED_DELAY: MetricDefinition = {
164
204
  name: 'aztec.mempool.tx_mined_delay',
165
- description: 'Delay between transaction added and evicted from the mempool',
205
+ description: 'Delay (ms) from a transaction being received into the pool to being mined',
166
206
  unit: 'ms',
167
207
  valueType: ValueType.INT,
168
208
  };
@@ -204,6 +244,24 @@ export const MEMPOOL_TX_POOL_V2_METADATA_MEMORY: MetricDefinition = {
204
244
  valueType: ValueType.INT,
205
245
  };
206
246
 
247
+ export const MEMPOOL_TX_POOL_V2_QUEUE_WAIT: MetricDefinition = {
248
+ name: 'aztec.mempool.tx_pool_v2.queue_wait',
249
+ description: 'Time an operation waits in the tx pool serial queue before executing, keyed by mempool.operation',
250
+ unit: 'ms',
251
+ valueType: ValueType.INT,
252
+ };
253
+ export const MEMPOOL_TX_POOL_V2_QUEUE_EXECUTION: MetricDefinition = {
254
+ name: 'aztec.mempool.tx_pool_v2.queue_execution',
255
+ description: 'Time an operation spends executing in the tx pool serial queue, keyed by mempool.operation',
256
+ unit: 'ms',
257
+ valueType: ValueType.INT,
258
+ };
259
+ export const MEMPOOL_TX_POOL_V2_QUEUE_LENGTH: MetricDefinition = {
260
+ name: 'aztec.mempool.tx_pool_v2.queue_length',
261
+ description: 'Number of operations waiting in the tx pool serial queue',
262
+ valueType: ValueType.INT,
263
+ };
264
+
207
265
  export const MEMPOOL_TX_POOL_V2_DUPLICATE_ADD: MetricDefinition = {
208
266
  name: 'aztec.mempool.tx_pool_v2.duplicate_add',
209
267
  description: 'Transactions received via addPendingTxs that were already in the pool',
@@ -308,6 +366,12 @@ export const ARCHIVER_SYNC_PER_BLOCK: MetricDefinition = {
308
366
  unit: 'ms',
309
367
  valueType: ValueType.INT,
310
368
  };
369
+ export const ARCHIVER_SYNC_PER_CHECKPOINT: MetricDefinition = {
370
+ name: 'aztec.archiver.checkpoint.sync_per_item_duration',
371
+ description: 'Duration to sync a checkpoint',
372
+ unit: 'ms',
373
+ valueType: ValueType.INT,
374
+ };
311
375
  export const ARCHIVER_SYNC_BLOCK_COUNT: MetricDefinition = {
312
376
  name: 'aztec.archiver.block.sync_count',
313
377
  description: 'Number of blocks synced from L1',
@@ -334,7 +398,8 @@ export const ARCHIVER_PRUNE_DURATION: MetricDefinition = {
334
398
  };
335
399
  export const ARCHIVER_PRUNE_COUNT: MetricDefinition = {
336
400
  name: 'aztec.archiver.prune_count',
337
- description: 'Number of prunes detected',
401
+ description:
402
+ 'Number of prunes detected, dimensioned by prune_type: unproven (epoch prune of checkpoints that will not be proven), uncheckpointed (proposed blocks whose slot ended without a checkpoint), l1_conflict (proposed blocks conflicting with an L1 checkpoint), orphan (proposed blocks whose matching proposed checkpoint never arrived before the deadline), and l1_mismatch (the local checkpointed tip diverged from L1 — an L1 reorg or a pruned/missed-proof checkpoint — rewinding already-checkpointed blocks).',
338
403
  valueType: ValueType.INT,
339
404
  };
340
405
 
@@ -357,6 +422,12 @@ export const ARCHIVER_CHECKPOINT_L1_INCLUSION_DELAY: MetricDefinition = {
357
422
  valueType: ValueType.INT,
358
423
  };
359
424
 
425
+ export const ARCHIVER_CHECKPOINT_PROMOTED_COUNT: MetricDefinition = {
426
+ name: 'aztec.archiver.checkpoint_promoted_count',
427
+ description: 'Number of checkpoints promoted from proposed (blob fetch skipped)',
428
+ valueType: ValueType.INT,
429
+ };
430
+
360
431
  export const NODE_RECEIVE_TX_DURATION: MetricDefinition = {
361
432
  name: 'aztec.node.receive_tx.duration',
362
433
  description: 'The duration of the receiveTx method',
@@ -388,6 +459,12 @@ export const SEQUENCER_STATE_TRANSITION_BUFFER_DURATION: MetricDefinition = {
388
459
  unit: 'ms',
389
460
  valueType: ValueType.INT,
390
461
  };
462
+ export const SEQUENCER_STATE_DURATION: MetricDefinition = {
463
+ name: 'aztec.sequencer.state_duration',
464
+ description: 'Wall-clock time spent in each sequencer state, labelled by the state being left',
465
+ unit: 'ms',
466
+ valueType: ValueType.INT,
467
+ };
391
468
  export const SEQUENCER_BLOCK_BUILD_DURATION: MetricDefinition = {
392
469
  name: 'aztec.sequencer.block.build_duration',
393
470
  description: 'Duration to build a block',
@@ -405,6 +482,12 @@ export const SEQUENCER_BLOCK_COUNT: MetricDefinition = {
405
482
  description: 'Number of blocks built by this sequencer',
406
483
  valueType: ValueType.INT,
407
484
  };
485
+ export const SEQUENCER_BLOCK_INTER_BLOCK_TIME: MetricDefinition = {
486
+ name: 'aztec.sequencer.block.inter_block_time',
487
+ description: 'Wall-clock time elapsed between consecutive blocks being built by this sequencer',
488
+ unit: 'ms',
489
+ valueType: ValueType.INT,
490
+ };
408
491
  export const SEQUENCER_CURRENT_SLOT_REWARDS: MetricDefinition = {
409
492
  name: 'aztec.sequencer.current_slot_rewards',
410
493
  description: 'The rewards earned per filled slot',
@@ -477,6 +560,25 @@ export const SEQUENCER_CHECKPOINT_BUILD_DURATION: MetricDefinition = {
477
560
  unit: 'ms',
478
561
  valueType: ValueType.INT,
479
562
  };
563
+ export const SEQUENCER_CHECKPOINT_START_TO_FIRST_BLOCK_DURATION: MetricDefinition = {
564
+ name: 'aztec.sequencer.checkpoint.start_to_first_block_duration',
565
+ description: 'Time from starting checkpoint work to the first block finishing build',
566
+ unit: 'ms',
567
+ valueType: ValueType.INT,
568
+ };
569
+ export const SEQUENCER_CHECKPOINT_LAST_BLOCK_TO_BROADCAST_DURATION: MetricDefinition = {
570
+ name: 'aztec.sequencer.checkpoint.last_block_to_broadcast_duration',
571
+ description: 'Time from the final block finishing build to the checkpoint proposal being broadcast',
572
+ unit: 'ms',
573
+ valueType: ValueType.INT,
574
+ };
575
+ export const SEQUENCER_PIPELINED_CHECKPOINT_BUILD_START_OFFSET_FROM_SLOT_BOUNDARY: MetricDefinition = {
576
+ name: 'aztec.sequencer.pipelined_checkpoint.build_start_offset_from_slot_boundary',
577
+ description:
578
+ 'Absolute offset from the wall-clock slot boundary when a pipelined checkpoint build starts. Use aztec.slot_boundary_side to distinguish before vs after the boundary.',
579
+ unit: 'ms',
580
+ valueType: ValueType.INT,
581
+ };
480
582
  export const SEQUENCER_CHECKPOINT_BLOCK_COUNT: MetricDefinition = {
481
583
  name: 'aztec.sequencer.checkpoint.block_count',
482
584
  description: 'Number of blocks built in a checkpoint',
@@ -499,6 +601,46 @@ export const SEQUENCER_SLASHING_ATTEMPTS_COUNT: MetricDefinition = {
499
601
  description: 'The number of slashing action attempts',
500
602
  valueType: ValueType.INT,
501
603
  };
604
+ export const SLASHER_ROUND_EXECUTED_COUNT: MetricDefinition = {
605
+ name: 'aztec.slasher.round.executed_count',
606
+ description: 'The number of slashing rounds executed',
607
+ valueType: ValueType.INT,
608
+ };
609
+ export const SLASHER_OWN_VALIDATOR_TARGETED_COUNT: MetricDefinition = {
610
+ name: 'aztec.slasher.own_validator.targeted_count',
611
+ description:
612
+ "The number of times one of the node's own validators was named as a slash target by an onchain vote, counted " +
613
+ 'once per vote per validator. Votes cast while the node is offline or starting up are not counted, and L1 ' +
614
+ 'reorgs can cause small drift within a round.',
615
+ valueType: ValueType.INT,
616
+ };
617
+ export const SLASHER_OWN_VALIDATOR_CURRENT_ROUND_VOTES_MAX: MetricDefinition = {
618
+ name: 'aztec.slasher.own_validator.current_round_votes_max',
619
+ description:
620
+ "Highest number of votes cast against any committee position held by the node's own validators in the current " +
621
+ 'slashing round, to compare against aztec.slasher.quorum_size (the contract tallies quorum per position). ' +
622
+ 'Resets to zero when a new round starts. Votes cast while the node is offline or starting up are not counted, ' +
623
+ 'and L1 reorgs can cause small drift within a round.',
624
+ valueType: ValueType.INT,
625
+ };
626
+ export const SLASHER_QUORUM_SIZE: MetricDefinition = {
627
+ name: 'aztec.slasher.quorum_size',
628
+ description: 'The number of votes a validator must receive in a round to be slashed',
629
+ valueType: ValueType.INT,
630
+ };
631
+ export const SLASHER_OWN_VALIDATOR_SLASHED_COUNT: MetricDefinition = {
632
+ name: 'aztec.slasher.own_validator.slashed_count',
633
+ description: "The number of times one of the node's own validators was slashed, from executed Slashed events",
634
+ valueType: ValueType.INT,
635
+ };
636
+ export const SLASHER_OWN_VALIDATOR_SLASHED_AMOUNT: MetricDefinition = {
637
+ name: 'aztec.slasher.own_validator.slashed_amount',
638
+ description:
639
+ "Cumulative amount slashed from the node's own validators in whole staking-asset tokens, from executed " +
640
+ 'Slashed events',
641
+ unit: 'tokens',
642
+ valueType: ValueType.DOUBLE,
643
+ };
502
644
  export const SEQUENCER_CHECKPOINT_SUCCESS_COUNT: MetricDefinition = {
503
645
  name: 'aztec.sequencer.checkpoint.success_count',
504
646
  description: 'The number of times checkpoint publishing succeeded',
@@ -514,6 +656,11 @@ export const SEQUENCER_PIPELINE_DISCARDS_COUNT: MetricDefinition = {
514
656
  description: 'The number of times a pipeline was discarded',
515
657
  valueType: ValueType.INT,
516
658
  };
659
+ export const SEQUENCER_PIPELINE_PARENT_CHECKPOINT_MISMATCH_COUNT: MetricDefinition = {
660
+ name: 'aztec.sequencer.pipeline.parent_checkpoint_mismatch_count',
661
+ description: 'The number of times a pipelined checkpoint was discarded because the parent did not match expectations',
662
+ valueType: ValueType.INT,
663
+ };
517
664
 
518
665
  // Fisherman fee analysis metrics
519
666
  export const FISHERMAN_FEE_ANALYSIS_WOULD_BE_INCLUDED: MetricDefinition = {
@@ -681,6 +828,24 @@ export const L1_PUBLISHER_TX_TOTAL_FEE: MetricDefinition = {
681
828
  unit: 'eth',
682
829
  valueType: ValueType.DOUBLE,
683
830
  };
831
+ export const PROVER_NODE_ESTIMATED_SUBMISSION_GAS: MetricDefinition = {
832
+ name: 'aztec.prover_node.estimated_submission.gas',
833
+ description: 'Estimated gas for a proof submission tx (proof publishing disabled, not actually sent)',
834
+ unit: 'gas',
835
+ valueType: ValueType.INT,
836
+ };
837
+ export const PROVER_NODE_ESTIMATED_SUBMISSION_GAS_PRICE: MetricDefinition = {
838
+ name: 'aztec.prover_node.estimated_submission.gas_price',
839
+ description: 'Estimated effective gas price for a proof submission tx (proof publishing disabled, not actually sent)',
840
+ unit: 'gwei',
841
+ valueType: ValueType.DOUBLE,
842
+ };
843
+ export const PROVER_NODE_ESTIMATED_SUBMISSION_TOTAL_FEE: MetricDefinition = {
844
+ name: 'aztec.prover_node.estimated_submission.total_fee',
845
+ description: 'Estimated total L1 fee for a proof submission tx (proof publishing disabled, not actually sent)',
846
+ unit: 'eth',
847
+ valueType: ValueType.DOUBLE,
848
+ };
684
849
 
685
850
  export const L1_BLOCK_HEIGHT: MetricDefinition = {
686
851
  name: 'aztec.l1.block_height',
@@ -909,6 +1074,19 @@ export const P2P_GOSSIP_AGG_MESSAGE_VALIDATION_DURATION_AVG: MetricDefinition =
909
1074
  valueType: ValueType.INT,
910
1075
  };
911
1076
 
1077
+ export const P2P_GOSSIP_SLOW_VALIDATION_COUNT: MetricDefinition = {
1078
+ name: 'aztec.p2p.gossip.slow_validation_count',
1079
+ description: 'Number of gossip validations that exceeded 75% of the mcache eviction window',
1080
+ valueType: ValueType.INT,
1081
+ };
1082
+
1083
+ export const P2P_GOSSIP_TX_VALIDATION_STAGE_DURATION: MetricDefinition = {
1084
+ name: 'aztec.p2p.gossip.tx_validation_stage_duration',
1085
+ description: 'Duration of each stage of gossiped tx validation, keyed by the tx_validation_stage attribute',
1086
+ unit: 'ms',
1087
+ valueType: ValueType.INT,
1088
+ };
1089
+
912
1090
  export const PUBLIC_PROCESSOR_TX_DURATION: MetricDefinition = {
913
1091
  name: 'aztec.public_processor.tx_duration',
914
1092
  description: 'Duration to process a public transaction',
@@ -972,6 +1150,17 @@ export const PUBLIC_PROCESSOR_TREE_INSERTION: MetricDefinition = {
972
1150
  unit: 'ms',
973
1151
  valueType: ValueType.INT,
974
1152
  };
1153
+ export const PUBLIC_PROCESSOR_SILENTLY_SKIPPED_COUNT: MetricDefinition = {
1154
+ name: 'aztec.public_processor.silently_skipped_count',
1155
+ description: 'Public txs fully processed then skipped (e.g. blob-field limit); not counted as processed or failed',
1156
+ valueType: ValueType.INT,
1157
+ };
1158
+ export const PUBLIC_PROCESSOR_SILENTLY_SKIPPED_DURATION: MetricDefinition = {
1159
+ name: 'aztec.public_processor.silently_skipped_duration',
1160
+ description: 'Wall-clock time spent processing txs that were then silently skipped',
1161
+ unit: 'ms',
1162
+ valueType: ValueType.INT,
1163
+ };
975
1164
 
976
1165
  export const PUBLIC_EXECUTOR_PREFIX = 'aztec.public_executor.';
977
1166
  export const PUBLIC_EXECUTOR_SIMULATION_COUNT: MetricDefinition = {
@@ -1116,12 +1305,6 @@ export const PROVING_AGENT_IDLE: MetricDefinition = {
1116
1305
  valueType: ValueType.DOUBLE,
1117
1306
  };
1118
1307
 
1119
- export const PROVER_NODE_EXECUTION_DURATION: MetricDefinition = {
1120
- name: 'aztec.prover_node.execution.duration',
1121
- description: 'Duration of execution of an epoch by the prover',
1122
- unit: 'ms',
1123
- valueType: ValueType.INT,
1124
- };
1125
1308
  export const PROVER_NODE_JOB_DURATION: MetricDefinition = {
1126
1309
  name: 'aztec.prover_node.job_duration',
1127
1310
  description: 'Duration of proving job',
@@ -1149,12 +1332,6 @@ export const PROVER_NODE_BLOB_PROCESSING_LAST_DURATION: MetricDefinition = {
1149
1332
  unit: 'ms',
1150
1333
  valueType: ValueType.INT,
1151
1334
  };
1152
- export const PROVER_NODE_CHONK_VERIFIER_LAST_DURATION: MetricDefinition = {
1153
- name: 'aztec.prover_node.chonk_verifier.last_duration',
1154
- description: 'Duration of chonk verifier enqueuing in epoch proving job',
1155
- unit: 'ms',
1156
- valueType: ValueType.INT,
1157
- };
1158
1335
  export const PROVER_NODE_BLOCK_PROCESSING_DURATION: MetricDefinition = {
1159
1336
  name: 'aztec.prover_node.block_processing.duration',
1160
1337
  description: 'Duration of processing a single block in epoch proving job',
@@ -1167,12 +1344,33 @@ export const PROVER_NODE_CHECKPOINT_PROCESSING_DURATION: MetricDefinition = {
1167
1344
  unit: 'ms',
1168
1345
  valueType: ValueType.INT,
1169
1346
  };
1170
- export const PROVER_NODE_ALL_CHECKPOINTS_PROCESSING_LAST_DURATION: MetricDefinition = {
1171
- name: 'aztec.prover_node.all_checkpoints_processing.last_duration',
1172
- description: 'Duration of processing all checkpoints in epoch proving job',
1347
+ export const PROVER_NODE_CHECKPOINT_BLOCKS: MetricDefinition = {
1348
+ name: 'aztec.prover_node.checkpoint_blocks',
1349
+ description: 'Number of blocks in a proven checkpoint',
1350
+ valueType: ValueType.INT,
1351
+ };
1352
+ export const PROVER_NODE_CHECKPOINT_TRANSACTIONS: MetricDefinition = {
1353
+ name: 'aztec.prover_node.checkpoint_transactions',
1354
+ description: 'Number of transactions in a proven checkpoint',
1355
+ valueType: ValueType.INT,
1356
+ };
1357
+ export const PROVER_NODE_CHECKPOINT_PROVING_DURATION: MetricDefinition = {
1358
+ name: 'aztec.prover_node.checkpoint_proving.duration',
1359
+ description:
1360
+ 'Duration from the start of checkpoint processing to its block proofs being ready (excludes tx gathering)',
1173
1361
  unit: 'ms',
1174
1362
  valueType: ValueType.INT,
1175
1363
  };
1364
+ export const PROVER_NODE_ACTIVE_CHECKPOINTS: MetricDefinition = {
1365
+ name: 'aztec.prover_node.active_checkpoints',
1366
+ description: 'Current number of canonical CheckpointProvers in the store (i.e. checkpoints currently being proven)',
1367
+ valueType: ValueType.INT,
1368
+ };
1369
+ export const PROVER_NODE_ACTIVE_EPOCH_SESSIONS: MetricDefinition = {
1370
+ name: 'aztec.prover_node.active_epoch_sessions',
1371
+ description: 'Current number of live EpochSessions, broken down by kind (full|partial)',
1372
+ valueType: ValueType.INT,
1373
+ };
1176
1374
  export const PROVER_NODE_REWARDS_TOTAL: MetricDefinition = {
1177
1375
  name: 'aztec.prover_node.rewards_total',
1178
1376
  description: 'The rewards earned (total)',
@@ -1286,6 +1484,19 @@ export const VALIDATOR_RE_EXECUTION_TX_COUNT: MetricDefinition = {
1286
1484
  unit: 'tx',
1287
1485
  valueType: ValueType.INT,
1288
1486
  };
1487
+ export const VALIDATOR_CHECKPOINT_PROPOSAL_TO_PIPELINED_STATE_DURATION: MetricDefinition = {
1488
+ name: 'aztec.validator.checkpoint_proposal_to_pipelined_state_duration',
1489
+ description: 'Time from receiving a checkpoint proposal to setting proposed checkpoint state for pipelining',
1490
+ unit: 'ms',
1491
+ valueType: ValueType.INT,
1492
+ };
1493
+ export const VALIDATOR_CHECKPOINT_PROPOSAL_RECEIVE_OFFSET_FROM_NEXT_SLOT_BOUNDARY: MetricDefinition = {
1494
+ name: 'aztec.validator.checkpoint.proposal_receive_offset_from_next_slot_boundary',
1495
+ description:
1496
+ 'Absolute offset from the next slot boundary when a foreign checkpoint proposal is received. Use aztec.slot_boundary_side to distinguish before vs after the boundary.',
1497
+ unit: 'ms',
1498
+ valueType: ValueType.INT,
1499
+ };
1289
1500
 
1290
1501
  export const VALIDATOR_FAILED_REEXECUTION_COUNT: MetricDefinition = {
1291
1502
  name: 'aztec.validator.failed_reexecution_count',