@aztec/telemetry-client 0.0.1-commit.2ed92850 → 0.0.1-commit.2f68f620

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 +13 -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/lmdb_metrics.d.ts +2 -2
  8. package/dest/lmdb_metrics.d.ts.map +1 -1
  9. package/dest/metric-utils.d.ts +21 -2
  10. package/dest/metric-utils.d.ts.map +1 -1
  11. package/dest/metric-utils.js +52 -0
  12. package/dest/metrics.d.ts +70 -4
  13. package/dest/metrics.d.ts.map +1 -1
  14. package/dest/metrics.js +372 -11
  15. package/dest/monitored_batch_span_processor.d.ts +29 -0
  16. package/dest/monitored_batch_span_processor.d.ts.map +1 -0
  17. package/dest/monitored_batch_span_processor.js +75 -0
  18. package/dest/nodejs_metrics_monitor.d.ts +1 -1
  19. package/dest/nodejs_metrics_monitor.d.ts.map +1 -1
  20. package/dest/nodejs_metrics_monitor.js +7 -1
  21. package/dest/otel.d.ts +6 -1
  22. package/dest/otel.d.ts.map +1 -1
  23. package/dest/otel.js +73 -4
  24. package/dest/otel_propagation.d.ts +3 -1
  25. package/dest/otel_propagation.d.ts.map +1 -1
  26. package/dest/otel_propagation.js +49 -1
  27. package/dest/otel_resource.d.ts +1 -1
  28. package/dest/otel_resource.d.ts.map +1 -1
  29. package/dest/otel_resource.js +14 -2
  30. package/dest/prom_otel_adapter.d.ts +4 -4
  31. package/dest/prom_otel_adapter.d.ts.map +1 -1
  32. package/dest/prom_otel_adapter.js +4 -3
  33. package/dest/start.d.ts +3 -2
  34. package/dest/start.d.ts.map +1 -1
  35. package/dest/start.js +3 -3
  36. package/dest/telemetry.d.ts +5 -4
  37. package/dest/telemetry.d.ts.map +1 -1
  38. package/dest/telemetry.js +1 -1
  39. package/dest/wrappers/fetch.d.ts +3 -3
  40. package/dest/wrappers/fetch.d.ts.map +1 -1
  41. package/dest/wrappers/fetch.js +3 -2
  42. package/dest/wrappers/l2_block_stream.d.ts +2 -2
  43. package/dest/wrappers/l2_block_stream.d.ts.map +1 -1
  44. package/package.json +3 -3
  45. package/src/attributes.ts +17 -1
  46. package/src/config.ts +24 -9
  47. package/src/metric-utils.ts +64 -1
  48. package/src/metrics.ts +382 -11
  49. package/src/monitored_batch_span_processor.ts +100 -0
  50. package/src/nodejs_metrics_monitor.ts +4 -1
  51. package/src/otel.ts +52 -3
  52. package/src/otel_propagation.ts +42 -1
  53. package/src/otel_resource.ts +19 -2
  54. package/src/prom_otel_adapter.ts +4 -5
  55. package/src/start.ts +12 -4
  56. package/src/telemetry.ts +4 -3
  57. package/src/wrappers/fetch.ts +9 -3
  58. package/src/wrappers/l2_block_stream.ts +1 -4
package/src/attributes.ts CHANGED
@@ -45,6 +45,8 @@ export const BLOCK_NUMBER = 'aztec.block.number';
45
45
  export const BLOCK_HASH = 'aztec.block.hash';
46
46
  /** The slot number */
47
47
  export const SLOT_NUMBER = 'aztec.slot.number';
48
+ /** Whether an event happened before or after a slot boundary. */
49
+ export const SLOT_BOUNDARY_SIDE = 'aztec.slot_boundary_side';
48
50
  /** The checkpoint number */
49
51
  export const CHECKPOINT_NUMBER = 'aztec.checkpoint.number';
50
52
  /** The parent's block number */
@@ -94,7 +96,6 @@ export const VALIDATOR_STATUS = 'aztec.validator_status';
94
96
 
95
97
  export const P2P_ID = 'aztec.p2p.id';
96
98
  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
99
  /** The state of a peer (Healthy, Disconnect, Banned) */
99
100
  export const P2P_PEER_SCORE_STATE = 'aztec.p2p.peer_score_state';
100
101
  export const POOL_NAME = 'aztec.pool.name';
@@ -128,6 +129,9 @@ export const NODEJS_EVENT_LOOP_STATE = 'nodejs.eventloop.state';
128
129
 
129
130
  export const TOPIC_NAME = 'aztec.gossip.topic_name';
130
131
 
132
+ /** The reason a transaction was evicted from the tx pool */
133
+ export const TX_POOL_EVICTION_REASON = 'aztec.mempool.eviction_reason';
134
+
131
135
  export const TX_COLLECTION_METHOD = 'aztec.tx_collection.method';
132
136
 
133
137
  /** Scope of L1 transaction (sequencer, prover, or other) */
@@ -139,8 +143,20 @@ export const IS_COMMITTEE_MEMBER = 'aztec.is_committee_member';
139
143
  /** Fisherman fee analysis strategy identifier */
140
144
  export const FISHERMAN_FEE_STRATEGY_ID = 'aztec.fisherman.strategy_id';
141
145
 
146
+ /** Whether the analyzed block reached 100% blob capacity */
147
+ export const BLOCK_FULL = 'aztec.block_full';
148
+
142
149
  /** The L1 transaction target for block proposal */
143
150
  export const L1_BLOCK_PROPOSAL_TX_TARGET = 'aztec.l1.block_proposal_tx_target';
144
151
 
145
152
  /** Whether tracing methods were used to extract block proposal data */
146
153
  export const L1_BLOCK_PROPOSAL_USED_TRACE = 'aztec.l1.block_proposal_used_trace';
154
+
155
+ /** HA signer duty type (e.g., BLOCK_PROPOSAL, CHECKPOINT_ATTESTATION) */
156
+ export const HA_DUTY_TYPE = 'aztec.ha_signer.duty_type';
157
+
158
+ /** HA signer node identifier */
159
+ export const HA_NODE_ID = 'aztec.ha_signer.node_id';
160
+
161
+ /** The address of an attester (validator) participating in consensus */
162
+ export const ATTESTER_ADDRESS = 'aztec.attester.address';
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',
@@ -1,6 +1,7 @@
1
- import type { MetricOptions } from '@opentelemetry/api';
1
+ import type { AttributeValue, MetricOptions } from '@opentelemetry/api';
2
2
 
3
3
  import type { MetricDefinition } from './metrics.js';
4
+ import type { AllowedAttributeNames, Meter, MetricAttributesType, UpDownCounter } from './telemetry.js';
4
5
 
5
6
  /** Extracts OpenTelemetry MetricOptions from a MetricDefinition */
6
7
  export function toMetricOptions(def: MetricDefinition): MetricOptions {
@@ -10,3 +11,65 @@ export function toMetricOptions(def: MetricDefinition): MetricOptions {
10
11
  valueType: def.valueType,
11
12
  };
12
13
  }
14
+
15
+ /** A mapping of attribute keys to their possible values */
16
+ export type AttributeValuesMap = Partial<Record<AllowedAttributeNames, AttributeValue[]>>;
17
+
18
+ /**
19
+ * Expands an attribute values map into all combinations of attribute objects.
20
+ * Example: { status: ['ok', 'fail'], type: ['a', 'b'] } =>
21
+ * [{ status: 'ok', type: 'a' }, { status: 'ok', type: 'b' }, { status: 'fail', type: 'a' }, { status: 'fail', type: 'b' }]
22
+ */
23
+ export function expandAttributeCombinations(attrMap: AttributeValuesMap): MetricAttributesType[] {
24
+ const keys = Object.keys(attrMap) as AllowedAttributeNames[];
25
+ if (keys.length === 0) {
26
+ return [{}];
27
+ }
28
+
29
+ const result: MetricAttributesType[] = [];
30
+
31
+ function generate(index: number, current: MetricAttributesType) {
32
+ if (index === keys.length) {
33
+ result.push({ ...current });
34
+ return;
35
+ }
36
+ const key = keys[index];
37
+ for (const value of attrMap[key]!) {
38
+ current[key] = value;
39
+ generate(index + 1, current);
40
+ }
41
+ }
42
+
43
+ generate(0, {});
44
+ return result;
45
+ }
46
+
47
+ /**
48
+ * Creates an UpDownCounter and initializes it to 0.
49
+ * @param meter - The meter to create the counter on
50
+ * @param metric - The metric definition
51
+ * @param attributes - Optional attributes for initialization. Can be:
52
+ * - AttributeValuesMap: mapping of attribute keys to arrays of possible values (generates cartesian product)
53
+ * - MetricAttributesType[]: explicit array of attribute objects
54
+ * - undefined: initializes without attributes
55
+ */
56
+ export function createUpDownCounterWithDefault(
57
+ meter: Meter,
58
+ metric: MetricDefinition,
59
+ attributes: AttributeValuesMap | MetricAttributesType[] | undefined = undefined,
60
+ ): UpDownCounter {
61
+ const counter = meter.createUpDownCounter(metric);
62
+ if (attributes === undefined) {
63
+ counter.add(0);
64
+ } else if (Array.isArray(attributes)) {
65
+ for (const attrs of attributes) {
66
+ counter.add(0, attrs);
67
+ }
68
+ } else {
69
+ const combinations = expandAttributeCombinations(attributes);
70
+ for (const attrs of combinations) {
71
+ counter.add(0, attrs);
72
+ }
73
+ }
74
+ return counter;
75
+ }