@aztec/telemetry-client 0.0.1-commit.993d52e → 0.0.1-commit.9a89641

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 (46) hide show
  1. package/dest/attributes.d.ts +11 -2
  2. package/dest/attributes.d.ts.map +1 -1
  3. package/dest/attributes.js +5 -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/lmdb_metrics.d.ts +2 -2
  8. package/dest/lmdb_metrics.d.ts.map +1 -1
  9. package/dest/metrics.d.ts +44 -2
  10. package/dest/metrics.d.ts.map +1 -1
  11. package/dest/metrics.js +238 -8
  12. package/dest/monitored_batch_span_processor.d.ts +29 -0
  13. package/dest/monitored_batch_span_processor.d.ts.map +1 -0
  14. package/dest/monitored_batch_span_processor.js +75 -0
  15. package/dest/otel.d.ts +6 -1
  16. package/dest/otel.d.ts.map +1 -1
  17. package/dest/otel.js +99 -4
  18. package/dest/otel_propagation.d.ts +3 -1
  19. package/dest/otel_propagation.d.ts.map +1 -1
  20. package/dest/otel_propagation.js +49 -1
  21. package/dest/start.d.ts +1 -1
  22. package/dest/start.d.ts.map +1 -1
  23. package/dest/start.js +1 -1
  24. package/dest/telemetry.d.ts +2 -2
  25. package/dest/telemetry.d.ts.map +1 -1
  26. package/dest/wrappers/fetch.d.ts +3 -3
  27. package/dest/wrappers/fetch.d.ts.map +1 -1
  28. package/dest/wrappers/fetch.js +3 -2
  29. package/dest/wrappers/index.d.ts +1 -2
  30. package/dest/wrappers/index.d.ts.map +1 -1
  31. package/dest/wrappers/index.js +0 -1
  32. package/package.json +3 -3
  33. package/src/attributes.ts +12 -1
  34. package/src/config.ts +24 -9
  35. package/src/metrics.ts +255 -8
  36. package/src/monitored_batch_span_processor.ts +100 -0
  37. package/src/otel.ts +69 -3
  38. package/src/otel_propagation.ts +42 -1
  39. package/src/start.ts +6 -1
  40. package/src/telemetry.ts +0 -1
  41. package/src/wrappers/fetch.ts +9 -3
  42. package/src/wrappers/index.ts +0 -1
  43. package/dest/wrappers/l2_block_stream.d.ts +0 -16
  44. package/dest/wrappers/l2_block_stream.d.ts.map +0 -1
  45. package/dest/wrappers/l2_block_stream.js +0 -400
  46. package/src/wrappers/l2_block_stream.ts +0 -41
package/src/metrics.ts CHANGED
@@ -162,7 +162,7 @@ export const MEMPOOL_TX_ADDED_COUNT: MetricDefinition = {
162
162
  };
163
163
  export const MEMPOOL_TX_MINED_DELAY: MetricDefinition = {
164
164
  name: 'aztec.mempool.tx_mined_delay',
165
- description: 'Delay between transaction added and evicted from the mempool',
165
+ description: 'Delay (ms) from a transaction being received into the pool to being mined',
166
166
  unit: 'ms',
167
167
  valueType: ValueType.INT,
168
168
  };
@@ -308,6 +308,12 @@ export const ARCHIVER_SYNC_PER_BLOCK: MetricDefinition = {
308
308
  unit: 'ms',
309
309
  valueType: ValueType.INT,
310
310
  };
311
+ export const ARCHIVER_SYNC_PER_CHECKPOINT: MetricDefinition = {
312
+ name: 'aztec.archiver.checkpoint.sync_per_item_duration',
313
+ description: 'Duration to sync a checkpoint',
314
+ unit: 'ms',
315
+ valueType: ValueType.INT,
316
+ };
311
317
  export const ARCHIVER_SYNC_BLOCK_COUNT: MetricDefinition = {
312
318
  name: 'aztec.archiver.block.sync_count',
313
319
  description: 'Number of blocks synced from L1',
@@ -334,7 +340,8 @@ export const ARCHIVER_PRUNE_DURATION: MetricDefinition = {
334
340
  };
335
341
  export const ARCHIVER_PRUNE_COUNT: MetricDefinition = {
336
342
  name: 'aztec.archiver.prune_count',
337
- description: 'Number of prunes detected',
343
+ description:
344
+ '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
345
  valueType: ValueType.INT,
339
346
  };
340
347
 
@@ -350,6 +357,19 @@ export const ARCHIVER_BLOCK_PROPOSAL_TX_TARGET_COUNT: MetricDefinition = {
350
357
  valueType: ValueType.INT,
351
358
  };
352
359
 
360
+ export const ARCHIVER_CHECKPOINT_L1_INCLUSION_DELAY: MetricDefinition = {
361
+ name: 'aztec.archiver.checkpoint_l1_inclusion_delay',
362
+ description: 'Seconds into the L2 slot when the checkpoint L1 tx was included',
363
+ unit: 's',
364
+ valueType: ValueType.INT,
365
+ };
366
+
367
+ export const ARCHIVER_CHECKPOINT_PROMOTED_COUNT: MetricDefinition = {
368
+ name: 'aztec.archiver.checkpoint_promoted_count',
369
+ description: 'Number of checkpoints promoted from proposed (blob fetch skipped)',
370
+ valueType: ValueType.INT,
371
+ };
372
+
353
373
  export const NODE_RECEIVE_TX_DURATION: MetricDefinition = {
354
374
  name: 'aztec.node.receive_tx.duration',
355
375
  description: 'The duration of the receiveTx method',
@@ -381,6 +401,12 @@ export const SEQUENCER_STATE_TRANSITION_BUFFER_DURATION: MetricDefinition = {
381
401
  unit: 'ms',
382
402
  valueType: ValueType.INT,
383
403
  };
404
+ export const SEQUENCER_STATE_DURATION: MetricDefinition = {
405
+ name: 'aztec.sequencer.state_duration',
406
+ description: 'Wall-clock time spent in each sequencer state, labelled by the state being left',
407
+ unit: 'ms',
408
+ valueType: ValueType.INT,
409
+ };
384
410
  export const SEQUENCER_BLOCK_BUILD_DURATION: MetricDefinition = {
385
411
  name: 'aztec.sequencer.block.build_duration',
386
412
  description: 'Duration to build a block',
@@ -398,6 +424,12 @@ export const SEQUENCER_BLOCK_COUNT: MetricDefinition = {
398
424
  description: 'Number of blocks built by this sequencer',
399
425
  valueType: ValueType.INT,
400
426
  };
427
+ export const SEQUENCER_BLOCK_INTER_BLOCK_TIME: MetricDefinition = {
428
+ name: 'aztec.sequencer.block.inter_block_time',
429
+ description: 'Wall-clock time elapsed between consecutive blocks being built by this sequencer',
430
+ unit: 'ms',
431
+ valueType: ValueType.INT,
432
+ };
401
433
  export const SEQUENCER_CURRENT_SLOT_REWARDS: MetricDefinition = {
402
434
  name: 'aztec.sequencer.current_slot_rewards',
403
435
  description: 'The rewards earned per filled slot',
@@ -470,6 +502,25 @@ export const SEQUENCER_CHECKPOINT_BUILD_DURATION: MetricDefinition = {
470
502
  unit: 'ms',
471
503
  valueType: ValueType.INT,
472
504
  };
505
+ export const SEQUENCER_CHECKPOINT_START_TO_FIRST_BLOCK_DURATION: MetricDefinition = {
506
+ name: 'aztec.sequencer.checkpoint.start_to_first_block_duration',
507
+ description: 'Time from starting checkpoint work to the first block finishing build',
508
+ unit: 'ms',
509
+ valueType: ValueType.INT,
510
+ };
511
+ export const SEQUENCER_CHECKPOINT_LAST_BLOCK_TO_BROADCAST_DURATION: MetricDefinition = {
512
+ name: 'aztec.sequencer.checkpoint.last_block_to_broadcast_duration',
513
+ description: 'Time from the final block finishing build to the checkpoint proposal being broadcast',
514
+ unit: 'ms',
515
+ valueType: ValueType.INT,
516
+ };
517
+ export const SEQUENCER_PIPELINED_CHECKPOINT_BUILD_START_OFFSET_FROM_SLOT_BOUNDARY: MetricDefinition = {
518
+ name: 'aztec.sequencer.pipelined_checkpoint.build_start_offset_from_slot_boundary',
519
+ description:
520
+ '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.',
521
+ unit: 'ms',
522
+ valueType: ValueType.INT,
523
+ };
473
524
  export const SEQUENCER_CHECKPOINT_BLOCK_COUNT: MetricDefinition = {
474
525
  name: 'aztec.sequencer.checkpoint.block_count',
475
526
  description: 'Number of blocks built in a checkpoint',
@@ -492,11 +543,66 @@ export const SEQUENCER_SLASHING_ATTEMPTS_COUNT: MetricDefinition = {
492
543
  description: 'The number of slashing action attempts',
493
544
  valueType: ValueType.INT,
494
545
  };
546
+ export const SLASHER_ROUND_EXECUTED_COUNT: MetricDefinition = {
547
+ name: 'aztec.slasher.round.executed_count',
548
+ description: 'The number of slashing rounds executed',
549
+ valueType: ValueType.INT,
550
+ };
551
+ export const SLASHER_OWN_VALIDATOR_TARGETED_COUNT: MetricDefinition = {
552
+ name: 'aztec.slasher.own_validator.targeted_count',
553
+ description:
554
+ "The number of times one of the node's own validators was named as a slash target by an onchain vote, counted " +
555
+ 'once per vote per validator. Votes cast while the node is offline or starting up are not counted, and L1 ' +
556
+ 'reorgs can cause small drift within a round.',
557
+ valueType: ValueType.INT,
558
+ };
559
+ export const SLASHER_OWN_VALIDATOR_CURRENT_ROUND_VOTES_MAX: MetricDefinition = {
560
+ name: 'aztec.slasher.own_validator.current_round_votes_max',
561
+ description:
562
+ "Highest number of votes cast against any committee position held by the node's own validators in the current " +
563
+ 'slashing round, to compare against aztec.slasher.quorum_size (the contract tallies quorum per position). ' +
564
+ 'Resets to zero when a new round starts. Votes cast while the node is offline or starting up are not counted, ' +
565
+ 'and L1 reorgs can cause small drift within a round.',
566
+ valueType: ValueType.INT,
567
+ };
568
+ export const SLASHER_QUORUM_SIZE: MetricDefinition = {
569
+ name: 'aztec.slasher.quorum_size',
570
+ description: 'The number of votes a validator must receive in a round to be slashed',
571
+ valueType: ValueType.INT,
572
+ };
573
+ export const SLASHER_OWN_VALIDATOR_SLASHED_COUNT: MetricDefinition = {
574
+ name: 'aztec.slasher.own_validator.slashed_count',
575
+ description: "The number of times one of the node's own validators was slashed, from executed Slashed events",
576
+ valueType: ValueType.INT,
577
+ };
578
+ export const SLASHER_OWN_VALIDATOR_SLASHED_AMOUNT: MetricDefinition = {
579
+ name: 'aztec.slasher.own_validator.slashed_amount',
580
+ description:
581
+ "Cumulative amount slashed from the node's own validators in whole staking-asset tokens, from executed " +
582
+ 'Slashed events',
583
+ unit: 'tokens',
584
+ valueType: ValueType.DOUBLE,
585
+ };
495
586
  export const SEQUENCER_CHECKPOINT_SUCCESS_COUNT: MetricDefinition = {
496
587
  name: 'aztec.sequencer.checkpoint.success_count',
497
588
  description: 'The number of times checkpoint publishing succeeded',
498
589
  valueType: ValueType.INT,
499
590
  };
591
+ export const SEQUENCER_PIPELINE_DEPTH: MetricDefinition = {
592
+ name: 'aztec.sequencer.pipeline.depth',
593
+ description: 'Current pipeline depth when builder pipelining is enabled',
594
+ valueType: ValueType.INT,
595
+ };
596
+ export const SEQUENCER_PIPELINE_DISCARDS_COUNT: MetricDefinition = {
597
+ name: 'aztec.sequencer.pipeline.discards_count',
598
+ description: 'The number of times a pipeline was discarded',
599
+ valueType: ValueType.INT,
600
+ };
601
+ export const SEQUENCER_PIPELINE_PARENT_CHECKPOINT_MISMATCH_COUNT: MetricDefinition = {
602
+ name: 'aztec.sequencer.pipeline.parent_checkpoint_mismatch_count',
603
+ description: 'The number of times a pipelined checkpoint was discarded because the parent did not match expectations',
604
+ valueType: ValueType.INT,
605
+ };
500
606
 
501
607
  // Fisherman fee analysis metrics
502
608
  export const FISHERMAN_FEE_ANALYSIS_WOULD_BE_INCLUDED: MetricDefinition = {
@@ -664,6 +770,24 @@ export const L1_PUBLISHER_TX_TOTAL_FEE: MetricDefinition = {
664
770
  unit: 'eth',
665
771
  valueType: ValueType.DOUBLE,
666
772
  };
773
+ export const PROVER_NODE_ESTIMATED_SUBMISSION_GAS: MetricDefinition = {
774
+ name: 'aztec.prover_node.estimated_submission.gas',
775
+ description: 'Estimated gas for a proof submission tx (proof publishing disabled, not actually sent)',
776
+ unit: 'gas',
777
+ valueType: ValueType.INT,
778
+ };
779
+ export const PROVER_NODE_ESTIMATED_SUBMISSION_GAS_PRICE: MetricDefinition = {
780
+ name: 'aztec.prover_node.estimated_submission.gas_price',
781
+ description: 'Estimated effective gas price for a proof submission tx (proof publishing disabled, not actually sent)',
782
+ unit: 'gwei',
783
+ valueType: ValueType.DOUBLE,
784
+ };
785
+ export const PROVER_NODE_ESTIMATED_SUBMISSION_TOTAL_FEE: MetricDefinition = {
786
+ name: 'aztec.prover_node.estimated_submission.total_fee',
787
+ description: 'Estimated total L1 fee for a proof submission tx (proof publishing disabled, not actually sent)',
788
+ unit: 'eth',
789
+ valueType: ValueType.DOUBLE,
790
+ };
667
791
 
668
792
  export const L1_BLOCK_HEIGHT: MetricDefinition = {
669
793
  name: 'aztec.l1.block_height',
@@ -757,6 +881,12 @@ export const PEER_MANAGER_PEER_COUNT: MetricDefinition = {
757
881
  unit: 'peers',
758
882
  valueType: ValueType.INT,
759
883
  };
884
+ export const PEER_MANAGER_HEALTHY_PEER_COUNT: MetricDefinition = {
885
+ name: 'aztec.peer_manager.healthy_peer_count',
886
+ description: 'Number of healthy (non-protected, non-banned) peers',
887
+ unit: 'peers',
888
+ valueType: ValueType.INT,
889
+ };
760
890
  export const PEER_MANAGER_LOW_SCORE_DISCONNECTS: MetricDefinition = {
761
891
  name: 'aztec.peer_manager.low_score_disconnects',
762
892
  description: 'Number of peers disconnected due to low score',
@@ -886,6 +1016,12 @@ export const P2P_GOSSIP_AGG_MESSAGE_VALIDATION_DURATION_AVG: MetricDefinition =
886
1016
  valueType: ValueType.INT,
887
1017
  };
888
1018
 
1019
+ export const P2P_GOSSIP_SLOW_VALIDATION_COUNT: MetricDefinition = {
1020
+ name: 'aztec.p2p.gossip.slow_validation_count',
1021
+ description: 'Number of gossip validations that exceeded 75% of the mcache eviction window',
1022
+ valueType: ValueType.INT,
1023
+ };
1024
+
889
1025
  export const PUBLIC_PROCESSOR_TX_DURATION: MetricDefinition = {
890
1026
  name: 'aztec.public_processor.tx_duration',
891
1027
  description: 'Duration to process a public transaction',
@@ -949,6 +1085,17 @@ export const PUBLIC_PROCESSOR_TREE_INSERTION: MetricDefinition = {
949
1085
  unit: 'ms',
950
1086
  valueType: ValueType.INT,
951
1087
  };
1088
+ export const PUBLIC_PROCESSOR_SILENTLY_SKIPPED_COUNT: MetricDefinition = {
1089
+ name: 'aztec.public_processor.silently_skipped_count',
1090
+ description: 'Public txs fully processed then skipped (e.g. blob-field limit); not counted as processed or failed',
1091
+ valueType: ValueType.INT,
1092
+ };
1093
+ export const PUBLIC_PROCESSOR_SILENTLY_SKIPPED_DURATION: MetricDefinition = {
1094
+ name: 'aztec.public_processor.silently_skipped_duration',
1095
+ description: 'Wall-clock time spent processing txs that were then silently skipped',
1096
+ unit: 'ms',
1097
+ valueType: ValueType.INT,
1098
+ };
952
1099
 
953
1100
  export const PUBLIC_EXECUTOR_PREFIX = 'aztec.public_executor.';
954
1101
  export const PUBLIC_EXECUTOR_SIMULATION_COUNT: MetricDefinition = {
@@ -1093,12 +1240,6 @@ export const PROVING_AGENT_IDLE: MetricDefinition = {
1093
1240
  valueType: ValueType.DOUBLE,
1094
1241
  };
1095
1242
 
1096
- export const PROVER_NODE_EXECUTION_DURATION: MetricDefinition = {
1097
- name: 'aztec.prover_node.execution.duration',
1098
- description: 'Duration of execution of an epoch by the prover',
1099
- unit: 'ms',
1100
- valueType: ValueType.INT,
1101
- };
1102
1243
  export const PROVER_NODE_JOB_DURATION: MetricDefinition = {
1103
1244
  name: 'aztec.prover_node.job_duration',
1104
1245
  description: 'Duration of proving job',
@@ -1120,6 +1261,51 @@ export const PROVER_NODE_JOB_TRANSACTIONS: MetricDefinition = {
1120
1261
  description: 'Number of transactions in a proven epoch',
1121
1262
  valueType: ValueType.INT,
1122
1263
  };
1264
+ export const PROVER_NODE_BLOB_PROCESSING_LAST_DURATION: MetricDefinition = {
1265
+ name: 'aztec.prover_node.blob_processing.last_duration',
1266
+ description: 'Duration of blob processing step in epoch proving job',
1267
+ unit: 'ms',
1268
+ valueType: ValueType.INT,
1269
+ };
1270
+ export const PROVER_NODE_BLOCK_PROCESSING_DURATION: MetricDefinition = {
1271
+ name: 'aztec.prover_node.block_processing.duration',
1272
+ description: 'Duration of processing a single block in epoch proving job',
1273
+ unit: 'ms',
1274
+ valueType: ValueType.INT,
1275
+ };
1276
+ export const PROVER_NODE_CHECKPOINT_PROCESSING_DURATION: MetricDefinition = {
1277
+ name: 'aztec.prover_node.checkpoint_processing.duration',
1278
+ description: 'Duration of processing a single checkpoint in epoch proving job',
1279
+ unit: 'ms',
1280
+ valueType: ValueType.INT,
1281
+ };
1282
+ export const PROVER_NODE_CHECKPOINT_BLOCKS: MetricDefinition = {
1283
+ name: 'aztec.prover_node.checkpoint_blocks',
1284
+ description: 'Number of blocks in a proven checkpoint',
1285
+ valueType: ValueType.INT,
1286
+ };
1287
+ export const PROVER_NODE_CHECKPOINT_TRANSACTIONS: MetricDefinition = {
1288
+ name: 'aztec.prover_node.checkpoint_transactions',
1289
+ description: 'Number of transactions in a proven checkpoint',
1290
+ valueType: ValueType.INT,
1291
+ };
1292
+ export const PROVER_NODE_CHECKPOINT_PROVING_DURATION: MetricDefinition = {
1293
+ name: 'aztec.prover_node.checkpoint_proving.duration',
1294
+ description:
1295
+ 'Duration from the start of checkpoint processing to its block proofs being ready (excludes tx gathering)',
1296
+ unit: 'ms',
1297
+ valueType: ValueType.INT,
1298
+ };
1299
+ export const PROVER_NODE_ACTIVE_CHECKPOINTS: MetricDefinition = {
1300
+ name: 'aztec.prover_node.active_checkpoints',
1301
+ description: 'Current number of canonical CheckpointProvers in the store (i.e. checkpoints currently being proven)',
1302
+ valueType: ValueType.INT,
1303
+ };
1304
+ export const PROVER_NODE_ACTIVE_EPOCH_SESSIONS: MetricDefinition = {
1305
+ name: 'aztec.prover_node.active_epoch_sessions',
1306
+ description: 'Current number of live EpochSessions, broken down by kind (full|partial)',
1307
+ valueType: ValueType.INT,
1308
+ };
1123
1309
  export const PROVER_NODE_REWARDS_TOTAL: MetricDefinition = {
1124
1310
  name: 'aztec.prover_node.rewards_total',
1125
1311
  description: 'The rewards earned (total)',
@@ -1233,6 +1419,19 @@ export const VALIDATOR_RE_EXECUTION_TX_COUNT: MetricDefinition = {
1233
1419
  unit: 'tx',
1234
1420
  valueType: ValueType.INT,
1235
1421
  };
1422
+ export const VALIDATOR_CHECKPOINT_PROPOSAL_TO_PIPELINED_STATE_DURATION: MetricDefinition = {
1423
+ name: 'aztec.validator.checkpoint_proposal_to_pipelined_state_duration',
1424
+ description: 'Time from receiving a checkpoint proposal to setting proposed checkpoint state for pipelining',
1425
+ unit: 'ms',
1426
+ valueType: ValueType.INT,
1427
+ };
1428
+ export const VALIDATOR_CHECKPOINT_PROPOSAL_RECEIVE_OFFSET_FROM_NEXT_SLOT_BOUNDARY: MetricDefinition = {
1429
+ name: 'aztec.validator.checkpoint.proposal_receive_offset_from_next_slot_boundary',
1430
+ description:
1431
+ '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.',
1432
+ unit: 'ms',
1433
+ valueType: ValueType.INT,
1434
+ };
1236
1435
 
1237
1436
  export const VALIDATOR_FAILED_REEXECUTION_COUNT: MetricDefinition = {
1238
1437
  name: 'aztec.validator.failed_reexecution_count',
@@ -1488,3 +1687,51 @@ export const IVC_VERIFIER_AGG_DURATION_AVG: MetricDefinition = {
1488
1687
  unit: 'ms',
1489
1688
  valueType: ValueType.DOUBLE,
1490
1689
  };
1690
+
1691
+ // HA Signer metrics
1692
+ export const HA_SIGNER_SIGNING_DURATION: MetricDefinition = {
1693
+ name: 'aztec.ha_signer.signing_duration',
1694
+ description: 'End-to-end duration for signing with HA protection (lock + sign + record)',
1695
+ unit: 'ms',
1696
+ valueType: ValueType.INT,
1697
+ };
1698
+ export const HA_SIGNER_SIGNING_SUCCESS_COUNT: MetricDefinition = {
1699
+ name: 'aztec.ha_signer.signing_success_count',
1700
+ description: 'Count of successful signing operations',
1701
+ valueType: ValueType.INT,
1702
+ };
1703
+ export const HA_SIGNER_DUTY_ALREADY_SIGNED_COUNT: MetricDefinition = {
1704
+ name: 'aztec.ha_signer.duty_already_signed_count',
1705
+ description: 'Count of DutyAlreadySignedError (expected in HA; another node signed first)',
1706
+ valueType: ValueType.INT,
1707
+ };
1708
+ export const HA_SIGNER_SLASHING_PROTECTION_COUNT: MetricDefinition = {
1709
+ name: 'aztec.ha_signer.slashing_protection_count',
1710
+ description: 'Count of SlashingProtectionError (attempted to sign different data)',
1711
+ valueType: ValueType.INT,
1712
+ };
1713
+ export const HA_SIGNER_SIGNING_ERROR_COUNT: MetricDefinition = {
1714
+ name: 'aztec.ha_signer.signing_error_count',
1715
+ description: 'Count of signing function failures (lock deleted for retry)',
1716
+ valueType: ValueType.INT,
1717
+ };
1718
+ export const HA_SIGNER_LOCK_ACQUIRED_COUNT: MetricDefinition = {
1719
+ name: 'aztec.ha_signer.lock_acquired_count',
1720
+ description: 'Count of lock acquisitions (new lock acquired vs existing record found)',
1721
+ valueType: ValueType.INT,
1722
+ };
1723
+ export const HA_SIGNER_CLEANUP_STUCK_DUTIES_COUNT: MetricDefinition = {
1724
+ name: 'aztec.ha_signer.cleanup_stuck_duties_count',
1725
+ description: 'Number of stuck duties cleaned up per cleanup run',
1726
+ valueType: ValueType.INT,
1727
+ };
1728
+ export const HA_SIGNER_CLEANUP_OLD_DUTIES_COUNT: MetricDefinition = {
1729
+ name: 'aztec.ha_signer.cleanup_old_duties_count',
1730
+ description: 'Number of old duties cleaned up',
1731
+ valueType: ValueType.INT,
1732
+ };
1733
+ export const HA_SIGNER_CLEANUP_OUTDATED_ROLLUP_DUTIES_COUNT: MetricDefinition = {
1734
+ name: 'aztec.ha_signer.cleanup_outdated_rollup_duties_count',
1735
+ description: 'Number of duties cleaned due to rollup upgrade',
1736
+ valueType: ValueType.INT,
1737
+ };
@@ -0,0 +1,100 @@
1
+ import type { Logger } from '@aztec/foundation/log';
2
+
3
+ import { type Context, SpanStatusCode } from '@opentelemetry/api';
4
+ import { hrTimeToMilliseconds } from '@opentelemetry/core';
5
+ import type { SpanExporter } from '@opentelemetry/sdk-trace-base';
6
+ import { BatchSpanProcessor, type BufferConfig, type ReadableSpan, type Span } from '@opentelemetry/sdk-trace-node';
7
+
8
+ /** Minimum interval between drop warnings to avoid log spam. */
9
+ const DROP_WARNING_INTERVAL_MS = 30_000;
10
+
11
+ const DEFAULT_MIN_TRACE_DURATION_MS = 10;
12
+
13
+ const DEFAULT_MAX_QUEUE_SIZE = 16384;
14
+
15
+ /** Cap on the per-export batch size, so a large queue can actually be drained instead of dribbling out
16
+ * at the SDK default of 512 spans per scheduled export. Kept <= maxQueueSize per the BatchSpanProcessor contract. */
17
+ const DEFAULT_MAX_EXPORT_BATCH_SIZE = 2048;
18
+
19
+ export type MonitoredBatchSpanProcessorConfig = BufferConfig & {
20
+ minTraceDurationMs?: number;
21
+ };
22
+
23
+ /**
24
+ * Wraps BatchSpanProcessor to emit warnings when spans are dropped due to a full queue.
25
+ * The standard BatchSpanProcessor silently discards spans when its internal queue reaches
26
+ * maxQueueSize, making telemetry data loss invisible to operators.
27
+ */
28
+ export class MonitoredBatchSpanProcessor extends BatchSpanProcessor {
29
+ private readonly maxQueueSize: number;
30
+ private readonly minTraceDurationMs: number;
31
+ private readonly log: Logger;
32
+
33
+ private approxQueueSize = 0;
34
+ private droppedSinceLastWarning = 0;
35
+ private totalDropped = 0;
36
+ private lastWarningTime = 0;
37
+
38
+ constructor(exporter: SpanExporter, log: Logger, config?: MonitoredBatchSpanProcessorConfig) {
39
+ const maxQueueSize = config?.maxQueueSize ?? DEFAULT_MAX_QUEUE_SIZE;
40
+ const maxExportBatchSize = Math.min(config?.maxExportBatchSize ?? DEFAULT_MAX_EXPORT_BATCH_SIZE, maxQueueSize);
41
+ super(exporter, { ...config, maxQueueSize, maxExportBatchSize });
42
+ this.maxQueueSize = maxQueueSize;
43
+ this.minTraceDurationMs = Math.max(0, config?.minTraceDurationMs ?? DEFAULT_MIN_TRACE_DURATION_MS);
44
+ this.log = log;
45
+ }
46
+
47
+ override onStart(span: Span, parentContext: Context): void {
48
+ super.onStart(span, parentContext);
49
+ }
50
+
51
+ override onEnd(span: ReadableSpan): void {
52
+ if (this.shouldDropShortSpan(span)) {
53
+ return;
54
+ }
55
+
56
+ if (this.approxQueueSize >= this.maxQueueSize) {
57
+ this.droppedSinceLastWarning++;
58
+ this.totalDropped++;
59
+ this.maybeLogDropWarning();
60
+ } else {
61
+ this.approxQueueSize++;
62
+ }
63
+ super.onEnd(span);
64
+ }
65
+
66
+ override async forceFlush(): Promise<void> {
67
+ await super.forceFlush();
68
+ this.approxQueueSize = 0;
69
+ }
70
+
71
+ override async shutdown(): Promise<void> {
72
+ if (this.totalDropped > 0) {
73
+ this.log.warn(`BatchSpanProcessor shutting down with ${this.totalDropped} total spans dropped`, {
74
+ totalDropped: this.totalDropped,
75
+ });
76
+ }
77
+ await super.shutdown();
78
+ }
79
+
80
+ private shouldDropShortSpan(span: ReadableSpan): boolean {
81
+ return (
82
+ this.minTraceDurationMs > 0 &&
83
+ span.status.code !== SpanStatusCode.ERROR &&
84
+ hrTimeToMilliseconds(span.duration) < this.minTraceDurationMs
85
+ );
86
+ }
87
+
88
+ private maybeLogDropWarning(): void {
89
+ const now = Date.now();
90
+ if (now - this.lastWarningTime >= DROP_WARNING_INTERVAL_MS) {
91
+ this.log.warn(
92
+ `BatchSpanProcessor dropping spans: queue full (maxQueueSize=${this.maxQueueSize}). ` +
93
+ `${this.droppedSinceLastWarning} dropped since last warning, ${this.totalDropped} total.`,
94
+ { droppedSinceLastWarning: this.droppedSinceLastWarning, totalDropped: this.totalDropped },
95
+ );
96
+ this.droppedSinceLastWarning = 0;
97
+ this.lastWarningTime = now;
98
+ }
99
+ }
100
+ }
package/src/otel.ts CHANGED
@@ -28,12 +28,13 @@ import {
28
28
  type PeriodicExportingMetricReaderOptions,
29
29
  View,
30
30
  } from '@opentelemetry/sdk-metrics';
31
- import { BatchSpanProcessor, NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
31
+ import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
32
32
  import { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION } from '@opentelemetry/semantic-conventions';
33
33
 
34
34
  import type { TelemetryClientConfig } from './config.js';
35
35
  import { toMetricOptions } from './metric-utils.js';
36
36
  import type { MetricDefinition } from './metrics.js';
37
+ import { MonitoredBatchSpanProcessor } from './monitored_batch_span_processor.js';
37
38
  import { NodejsMetricsMonitor } from './nodejs_metrics_monitor.js';
38
39
  import { OtelFilterMetricExporter, PublicOtelFilterMetricExporter } from './otel_filter_metric_exporter.js';
39
40
  import { registerOtelLoggerProvider } from './otel_logger_provider.js';
@@ -95,6 +96,11 @@ export class OpenTelemetryClient implements TelemetryClient {
95
96
  private meters: Map<string, WrappedMeter> = new Map<string, WrappedMeter>();
96
97
  private tracers: Map<string, Tracer> = new Map<string, Tracer>();
97
98
 
99
+ /** Memoized shutdown promise. The telemetry client is shared between the aztec-node and an embedded prover-node,
100
+ * so stop() can be invoked more than once; the providers throw "shutdown may only be called once" and
101
+ * "invalid attempt to force flush after shutdown" if that happens. Guarding here makes stop()/flush() idempotent. */
102
+ private stopPromise: Promise<void> | undefined;
103
+
98
104
  protected constructor(
99
105
  private resource: IResource,
100
106
  private meterProvider: MeterProvider,
@@ -168,6 +174,10 @@ export class OpenTelemetryClient implements TelemetryClient {
168
174
  }
169
175
 
170
176
  public async flush() {
177
+ // Flushing after the providers have been shut down throws "invalid attempt to force flush after shutdown".
178
+ if (this.stopPromise) {
179
+ return;
180
+ }
171
181
  await Promise.all([
172
182
  this.meterProvider.forceFlush(),
173
183
  this.loggerProvider?.forceFlush(),
@@ -175,7 +185,11 @@ export class OpenTelemetryClient implements TelemetryClient {
175
185
  ]);
176
186
  }
177
187
 
178
- public async stop() {
188
+ public stop() {
189
+ return (this.stopPromise ??= this.doStop());
190
+ }
191
+
192
+ private async doStop() {
179
193
  this.nodejsMetricsMonitor?.stop();
180
194
 
181
195
  const flushAndShutdown = async (provider?: { forceFlush: () => Promise<void>; shutdown: () => Promise<void> }) => {
@@ -241,6 +255,23 @@ export class OpenTelemetryClient implements TelemetryClient {
241
255
  true,
242
256
  ),
243
257
  }),
258
+ // Pending-to-mined delay routinely exceeds the 1-minute ceiling of the generic `ms`
259
+ // view below under load, so it would saturate at 60s. Give this one metric wider
260
+ // buckets (1s to 10min). This must precede the generic `ms` view: when multiple views
261
+ // match an instrument, the SDK keeps the first-registered compatible storage, so the
262
+ // first view in this list wins the bucket boundaries.
263
+ new View({
264
+ instrumentType: InstrumentType.HISTOGRAM,
265
+ instrumentName: 'aztec.mempool.tx_mined_delay',
266
+ instrumentUnit: 'ms',
267
+ aggregation: new ExplicitBucketHistogramAggregation(
268
+ [
269
+ 1_000, 2_500, 5_000, 7_500, 10_000, 15_000, 30_000, 45_000, 60_000, 90_000, 120_000, 180_000, 300_000,
270
+ 600_000,
271
+ ],
272
+ true,
273
+ ),
274
+ }),
244
275
  new View({
245
276
  instrumentType: InstrumentType.HISTOGRAM,
246
277
  instrumentUnit: 'ms',
@@ -334,6 +365,36 @@ export class OpenTelemetryClient implements TelemetryClient {
334
365
  true,
335
366
  ),
336
367
  }),
368
+ // L1 gas prices in gwei: priority fees ~0.01-10, base fees ~1-500, spikes to 1000+
369
+ new View({
370
+ instrumentType: InstrumentType.HISTOGRAM,
371
+ instrumentUnit: 'gwei',
372
+ aggregation: new ExplicitBucketHistogramAggregation(
373
+ [0.1, 0.5, 1, 2, 5, 10, 20, 50, 100, 200, 500, 1_000],
374
+ true,
375
+ ),
376
+ }),
377
+ // L1 gas consumption: tx gas 100k-30M, calldata/blob gas varies
378
+ new View({
379
+ instrumentType: InstrumentType.HISTOGRAM,
380
+ instrumentUnit: 'gas',
381
+ aggregation: new ExplicitBucketHistogramAggregation(
382
+ [
383
+ 10_000, 50_000, 100_000, 250_000, 500_000, 1_000_000, 2_000_000, 5_000_000, 10_000_000, 15_000_000,
384
+ 30_000_000,
385
+ ],
386
+ true,
387
+ ),
388
+ }),
389
+ // L1 tx total fee in ETH: typically 0.001 - 1 ETH
390
+ new View({
391
+ instrumentType: InstrumentType.HISTOGRAM,
392
+ instrumentUnit: 'eth',
393
+ aggregation: new ExplicitBucketHistogramAggregation(
394
+ [0.0001, 0.0005, 0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1, 5, 10],
395
+ true,
396
+ ),
397
+ }),
337
398
  ],
338
399
  });
339
400
  }
@@ -343,7 +404,12 @@ export class OpenTelemetryClient implements TelemetryClient {
343
404
  const tracerProvider = new NodeTracerProvider({
344
405
  resource,
345
406
  spanProcessors: config.tracesCollectorUrl
346
- ? [new BatchSpanProcessor(new OTLPTraceExporter({ url: config.tracesCollectorUrl.href }))]
407
+ ? [
408
+ new MonitoredBatchSpanProcessor(new OTLPTraceExporter({ url: config.tracesCollectorUrl.href }), log, {
409
+ maxQueueSize: config.otelBspMaxQueueSize,
410
+ minTraceDurationMs: config.otelMinTraceDurationMs,
411
+ }),
412
+ ]
347
413
  : [],
348
414
  });
349
415
 
@@ -1,3 +1,5 @@
1
+ import type { DiagnosticsMiddleware } from '@aztec/foundation/json-rpc/server';
2
+
1
3
  import { ROOT_CONTEXT, type Span, SpanKind, SpanStatusCode, propagation } from '@opentelemetry/api';
2
4
  import type Koa from 'koa';
3
5
 
@@ -17,7 +19,7 @@ export function getOtelJsonRpcPropagationMiddleware(
17
19
  const context = propagation.extract(ROOT_CONTEXT, ctx.request.headers);
18
20
  const method = (ctx.request.body as any)?.method;
19
21
  return tracer.startActiveSpan(
20
- `JsonRpcServer.${method ?? 'unknown'}`,
22
+ `JsonRpcServer.${method ?? 'batch'}`,
21
23
  { kind: SpanKind.SERVER },
22
24
  context,
23
25
  async (span: Span): Promise<void> => {
@@ -48,3 +50,42 @@ export function getOtelJsonRpcPropagationMiddleware(
48
50
  );
49
51
  };
50
52
  }
53
+
54
+ export function getOtelJsonRpcDiagnosticsMiddleware(): DiagnosticsMiddleware {
55
+ return function otelJsonRpcDiagnostics(ctx, next) {
56
+ const [namespace, method] = splitNamespace(ctx.method);
57
+ const scope = namespace ?? 'UnknownHandler';
58
+ const tracer = getTelemetryClient().getTracer(scope);
59
+ return tracer.startActiveSpan(
60
+ `${scope}.${method}`,
61
+ { kind: SpanKind.INTERNAL, attributes: { [ATTR_JSONRPC_METHOD]: ctx.method } },
62
+ async span => {
63
+ if (ctx.id !== null) {
64
+ span.setAttribute(ATTR_JSONRPC_REQUEST_ID, ctx.id);
65
+ }
66
+
67
+ try {
68
+ await next();
69
+ span.setStatus({ code: SpanStatusCode.OK });
70
+ } catch (err) {
71
+ span.setStatus({ code: SpanStatusCode.ERROR, message: err instanceof Error ? err.message : String(err) });
72
+ if (typeof err === 'string' || err instanceof Error) {
73
+ span.recordException(err);
74
+ }
75
+ throw err;
76
+ } finally {
77
+ span.end();
78
+ }
79
+ },
80
+ );
81
+ };
82
+ }
83
+
84
+ function splitNamespace(fullMethod: string): [namespace: string | undefined, method: string] {
85
+ const idx = fullMethod.indexOf('_');
86
+ if (idx > -1) {
87
+ return [fullMethod.slice(0, idx), fullMethod.slice(idx + 1)];
88
+ } else {
89
+ return [undefined, fullMethod];
90
+ }
91
+ }
package/src/start.ts CHANGED
@@ -19,7 +19,12 @@ export async function initTelemetryClient(
19
19
  return telemetry;
20
20
  }
21
21
 
22
- if (config.metricsCollectorUrl || config.publicMetricsCollectorUrl) {
22
+ if (
23
+ config.metricsCollectorUrl ||
24
+ config.publicMetricsCollectorUrl ||
25
+ config.tracesCollectorUrl ||
26
+ config.logsCollectorUrl
27
+ ) {
23
28
  log.info(`Using OpenTelemetry client with custom collector`);
24
29
  // Lazy load OpenTelemetry to avoid loading heavy deps at startup
25
30
  const { OpenTelemetryClient } = await import('./otel.js');
package/src/telemetry.ts CHANGED
@@ -48,7 +48,6 @@ type BannedMetricAttributeNames = (typeof Attributes)[
48
48
  | 'TX_HASH'
49
49
  | 'PROVING_JOB_ID'
50
50
  | 'P2P_ID'
51
- | 'P2P_REQ_RESP_BATCH_REQUESTS_COUNT'
52
51
  | 'TARGET_ADDRESS'
53
52
  | 'MANA_USED'
54
53
  | 'TOTAL_INSTRUCTIONS'];