@aztec/telemetry-client 0.0.0-test.0

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 (93) hide show
  1. package/dest/attributes.d.ts +99 -0
  2. package/dest/attributes.d.ts.map +1 -0
  3. package/dest/attributes.js +67 -0
  4. package/dest/bench.d.ts +29 -0
  5. package/dest/bench.d.ts.map +1 -0
  6. package/dest/bench.js +98 -0
  7. package/dest/config.d.ts +12 -0
  8. package/dest/config.d.ts.map +1 -0
  9. package/dest/config.js +39 -0
  10. package/dest/event_loop_monitor.d.ts +18 -0
  11. package/dest/event_loop_monitor.d.ts.map +1 -0
  12. package/dest/event_loop_monitor.js +93 -0
  13. package/dest/index.d.ts +10 -0
  14. package/dest/index.d.ts.map +1 -0
  15. package/dest/index.js +9 -0
  16. package/dest/lmdb_metrics.d.ts +16 -0
  17. package/dest/lmdb_metrics.d.ts.map +1 -0
  18. package/dest/lmdb_metrics.js +42 -0
  19. package/dest/metrics.d.ts +129 -0
  20. package/dest/metrics.d.ts.map +1 -0
  21. package/dest/metrics.js +126 -0
  22. package/dest/noop.d.ts +14 -0
  23. package/dest/noop.d.ts.map +1 -0
  24. package/dest/noop.js +71 -0
  25. package/dest/otel.d.ts +32 -0
  26. package/dest/otel.d.ts.map +1 -0
  27. package/dest/otel.js +319 -0
  28. package/dest/otel_filter_metric_exporter.d.ts +12 -0
  29. package/dest/otel_filter_metric_exporter.d.ts.map +1 -0
  30. package/dest/otel_filter_metric_exporter.js +33 -0
  31. package/dest/otel_logger_provider.d.ts +4 -0
  32. package/dest/otel_logger_provider.d.ts.map +1 -0
  33. package/dest/otel_logger_provider.js +25 -0
  34. package/dest/otel_propagation.d.ts +3 -0
  35. package/dest/otel_propagation.d.ts.map +1 -0
  36. package/dest/otel_propagation.js +44 -0
  37. package/dest/otel_resource.d.ts +3 -0
  38. package/dest/otel_resource.d.ts.map +1 -0
  39. package/dest/otel_resource.js +12 -0
  40. package/dest/prom_otel_adapter.d.ts +127 -0
  41. package/dest/prom_otel_adapter.d.ts.map +1 -0
  42. package/dest/prom_otel_adapter.js +183 -0
  43. package/dest/start.d.ts +6 -0
  44. package/dest/start.d.ts.map +1 -0
  45. package/dest/start.js +24 -0
  46. package/dest/telemetry.d.ts +118 -0
  47. package/dest/telemetry.d.ts.map +1 -0
  48. package/dest/telemetry.js +116 -0
  49. package/dest/vendor/attributes.d.ts +5 -0
  50. package/dest/vendor/attributes.d.ts.map +1 -0
  51. package/dest/vendor/attributes.js +5 -0
  52. package/dest/vendor/otel-pino-stream.d.ts +41 -0
  53. package/dest/vendor/otel-pino-stream.d.ts.map +1 -0
  54. package/dest/vendor/otel-pino-stream.js +229 -0
  55. package/dest/with_tracer.d.ts +33 -0
  56. package/dest/with_tracer.d.ts.map +1 -0
  57. package/dest/with_tracer.js +32 -0
  58. package/dest/wrappers/fetch.d.ts +16 -0
  59. package/dest/wrappers/fetch.d.ts.map +1 -0
  60. package/dest/wrappers/fetch.js +39 -0
  61. package/dest/wrappers/index.d.ts +4 -0
  62. package/dest/wrappers/index.d.ts.map +1 -0
  63. package/dest/wrappers/index.js +3 -0
  64. package/dest/wrappers/json_rpc_server.d.ts +4 -0
  65. package/dest/wrappers/json_rpc_server.d.ts.map +1 -0
  66. package/dest/wrappers/json_rpc_server.js +11 -0
  67. package/dest/wrappers/l2_block_stream.d.ts +15 -0
  68. package/dest/wrappers/l2_block_stream.d.ts.map +1 -0
  69. package/dest/wrappers/l2_block_stream.js +26 -0
  70. package/package.json +89 -0
  71. package/src/attributes.ts +115 -0
  72. package/src/bench.ts +147 -0
  73. package/src/config.ts +56 -0
  74. package/src/event_loop_monitor.ts +119 -0
  75. package/src/index.ts +9 -0
  76. package/src/lmdb_metrics.ts +45 -0
  77. package/src/metrics.ts +153 -0
  78. package/src/noop.ts +91 -0
  79. package/src/otel.ts +286 -0
  80. package/src/otel_filter_metric_exporter.ts +38 -0
  81. package/src/otel_logger_provider.ts +31 -0
  82. package/src/otel_propagation.ts +50 -0
  83. package/src/otel_resource.ts +16 -0
  84. package/src/prom_otel_adapter.ts +326 -0
  85. package/src/start.ts +33 -0
  86. package/src/telemetry.ts +267 -0
  87. package/src/vendor/attributes.ts +5 -0
  88. package/src/vendor/otel-pino-stream.ts +282 -0
  89. package/src/with_tracer.ts +35 -0
  90. package/src/wrappers/fetch.ts +52 -0
  91. package/src/wrappers/index.ts +3 -0
  92. package/src/wrappers/json_rpc_server.ts +15 -0
  93. package/src/wrappers/l2_block_stream.ts +37 -0
package/src/bench.ts ADDED
@@ -0,0 +1,147 @@
1
+ import type { BatchObservableCallback, Context, MetricOptions, Observable, ValueType } from '@opentelemetry/api';
2
+
3
+ import { NoopTracer } from './noop.js';
4
+ import type {
5
+ AttributesType,
6
+ Gauge,
7
+ Histogram,
8
+ Meter,
9
+ MetricsType,
10
+ ObservableGauge,
11
+ ObservableUpDownCounter,
12
+ TelemetryClient,
13
+ Tracer,
14
+ UpDownCounter,
15
+ } from './telemetry.js';
16
+
17
+ export type BenchmarkMetricsType = {
18
+ name: string;
19
+ metrics: {
20
+ name: string;
21
+ type: 'gauge' | 'counter' | 'histogram';
22
+ description?: string;
23
+ unit?: string;
24
+ valueType?: ValueType;
25
+ points: BenchmarkDataPoint[];
26
+ }[];
27
+ }[];
28
+
29
+ export class BenchmarkTelemetryClient implements TelemetryClient {
30
+ private meters: InMemoryPlainMeter[] = [];
31
+
32
+ getMeter(name: string): Meter {
33
+ const meter = new InMemoryPlainMeter(name);
34
+ this.meters.push(meter);
35
+ return meter;
36
+ }
37
+
38
+ getTracer(): Tracer {
39
+ return new NoopTracer();
40
+ }
41
+
42
+ stop(): Promise<void> {
43
+ return Promise.resolve();
44
+ }
45
+
46
+ flush(): Promise<void> {
47
+ return Promise.resolve();
48
+ }
49
+
50
+ isEnabled() {
51
+ return true;
52
+ }
53
+
54
+ getMeters(): BenchmarkMetricsType {
55
+ return this.meters;
56
+ }
57
+
58
+ clear() {
59
+ this.meters.forEach(meter => meter.clear());
60
+ }
61
+ }
62
+
63
+ class InMemoryPlainMeter implements Meter {
64
+ public readonly metrics: InMemoryPlainMetric[] = [];
65
+
66
+ constructor(public readonly name: string) {}
67
+
68
+ clear() {
69
+ this.metrics.forEach(metric => metric.clear());
70
+ }
71
+
72
+ createGauge(name: MetricsType, options?: MetricOptions | undefined): Gauge {
73
+ return this.createMetric('gauge', name, options);
74
+ }
75
+
76
+ createObservableGauge(name: MetricsType, options?: MetricOptions | undefined): ObservableGauge {
77
+ return this.createMetric('gauge', name, options);
78
+ }
79
+
80
+ createHistogram(name: MetricsType, options?: MetricOptions | undefined): Histogram {
81
+ return this.createMetric('histogram', name, options);
82
+ }
83
+
84
+ createUpDownCounter(name: MetricsType, options?: MetricOptions | undefined): UpDownCounter {
85
+ return this.createMetric('counter', name, options);
86
+ }
87
+
88
+ createObservableUpDownCounter(name: MetricsType, options?: MetricOptions | undefined): ObservableUpDownCounter {
89
+ return this.createMetric('counter', name, options);
90
+ }
91
+
92
+ private createMetric(type: 'gauge' | 'counter' | 'histogram', name: string, options?: MetricOptions) {
93
+ const metric = new InMemoryPlainMetric(type, name, options);
94
+ this.metrics.push(metric);
95
+ return metric;
96
+ }
97
+
98
+ addBatchObservableCallback(
99
+ _callback: BatchObservableCallback<AttributesType>,
100
+ _observables: Observable<AttributesType>[],
101
+ ): void {}
102
+
103
+ removeBatchObservableCallback(
104
+ _callback: BatchObservableCallback<AttributesType>,
105
+ _observables: Observable<AttributesType>[],
106
+ ): void {}
107
+ }
108
+
109
+ export type BenchmarkDataPoint = { value: number; attributes?: AttributesType; context?: Context };
110
+
111
+ class InMemoryPlainMetric {
112
+ public readonly points: BenchmarkDataPoint[] = [];
113
+
114
+ public readonly description?: string;
115
+ public readonly unit?: string;
116
+ public readonly valueType?: ValueType;
117
+
118
+ constructor(
119
+ public readonly type: 'gauge' | 'counter' | 'histogram',
120
+ public readonly name: string,
121
+ options?: MetricOptions,
122
+ ) {
123
+ this.description = options?.description;
124
+ this.unit = options?.unit;
125
+ this.valueType = options?.valueType;
126
+ }
127
+
128
+ add(value: number, attributes?: AttributesType, context?: Context): void {
129
+ this.points.push({ value, attributes, context });
130
+ }
131
+
132
+ record(value: number, attributes?: AttributesType, context?: Context): void {
133
+ this.points.push({ value, attributes, context });
134
+ }
135
+
136
+ addCallback() {}
137
+
138
+ removeCallback() {}
139
+
140
+ getPoints(): BenchmarkDataPoint[] {
141
+ return this.points;
142
+ }
143
+
144
+ clear() {
145
+ this.points.splice(0, this.points.length);
146
+ }
147
+ }
package/src/config.ts ADDED
@@ -0,0 +1,56 @@
1
+ import { type ConfigMappingsType, getConfigFromMappings } from '@aztec/foundation/config';
2
+
3
+ export interface TelemetryClientConfig {
4
+ metricsCollectorUrl?: URL;
5
+ tracesCollectorUrl?: URL;
6
+ logsCollectorUrl?: URL;
7
+ otelCollectIntervalMs: number;
8
+ otelExportTimeoutMs: number;
9
+ otelExcludeMetrics?: string[];
10
+ }
11
+
12
+ export const telemetryClientConfigMappings: ConfigMappingsType<TelemetryClientConfig> = {
13
+ metricsCollectorUrl: {
14
+ env: 'OTEL_EXPORTER_OTLP_METRICS_ENDPOINT',
15
+ description: 'The URL of the telemetry collector for metrics',
16
+ parseEnv: (val: string) => val && new URL(val),
17
+ },
18
+ tracesCollectorUrl: {
19
+ env: 'OTEL_EXPORTER_OTLP_TRACES_ENDPOINT',
20
+ description: 'The URL of the telemetry collector for traces',
21
+ parseEnv: (val: string) => val && new URL(val),
22
+ },
23
+ logsCollectorUrl: {
24
+ env: 'OTEL_EXPORTER_OTLP_LOGS_ENDPOINT',
25
+ description: 'The URL of the telemetry collector for logs',
26
+ parseEnv: (val: string) => val && new URL(val),
27
+ },
28
+ otelCollectIntervalMs: {
29
+ env: 'OTEL_COLLECT_INTERVAL_MS',
30
+ description: 'The interval at which to collect metrics',
31
+ defaultValue: 60000, // Default extracted from otel client
32
+ parseEnv: (val: string) => parseInt(val),
33
+ },
34
+ otelExportTimeoutMs: {
35
+ env: 'OTEL_EXPORT_TIMEOUT_MS',
36
+ description: 'The timeout for exporting metrics',
37
+ defaultValue: 30000, // Default extracted from otel client
38
+ parseEnv: (val: string) => parseInt(val),
39
+ },
40
+ otelExcludeMetrics: {
41
+ env: 'OTEL_EXCLUDE_METRICS',
42
+ description: 'A list of metric prefixes to exclude from export',
43
+ parseEnv: (val: string) =>
44
+ val
45
+ ? val
46
+ .split(',')
47
+ .map(s => s.trim())
48
+ .filter(s => s.length > 0)
49
+ : [],
50
+ defaultValue: [],
51
+ },
52
+ };
53
+
54
+ export function getConfigEnvVars(): TelemetryClientConfig {
55
+ return getConfigFromMappings<TelemetryClientConfig>(telemetryClientConfigMappings);
56
+ }
@@ -0,0 +1,119 @@
1
+ import { type EventLoopUtilization, type IntervalHistogram, monitorEventLoopDelay, performance } from 'node:perf_hooks';
2
+
3
+ import * as Attributes from './attributes.js';
4
+ import * as Metrics from './metrics.js';
5
+ import {
6
+ type BatchObservableResult,
7
+ type Meter,
8
+ type ObservableGauge,
9
+ type UpDownCounter,
10
+ ValueType,
11
+ } from './telemetry.js';
12
+
13
+ /**
14
+ * Detector for custom Aztec attributes
15
+ */
16
+ export class EventLoopMonitor {
17
+ private eventLoopDelayGauges: {
18
+ min: ObservableGauge;
19
+ max: ObservableGauge;
20
+ mean: ObservableGauge;
21
+ stddev: ObservableGauge;
22
+ p50: ObservableGauge;
23
+ p90: ObservableGauge;
24
+ p99: ObservableGauge;
25
+ };
26
+
27
+ private eventLoopUilization: ObservableGauge;
28
+ private eventLoopTime: UpDownCounter;
29
+
30
+ private started = false;
31
+
32
+ private lastELU: EventLoopUtilization | undefined;
33
+ private eventLoopDelay: IntervalHistogram;
34
+
35
+ constructor(private meter: Meter) {
36
+ const nsObsGauge = (name: (typeof Metrics)[keyof typeof Metrics], description: string) =>
37
+ meter.createObservableGauge(name, {
38
+ unit: 'ns',
39
+ valueType: ValueType.INT,
40
+ description,
41
+ });
42
+
43
+ this.eventLoopDelayGauges = {
44
+ min: nsObsGauge(Metrics.NODEJS_EVENT_LOOP_DELAY_MIN, 'Minimum delay of the event loop'),
45
+ mean: nsObsGauge(Metrics.NODEJS_EVENT_LOOP_DELAY_MEAN, 'Mean delay of the event loop'),
46
+ max: nsObsGauge(Metrics.NODEJS_EVENT_LOOP_DELAY_MAX, 'Max delay of the event loop'),
47
+ stddev: nsObsGauge(Metrics.NODEJS_EVENT_LOOP_DELAY_STDDEV, 'Stddev delay of the event loop'),
48
+ p50: nsObsGauge(Metrics.NODEJS_EVENT_LOOP_DELAY_P50, 'P50 delay of the event loop'),
49
+ p90: nsObsGauge(Metrics.NODEJS_EVENT_LOOP_DELAY_P90, 'P90 delay of the event loop'),
50
+ p99: nsObsGauge(Metrics.NODEJS_EVENT_LOOP_DELAY_P99, 'P99 delay of the event loop'),
51
+ };
52
+
53
+ this.eventLoopUilization = meter.createObservableGauge(Metrics.NODEJS_EVENT_LOOP_UTILIZATION, {
54
+ valueType: ValueType.DOUBLE,
55
+ description: 'How busy is the event loop',
56
+ });
57
+
58
+ this.eventLoopTime = meter.createUpDownCounter(Metrics.NODEJS_EVENT_LOOP_TIME, {
59
+ unit: 'ms',
60
+ valueType: ValueType.INT,
61
+ description: 'How much time the event loop has spent in a given state',
62
+ });
63
+
64
+ this.eventLoopDelay = monitorEventLoopDelay();
65
+ }
66
+
67
+ start(): void {
68
+ if (this.started) {
69
+ return;
70
+ }
71
+
72
+ this.lastELU = performance.eventLoopUtilization();
73
+ this.eventLoopDelay.enable();
74
+ this.meter.addBatchObservableCallback(this.measure, [
75
+ this.eventLoopUilization,
76
+ ...Object.values(this.eventLoopDelayGauges),
77
+ ]);
78
+ }
79
+
80
+ stop(): void {
81
+ if (!this.started) {
82
+ return;
83
+ }
84
+ this.meter.removeBatchObservableCallback(this.measure, [
85
+ this.eventLoopUilization,
86
+ ...Object.values(this.eventLoopDelayGauges),
87
+ ]);
88
+ this.eventLoopDelay.disable();
89
+ this.eventLoopDelay.reset();
90
+ this.lastELU = undefined;
91
+ }
92
+
93
+ private measure = (obs: BatchObservableResult): void => {
94
+ const newELU = performance.eventLoopUtilization();
95
+ const delta = performance.eventLoopUtilization(newELU, this.lastELU);
96
+ this.lastELU = newELU;
97
+
98
+ // `utilization` [0,1] represents how much the event loop is busy vs waiting for new events to come in
99
+ // This should be corelated with CPU usage to gauge the performance characteristics of services
100
+ // 100% utilization leads to high latency because the event loop is _always_ busy, there's no breathing room for events to be processed quickly.
101
+ // Docs and examples:
102
+ // - https://nodesource.com/blog/event-loop-utilization-nodejs
103
+ // - https://youtu.be/WetXnEPraYM
104
+ obs.observe(this.eventLoopUilization, delta.utilization);
105
+
106
+ this.eventLoopTime.add(Math.floor(delta.idle), { [Attributes.NODEJS_EVENT_LOOP_STATE]: 'idle' });
107
+ this.eventLoopTime.add(Math.floor(delta.active), { [Attributes.NODEJS_EVENT_LOOP_STATE]: 'active' });
108
+
109
+ obs.observe(this.eventLoopDelayGauges.min, Math.floor(this.eventLoopDelay.min));
110
+ obs.observe(this.eventLoopDelayGauges.mean, Math.floor(this.eventLoopDelay.mean));
111
+ obs.observe(this.eventLoopDelayGauges.max, Math.floor(this.eventLoopDelay.max));
112
+ obs.observe(this.eventLoopDelayGauges.stddev, Math.floor(this.eventLoopDelay.stddev));
113
+ obs.observe(this.eventLoopDelayGauges.p50, Math.floor(this.eventLoopDelay.percentile(50)));
114
+ obs.observe(this.eventLoopDelayGauges.p90, Math.floor(this.eventLoopDelay.percentile(90)));
115
+ obs.observe(this.eventLoopDelayGauges.p99, Math.floor(this.eventLoopDelay.percentile(99)));
116
+
117
+ this.eventLoopDelay.reset();
118
+ };
119
+ }
package/src/index.ts ADDED
@@ -0,0 +1,9 @@
1
+ export * from './telemetry.js';
2
+ export * as Metrics from './metrics.js';
3
+ export * as Attributes from './attributes.js';
4
+ export * from './with_tracer.js';
5
+ export * from './prom_otel_adapter.js';
6
+ export * from './lmdb_metrics.js';
7
+ export * from './wrappers/index.js';
8
+ export * from './start.js';
9
+ export * from './otel_propagation.js';
@@ -0,0 +1,45 @@
1
+ import * as Metrics from './metrics.js';
2
+ import {
3
+ type AttributesType,
4
+ type BatchObservableResult,
5
+ type Meter,
6
+ type ObservableGauge,
7
+ ValueType,
8
+ } from './telemetry.js';
9
+
10
+ export type LmdbStatsCallback = () => Promise<{ mappingSize: number; numItems: number; actualSize: number }>;
11
+
12
+ export class LmdbMetrics {
13
+ private dbMapSize: ObservableGauge;
14
+ private dbUsedSize: ObservableGauge;
15
+ private dbNumItems: ObservableGauge;
16
+
17
+ constructor(meter: Meter, private attributes?: AttributesType, private getStats?: LmdbStatsCallback) {
18
+ this.dbMapSize = meter.createObservableGauge(Metrics.DB_MAP_SIZE, {
19
+ description: 'LMDB Map Size',
20
+ valueType: ValueType.INT,
21
+ unit: 'By',
22
+ });
23
+ this.dbUsedSize = meter.createObservableGauge(Metrics.DB_USED_SIZE, {
24
+ description: 'LMDB Used Size',
25
+ valueType: ValueType.INT,
26
+ unit: 'By',
27
+ });
28
+ this.dbNumItems = meter.createObservableGauge(Metrics.DB_NUM_ITEMS, {
29
+ description: 'LMDB Num Items',
30
+ valueType: ValueType.INT,
31
+ });
32
+
33
+ meter.addBatchObservableCallback(this.recordDBMetrics, [this.dbMapSize, this.dbUsedSize, this.dbNumItems]);
34
+ }
35
+
36
+ private recordDBMetrics = async (observable: BatchObservableResult) => {
37
+ if (!this.getStats) {
38
+ return;
39
+ }
40
+ const metrics = await this.getStats();
41
+ observable.observe(this.dbMapSize, metrics.mappingSize, this.attributes);
42
+ observable.observe(this.dbNumItems, metrics.numItems, this.attributes);
43
+ observable.observe(this.dbUsedSize, metrics.actualSize, this.attributes);
44
+ };
45
+ }
package/src/metrics.ts ADDED
@@ -0,0 +1,153 @@
1
+ /**
2
+ * @file Metric names used in Aztec.
3
+ * Metric names must be unique and not clash with {@link attributes.ts | Attribute names}.
4
+ * Prefix metric names with `aztec` and use dots `.` to separate namespaces.
5
+ *
6
+ * @see {@link https://opentelemetry.io/docs/specs/semconv/general/metrics/ | OpenTelemetry Metrics} for naming conventions.
7
+ */
8
+
9
+ export const BLOB_SINK_OBJECTS_IN_BLOB_STORE = 'aztec.blob_sink.objects_in_blob_store';
10
+ export const BLOB_SINK_BLOB_SIZE = 'aztec.blob_sink.blob_size';
11
+
12
+ /** How long it takes to simulate a circuit */
13
+ export const CIRCUIT_SIMULATION_DURATION = 'aztec.circuit.simulation.duration';
14
+ export const CIRCUIT_SIMULATION_INPUT_SIZE = 'aztec.circuit.simulation.input_size';
15
+ export const CIRCUIT_SIMULATION_OUTPUT_SIZE = 'aztec.circuit.simulation.output_size';
16
+
17
+ export const CIRCUIT_WITNESS_GEN_DURATION = 'aztec.circuit.witness_generation.duration';
18
+ export const CIRCUIT_WITNESS_GEN_INPUT_SIZE = 'aztec.circuit.witness_generation.input_size';
19
+ export const CIRCUIT_WITNESS_GEN_OUTPUT_SIZE = 'aztec.circuit.witness_generation.output_size';
20
+
21
+ export const CIRCUIT_PROVING_DURATION = 'aztec.circuit.proving.duration';
22
+ export const CIRCUIT_PROVING_INPUT_SIZE = 'aztec.circuit.proving.input_size';
23
+ export const CIRCUIT_PROVING_PROOF_SIZE = 'aztec.circuit.proving.proof_size';
24
+
25
+ export const CIRCUIT_PUBLIC_INPUTS_COUNT = 'aztec.circuit.public_inputs_count';
26
+ export const CIRCUIT_GATE_COUNT = 'aztec.circuit.gate_count';
27
+ export const CIRCUIT_SIZE = 'aztec.circuit.size';
28
+
29
+ export const MEMPOOL_TX_COUNT = 'aztec.mempool.tx_count';
30
+ export const MEMPOOL_TX_SIZE = 'aztec.mempool.tx_size';
31
+ export const DB_NUM_ITEMS = 'aztec.db.num_items';
32
+ export const DB_MAP_SIZE = 'aztec.db.map_size';
33
+ export const DB_USED_SIZE = 'aztec.db.used_size';
34
+
35
+ export const MEMPOOL_ATTESTATIONS_COUNT = 'aztec.mempool.attestations_count';
36
+ export const MEMPOOL_ATTESTATIONS_SIZE = 'aztec.mempool.attestations_size';
37
+
38
+ export const ARCHIVER_SYNC_DURATION = 'aztec.archiver.sync_duration';
39
+ export const ARCHIVER_L1_BLOCKS_SYNCED = 'aztec.archiver.l1_blocks_synced';
40
+ export const ARCHIVER_L1_BLOCK_HEIGHT = 'aztec.archiver.l1_block_height';
41
+ export const ARCHIVER_BLOCK_HEIGHT = 'aztec.archiver.block_height';
42
+ export const ARCHIVER_TX_COUNT = 'aztec.archiver.tx_count';
43
+ export const ARCHIVER_ROLLUP_PROOF_DELAY = 'aztec.archiver.rollup_proof_delay';
44
+ export const ARCHIVER_ROLLUP_PROOF_COUNT = 'aztec.archiver.rollup_proof_count';
45
+ export const ARCHIVER_PRUNE_COUNT = 'aztec.archiver.prune_count';
46
+
47
+ export const NODE_RECEIVE_TX_DURATION = 'aztec.node.receive_tx.duration';
48
+ export const NODE_RECEIVE_TX_COUNT = 'aztec.node.receive_tx.count';
49
+
50
+ export const SEQUENCER_STATE_TRANSITION_BUFFER_DURATION = 'aztec.sequencer.state_transition_buffer.duration';
51
+ export const SEQUENCER_BLOCK_BUILD_DURATION = 'aztec.sequencer.block.build_duration';
52
+ export const SEQUENCER_BLOCK_BUILD_MANA_PER_SECOND = 'aztec.sequencer.block.build_mana_per_second';
53
+ export const SEQUENCER_BLOCK_COUNT = 'aztec.sequencer.block.count';
54
+ export const SEQUENCER_CURRENT_STATE = 'aztec.sequencer.current.state';
55
+ export const SEQUENCER_CURRENT_BLOCK_NUMBER = 'aztec.sequencer.current.block_number';
56
+ export const SEQUENCER_CURRENT_BLOCK_SIZE = 'aztec.sequencer.current.block_size';
57
+ export const SEQUENCER_TIME_TO_COLLECT_ATTESTATIONS = 'aztec.sequencer.time_to_collect_attestations';
58
+ export const SEQUENCER_BLOCK_BUILD_INSERTION_TIME = 'aztec.sequencer.block_builder_tree_insertion_duration';
59
+
60
+ export const L1_PUBLISHER_GAS_PRICE = 'aztec.l1_publisher.gas_price';
61
+ export const L1_PUBLISHER_TX_COUNT = 'aztec.l1_publisher.tx_count';
62
+ export const L1_PUBLISHER_TX_DURATION = 'aztec.l1_publisher.tx_duration';
63
+ export const L1_PUBLISHER_TX_GAS = 'aztec.l1_publisher.tx_gas';
64
+ export const L1_PUBLISHER_TX_CALLDATA_SIZE = 'aztec.l1_publisher.tx_calldata_size';
65
+ export const L1_PUBLISHER_TX_CALLDATA_GAS = 'aztec.l1_publisher.tx_calldata_gas';
66
+ export const L1_PUBLISHER_TX_BLOBDATA_GAS_USED = 'aztec.l1_publisher.tx_blobdata_gas_used';
67
+ export const L1_PUBLISHER_TX_BLOBDATA_GAS_COST = 'aztec.l1_publisher.tx_blobdata_gas_cost';
68
+ export const L1_PUBLISHER_BLOB_COUNT = 'aztec.l1_publisher.blob_count';
69
+ export const L1_PUBLISHER_BLOB_INCLUSION_BLOCKS = 'aztec.l1_publisher.blob_inclusion_blocks';
70
+ export const L1_PUBLISHER_BLOB_TX_SUCCESS = 'aztec.l1_publisher.blob_tx_success';
71
+ export const L1_PUBLISHER_BLOB_TX_FAILURE = 'aztec.l1_publisher.blob_tx_failure';
72
+ export const L1_PUBLISHER_BALANCE = 'aztec.l1_publisher.balance';
73
+
74
+ export const PEER_MANAGER_GOODBYES_SENT = 'aztec.peer_manager.goodbyes_sent';
75
+ export const PEER_MANAGER_GOODBYES_RECEIVED = 'aztec.peer_manager.goodbyes_received';
76
+
77
+ export const P2P_REQ_RESP_SENT_REQUESTS = 'aztec.p2p.req_resp.sent_requests';
78
+ export const P2P_REQ_RESP_RECEIVED_REQUESTS = 'aztec.p2p.req_resp.received_requests';
79
+ export const P2P_REQ_RESP_FAILED_OUTBOUND_REQUESTS = 'aztec.p2p.req_resp.failed_outbound_requests';
80
+ export const P2P_REQ_RESP_FAILED_INBOUND_REQUESTS = 'aztec.p2p.req_resp.failed_inbound_requests';
81
+
82
+ export const PUBLIC_PROCESSOR_TX_DURATION = 'aztec.public_processor.tx_duration';
83
+ export const PUBLIC_PROCESSOR_TX_COUNT = 'aztec.public_processor.tx_count';
84
+ export const PUBLIC_PROCESSOR_TX_PHASE_COUNT = 'aztec.public_processor.tx_phase_count';
85
+ export const PUBLIC_PROCESSOR_TX_GAS = 'aztec.public_processor.tx_gas';
86
+ export const PUBLIC_PROCESSOR_PHASE_DURATION = 'aztec.public_processor.phase_duration';
87
+ export const PUBLIC_PROCESSOR_PHASE_COUNT = 'aztec.public_processor.phase_count';
88
+ export const PUBLIC_PROCESSOR_DEPLOY_BYTECODE_SIZE = 'aztec.public_processor.deploy_bytecode_size';
89
+ export const PUBLIC_PROCESSOR_TOTAL_GAS = 'aztec.public_processor.total_gas';
90
+ export const PUBLIC_PROCESSOR_TOTAL_GAS_HISTOGRAM = 'aztec.public_processor.total_gas_histogram';
91
+ export const PUBLIC_PROCESSOR_GAS_RATE = 'aztec.public_processor.gas_rate';
92
+ export const PUBLIC_PROCESSOR_TREE_INSERTION = 'aztec.public_processor.tree_insertion';
93
+
94
+ export const PUBLIC_EXECUTOR_SIMULATION_COUNT = 'aztec.public_executor.simulation_count';
95
+ export const PUBLIC_EXECUTOR_SIMULATION_DURATION = 'aztec.public_executor.simulation_duration';
96
+ export const PUBLIC_EXECUTOR_SIMULATION_MANA_PER_SECOND = 'aztec.public_executor.simulation_mana_per_second';
97
+ export const PUBLIC_EXECUTION_SIMULATION_BYTECODE_SIZE = 'aztec.public_executor.simulation_bytecode_size';
98
+ export const PUBLIC_EXECUTION_PRIVATE_EFFECTS_INSERTION = 'aztec.public_executor.private_effects_insertion';
99
+
100
+ export const PROVING_ORCHESTRATOR_BASE_ROLLUP_INPUTS_DURATION =
101
+ 'aztec.proving_orchestrator.base_rollup.inputs_duration';
102
+
103
+ export const PROVING_QUEUE_JOB_SIZE = 'aztec.proving_queue.job_size';
104
+ export const PROVING_QUEUE_SIZE = 'aztec.proving_queue.size';
105
+ export const PROVING_QUEUE_TOTAL_JOBS = 'aztec.proving_queue.enqueued_jobs_count';
106
+ export const PROVING_QUEUE_CACHED_JOBS = 'aztec.proving_queue.cached_jobs_count';
107
+ export const PROVING_QUEUE_ACTIVE_JOBS = 'aztec.proving_queue.active_jobs_count';
108
+ export const PROVING_QUEUE_RESOLVED_JOBS = 'aztec.proving_queue.resolved_jobs_count';
109
+ export const PROVING_QUEUE_REJECTED_JOBS = 'aztec.proving_queue.rejected_jobs_count';
110
+ export const PROVING_QUEUE_RETRIED_JOBS = 'aztec.proving_queue.retried_jobs_count';
111
+ export const PROVING_QUEUE_TIMED_OUT_JOBS = 'aztec.proving_queue.timed_out_jobs_count';
112
+ export const PROVING_QUEUE_JOB_WAIT = 'aztec.proving_queue.job_wait';
113
+ export const PROVING_QUEUE_JOB_DURATION = 'aztec.proving_queue.job_duration';
114
+ export const PROVING_QUEUE_DB_NUM_ITEMS = 'aztec.proving_queue.db.num_items';
115
+ export const PROVING_QUEUE_DB_MAP_SIZE = 'aztec.proving_queue.db.map_size';
116
+ export const PROVING_QUEUE_DB_USED_SIZE = 'aztec.proving_queue.db.used_size';
117
+
118
+ export const PROVING_AGENT_IDLE = 'aztec.proving_queue.agent.idle';
119
+
120
+ export const PROVER_NODE_EXECUTION_DURATION = 'aztec.prover_node.execution.duration';
121
+ export const PROVER_NODE_JOB_DURATION = 'aztec.prover_node.job_duration';
122
+ export const PROVER_NODE_JOB_BLOCKS = 'aztec.prover_node.job_blocks';
123
+ export const PROVER_NODE_JOB_TRANSACTIONS = 'aztec.prover_node.job_transactions';
124
+
125
+ export const WORLD_STATE_FORK_DURATION = 'aztec.world_state.fork.duration';
126
+ export const WORLD_STATE_SYNC_DURATION = 'aztec.world_state.sync.duration';
127
+ export const WORLD_STATE_MERKLE_TREE_SIZE = 'aztec.world_state.merkle_tree_size';
128
+ export const WORLD_STATE_DB_SIZE = 'aztec.world_state.db_size';
129
+ export const WORLD_STATE_DB_MAP_SIZE = 'aztec.world_state.db_map_size';
130
+ export const WORLD_STATE_TREE_SIZE = 'aztec.world_state.tree_size';
131
+ export const WORLD_STATE_UNFINALISED_HEIGHT = 'aztec.world_state.unfinalised_height';
132
+ export const WORLD_STATE_FINALISED_HEIGHT = 'aztec.world_state.finalised_height';
133
+ export const WORLD_STATE_OLDEST_BLOCK = 'aztec.world_state.oldest_block';
134
+ export const WORLD_STATE_DB_USED_SIZE = 'aztec.world_state.db_used_size';
135
+ export const WORLD_STATE_DB_NUM_ITEMS = 'aztec.world_state.db_num_items';
136
+ export const WORLD_STATE_REQUEST_TIME = 'aztec.world_state.request_time';
137
+ export const WORLD_STATE_CRITICAL_ERROR_COUNT = 'aztec.world_state.critical_error_count';
138
+
139
+ export const PROOF_VERIFIER_COUNT = 'aztec.proof_verifier.count';
140
+
141
+ export const VALIDATOR_RE_EXECUTION_TIME = 'aztec.validator.re_execution_time';
142
+ export const VALIDATOR_FAILED_REEXECUTION_COUNT = 'aztec.validator.failed_reexecution_count';
143
+
144
+ export const NODEJS_EVENT_LOOP_DELAY_MIN = 'nodejs.eventloop.delay.min';
145
+ export const NODEJS_EVENT_LOOP_DELAY_MEAN = 'nodejs.eventloop.delay.mean';
146
+ export const NODEJS_EVENT_LOOP_DELAY_MAX = 'nodejs.eventloop.delay.max';
147
+ export const NODEJS_EVENT_LOOP_DELAY_STDDEV = 'nodejs.eventloop.delay.stddev';
148
+ export const NODEJS_EVENT_LOOP_DELAY_P50 = 'nodejs.eventloop.delay.p50';
149
+ export const NODEJS_EVENT_LOOP_DELAY_P90 = 'nodejs.eventloop.delay.p90';
150
+ export const NODEJS_EVENT_LOOP_DELAY_P99 = 'nodejs.eventloop.delay.p99';
151
+
152
+ export const NODEJS_EVENT_LOOP_UTILIZATION = 'nodejs.eventloop.utilization';
153
+ export const NODEJS_EVENT_LOOP_TIME = 'nodejs.eventloop.time';
package/src/noop.ts ADDED
@@ -0,0 +1,91 @@
1
+ import { type Meter, type Span, type SpanContext, type Tracer, createNoopMeter } from '@opentelemetry/api';
2
+
3
+ import type { TelemetryClient } from './telemetry.js';
4
+
5
+ export class NoopTelemetryClient implements TelemetryClient {
6
+ getMeter(): Meter {
7
+ return createNoopMeter();
8
+ }
9
+
10
+ getTracer(): Tracer {
11
+ return new NoopTracer();
12
+ }
13
+
14
+ stop(): Promise<void> {
15
+ return Promise.resolve();
16
+ }
17
+
18
+ flush(): Promise<void> {
19
+ return Promise.resolve();
20
+ }
21
+
22
+ isEnabled() {
23
+ return false;
24
+ }
25
+ }
26
+
27
+ // @opentelemetry/api internally uses NoopTracer and NoopSpan but they're not exported
28
+ // make our own versions
29
+ // https://github.com/open-telemetry/opentelemetry-js/issues/4518#issuecomment-2179405444
30
+ export class NoopTracer implements Tracer {
31
+ startSpan(): Span {
32
+ return new NoopSpan();
33
+ }
34
+
35
+ startActiveSpan<F extends (...args: any[]) => any>(_name: string, ...args: (unknown | F)[]): ReturnType<F> {
36
+ // there are three different signatures for startActiveSpan, grab the function, we don't care about the rest
37
+ const fn = args.find(arg => typeof arg === 'function') as F;
38
+ return fn(new NoopSpan());
39
+ }
40
+ }
41
+
42
+ class NoopSpan implements Span {
43
+ private recording: boolean = true;
44
+ addEvent(): this {
45
+ return this;
46
+ }
47
+
48
+ addLink(): this {
49
+ return this;
50
+ }
51
+
52
+ addLinks(): this {
53
+ return this;
54
+ }
55
+
56
+ end(): void {
57
+ this.recording = false;
58
+ }
59
+
60
+ isRecording(): boolean {
61
+ return this.recording;
62
+ }
63
+
64
+ recordException(): void {
65
+ return;
66
+ }
67
+
68
+ setAttribute(): this {
69
+ return this;
70
+ }
71
+
72
+ setAttributes(): this {
73
+ return this;
74
+ }
75
+
76
+ setStatus(): this {
77
+ return this;
78
+ }
79
+
80
+ spanContext(): SpanContext {
81
+ return {
82
+ spanId: '',
83
+ traceId: '',
84
+ traceFlags: 0,
85
+ };
86
+ }
87
+
88
+ updateName(): this {
89
+ return this;
90
+ }
91
+ }