@aztec/telemetry-client 0.0.0-test.1 → 0.0.1-commit.b655e406
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/attributes.d.ts +21 -8
- package/dest/attributes.d.ts.map +1 -1
- package/dest/attributes.js +16 -8
- package/dest/bench.d.ts +3 -0
- package/dest/bench.d.ts.map +1 -1
- package/dest/bench.js +7 -0
- package/dest/config.d.ts +5 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +23 -1
- package/dest/index.d.ts +1 -0
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -0
- package/dest/l1_metrics.d.ts +17 -0
- package/dest/l1_metrics.d.ts.map +1 -0
- package/dest/l1_metrics.js +70 -0
- package/dest/lmdb_metrics.d.ts +4 -2
- package/dest/lmdb_metrics.d.ts.map +1 -1
- package/dest/lmdb_metrics.js +8 -0
- package/dest/metrics.d.ts +87 -12
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +88 -13
- package/dest/{event_loop_monitor.d.ts → nodejs_metrics_monitor.d.ts} +5 -2
- package/dest/nodejs_metrics_monitor.d.ts.map +1 -0
- package/dest/{event_loop_monitor.js → nodejs_metrics_monitor.js} +55 -12
- package/dest/noop.d.ts +3 -1
- package/dest/noop.d.ts.map +1 -1
- package/dest/noop.js +2 -0
- package/dest/otel.d.ts +8 -4
- package/dest/otel.d.ts.map +1 -1
- package/dest/otel.js +79 -19
- package/dest/otel_filter_metric_exporter.d.ts +11 -3
- package/dest/otel_filter_metric_exporter.d.ts.map +1 -1
- package/dest/otel_filter_metric_exporter.js +38 -4
- package/dest/otel_resource.d.ts.map +1 -1
- package/dest/otel_resource.js +31 -2
- package/dest/prom_otel_adapter.d.ts +57 -8
- package/dest/prom_otel_adapter.d.ts.map +1 -1
- package/dest/prom_otel_adapter.js +143 -43
- package/dest/start.js +4 -4
- package/dest/telemetry.d.ts +28 -11
- package/dest/telemetry.d.ts.map +1 -1
- package/dest/telemetry.js +1 -1
- package/dest/vendor/otel-pino-stream.d.ts +0 -1
- package/dest/vendor/otel-pino-stream.d.ts.map +1 -1
- package/dest/vendor/otel-pino-stream.js +2 -2
- package/dest/wrappers/fetch.d.ts +1 -1
- package/dest/wrappers/fetch.d.ts.map +1 -1
- package/dest/wrappers/fetch.js +7 -5
- package/dest/wrappers/json_rpc_server.d.ts +1 -1
- package/dest/wrappers/json_rpc_server.d.ts.map +1 -1
- package/dest/wrappers/l2_block_stream.d.ts +1 -1
- package/dest/wrappers/l2_block_stream.d.ts.map +1 -1
- package/package.json +16 -13
- package/src/attributes.ts +27 -11
- package/src/bench.ts +15 -5
- package/src/config.ts +41 -2
- package/src/index.ts +1 -0
- package/src/l1_metrics.ts +80 -0
- package/src/lmdb_metrics.ts +24 -3
- package/src/metrics.ts +106 -12
- package/src/{event_loop_monitor.ts → nodejs_metrics_monitor.ts} +59 -10
- package/src/noop.ts +4 -1
- package/src/otel.ts +66 -21
- package/src/otel_filter_metric_exporter.ts +47 -5
- package/src/otel_resource.ts +40 -2
- package/src/prom_otel_adapter.ts +191 -59
- package/src/start.ts +4 -4
- package/src/telemetry.ts +50 -12
- package/src/vendor/otel-pino-stream.ts +1 -4
- package/src/wrappers/fetch.ts +24 -31
- package/src/wrappers/json_rpc_server.ts +1 -1
- package/src/wrappers/l2_block_stream.ts +1 -1
- package/dest/event_loop_monitor.d.ts.map +0 -1
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import { ExportResultCode } from '@opentelemetry/core';
|
|
2
|
+
import { AZTEC_NODE_ROLE } from './attributes.js';
|
|
1
3
|
export class OtelFilterMetricExporter {
|
|
2
4
|
exporter;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
+
metricPrefix;
|
|
6
|
+
filter;
|
|
7
|
+
constructor(exporter, metricPrefix, filter = 'deny'){
|
|
5
8
|
this.exporter = exporter;
|
|
6
|
-
this.
|
|
9
|
+
this.metricPrefix = metricPrefix;
|
|
10
|
+
this.filter = filter;
|
|
7
11
|
if (exporter.selectAggregation) {
|
|
8
12
|
this.selectAggregation = exporter.selectAggregation.bind(exporter);
|
|
9
13
|
}
|
|
@@ -22,7 +26,15 @@ export class OtelFilterMetricExporter {
|
|
|
22
26
|
this.exporter.export(filteredMetrics, resultCallback);
|
|
23
27
|
}
|
|
24
28
|
filterMetrics(metrics) {
|
|
25
|
-
return metrics.filter((metric)
|
|
29
|
+
return metrics.filter((metric)=>{
|
|
30
|
+
const matched = this.metricPrefix.some((prefix)=>metric.descriptor.name.startsWith(prefix));
|
|
31
|
+
if (this.filter === 'deny') {
|
|
32
|
+
return !matched;
|
|
33
|
+
}
|
|
34
|
+
if (this.filter === 'allow') {
|
|
35
|
+
return matched;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
26
38
|
}
|
|
27
39
|
forceFlush() {
|
|
28
40
|
return this.exporter.forceFlush();
|
|
@@ -30,4 +42,26 @@ export class OtelFilterMetricExporter {
|
|
|
30
42
|
shutdown() {
|
|
31
43
|
return this.exporter.shutdown();
|
|
32
44
|
}
|
|
45
|
+
setMetricPrefixes(metrics) {
|
|
46
|
+
this.metricPrefix = metrics;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export class PublicOtelFilterMetricExporter extends OtelFilterMetricExporter {
|
|
50
|
+
allowedRoles;
|
|
51
|
+
constructor(allowedRoles, exporter, metricPrefix){
|
|
52
|
+
super(exporter, metricPrefix, 'allow'), this.allowedRoles = allowedRoles;
|
|
53
|
+
}
|
|
54
|
+
export(metrics, resultCallback) {
|
|
55
|
+
const role = String(metrics.resource.attributes[AZTEC_NODE_ROLE] ?? '');
|
|
56
|
+
if (!role || !this.allowedRoles.includes(role)) {
|
|
57
|
+
// noop
|
|
58
|
+
return resultCallback({
|
|
59
|
+
code: ExportResultCode.SUCCESS
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
super.export(metrics, resultCallback);
|
|
63
|
+
}
|
|
64
|
+
setAllowedRoles(roles) {
|
|
65
|
+
this.allowedRoles = roles;
|
|
66
|
+
}
|
|
33
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otel_resource.d.ts","sourceRoot":"","sources":["../src/otel_resource.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"otel_resource.d.ts","sourceRoot":"","sources":["../src/otel_resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EAMf,MAAM,0BAA0B,CAAC;AAKlC,wBAAgB,eAAe,IAAI,SAAS,CAe3C"}
|
package/dest/otel_resource.js
CHANGED
|
@@ -1,12 +1,41 @@
|
|
|
1
|
-
import { detectResourcesSync, envDetectorSync, osDetectorSync,
|
|
1
|
+
import { Resource, detectResourcesSync, envDetectorSync, osDetectorSync, serviceInstanceIdDetectorSync } from '@opentelemetry/resources';
|
|
2
|
+
import { SEMRESATTRS_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
|
|
3
|
+
import { AZTEC_NODE_ROLE, AZTEC_REGISTRY_ADDRESS, AZTEC_ROLLUP_ADDRESS, AZTEC_ROLLUP_VERSION } from './attributes.js';
|
|
2
4
|
export function getOtelResource() {
|
|
3
5
|
const resource = detectResourcesSync({
|
|
4
6
|
detectors: [
|
|
7
|
+
aztecNetworkDetectorSync,
|
|
5
8
|
osDetectorSync,
|
|
6
9
|
envDetectorSync,
|
|
7
|
-
|
|
10
|
+
// this detector is disabled because:
|
|
11
|
+
// 1. our software runs in a docker container, a lot of the attributes detected would be identical across different machines (e.g. all run node v22, executing the same script, running PID 1, etc)
|
|
12
|
+
// 2. it catures process.argv which could contain sensitive values in plain text (e.g. validator private keys)
|
|
13
|
+
// processDetectorSync,
|
|
8
14
|
serviceInstanceIdDetectorSync
|
|
9
15
|
]
|
|
10
16
|
});
|
|
11
17
|
return resource;
|
|
12
18
|
}
|
|
19
|
+
const aztecNetworkDetectorSync = {
|
|
20
|
+
detect () {
|
|
21
|
+
let role;
|
|
22
|
+
if (process.argv.includes('--sequencer')) {
|
|
23
|
+
role = 'sequencer';
|
|
24
|
+
} else if (process.argv.includes('--prover-node')) {
|
|
25
|
+
role = 'prover-node';
|
|
26
|
+
} else if (process.argv.includes('--node')) {
|
|
27
|
+
role = 'node';
|
|
28
|
+
} else if (process.argv.includes('--p2p-bootstrap')) {
|
|
29
|
+
role = 'bootnode';
|
|
30
|
+
}
|
|
31
|
+
const aztecAttributes = {
|
|
32
|
+
// this gets overwritten by OTEL_RESOURCE_ATTRIBUTES (if set)
|
|
33
|
+
[SEMRESATTRS_SERVICE_NAME]: role ? `aztec-${role}` : undefined,
|
|
34
|
+
[AZTEC_NODE_ROLE]: role,
|
|
35
|
+
[AZTEC_ROLLUP_VERSION]: process.env.ROLLUP_VERSION ?? 'canonical',
|
|
36
|
+
[AZTEC_ROLLUP_ADDRESS]: process.env.ROLLUP_CONTRACT_ADDRESS,
|
|
37
|
+
[AZTEC_REGISTRY_ADDRESS]: process.env.REGISTRY_CONTRACT_ADDRESS
|
|
38
|
+
};
|
|
39
|
+
return new Resource(aztecAttributes);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
@@ -97,18 +97,67 @@ export declare class OtelGauge<Labels extends LabelsGeneric = NoLabels> implemen
|
|
|
97
97
|
* Resets the gauge to initial state
|
|
98
98
|
*/
|
|
99
99
|
reset(): void;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Implementation of a Histogram collector
|
|
103
|
+
*/
|
|
104
|
+
export declare class OtelHistogram<Labels extends LabelsGeneric = NoLabels> implements IHistogram<Labels> {
|
|
105
|
+
private logger;
|
|
106
|
+
private labelNames;
|
|
107
|
+
private histogram;
|
|
108
|
+
constructor(logger: Logger, meter: Meter, name: string, help: string, buckets?: number[], labelNames?: Array<keyof Labels>);
|
|
109
|
+
/**
|
|
110
|
+
* Starts a timer and returns a function that when called will record the time elapsed
|
|
111
|
+
* @param labels - Optional labels for the observation
|
|
112
|
+
*/
|
|
113
|
+
startTimer(labels?: Labels): () => void;
|
|
114
|
+
/**
|
|
115
|
+
* Observes a value
|
|
116
|
+
* @param value - Value to observe
|
|
117
|
+
*/
|
|
118
|
+
observe(value: number): void;
|
|
119
|
+
/**
|
|
120
|
+
* Observes a value with labels
|
|
121
|
+
* @param labels - Labels object
|
|
122
|
+
* @param value - Value to observe
|
|
123
|
+
*/
|
|
124
|
+
observe(labels: Labels, value: number): void;
|
|
125
|
+
reset(): void;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Implementation of an AvgMinMax collector
|
|
129
|
+
*/
|
|
130
|
+
export declare class OtelAvgMinMax<Labels extends LabelsGeneric = NoLabels> implements IAvgMinMax<Labels> {
|
|
131
|
+
private logger;
|
|
132
|
+
private labelNames;
|
|
133
|
+
private gauges;
|
|
134
|
+
private currentValues;
|
|
135
|
+
private labeledValues;
|
|
136
|
+
constructor(logger: Logger, meter: Meter, name: string, help: string, labelNames?: Array<keyof Labels>);
|
|
137
|
+
/**
|
|
138
|
+
* Sets the values for calculating avg, min, max
|
|
139
|
+
* @param values - Array of values
|
|
140
|
+
*/
|
|
141
|
+
set(values: number[]): void;
|
|
100
142
|
/**
|
|
101
|
-
*
|
|
102
|
-
* @param labels - Labels object
|
|
103
|
-
* @
|
|
143
|
+
* Sets the values for calculating avg, min, max with labels
|
|
144
|
+
* @param labels - Labels object
|
|
145
|
+
* @param values - Array of values
|
|
104
146
|
*/
|
|
105
|
-
|
|
147
|
+
set(labels: Labels, values: number[]): void;
|
|
148
|
+
/**
|
|
149
|
+
* Resets all stored values
|
|
150
|
+
*/
|
|
151
|
+
reset(): void;
|
|
106
152
|
/**
|
|
107
|
-
*
|
|
108
|
-
* @param
|
|
109
|
-
* @
|
|
153
|
+
* General function to observe an aggregation
|
|
154
|
+
* @param result - Observer result
|
|
155
|
+
* @param aggregateFn - Function that calculates the aggregation
|
|
110
156
|
*/
|
|
111
|
-
private
|
|
157
|
+
private observeAggregation;
|
|
158
|
+
private observeAvg;
|
|
159
|
+
private observeMin;
|
|
160
|
+
private observeMax;
|
|
112
161
|
}
|
|
113
162
|
/**
|
|
114
163
|
* Otel metrics Adapter
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prom_otel_adapter.d.ts","sourceRoot":"","sources":["../src/prom_otel_adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"prom_otel_adapter.d.ts","sourceRoot":"","sources":["../src/prom_otel_adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,KAAK,EAAa,KAAK,EAAgC,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtG;;GAEG;AACH,KAAK,QAAQ,GAAG,MAAM,CAAC;AACvB,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAChC,MAAM,MAAM,eAAe,GAAG,GAAG,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;AAExD,oBAAY,aAAa;IACvB,OAAO,YAAY;IACnB,OAAO,YAAY;CACpB;AAED,KAAK,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AACtC,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;AACrD,KAAK,SAAS,CAAC,MAAM,SAAS,aAAa,IAAI,OAAO,CAAC,MAAM,MAAM,EAAE,MAAM,CAAC,CAAC;AAC7E,UAAU,SAAS,CAAC,MAAM,SAAS,aAAa;IAC9C,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;CAChC;AAED,UAAU,MAAM,CAAC,MAAM,SAAS,aAAa,GAAG,QAAQ;IACtD,GAAG,EAAE,QAAQ,SAAS,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,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3
|
import { Registry } from 'prom-client';
|
|
3
4
|
export var MessageSource = /*#__PURE__*/ function(MessageSource) {
|
|
4
5
|
MessageSource["forward"] = "forward";
|
|
@@ -59,7 +60,7 @@ export var MessageSource = /*#__PURE__*/ function(MessageSource) {
|
|
|
59
60
|
return;
|
|
60
61
|
}
|
|
61
62
|
for (const [labelStr, value] of this.labeledValues.entries()){
|
|
62
|
-
const labels =
|
|
63
|
+
const labels = parseLabelsSafely(labelStr, this.logger);
|
|
63
64
|
if (labels) {
|
|
64
65
|
result.observe(value, labels);
|
|
65
66
|
}
|
|
@@ -71,7 +72,7 @@ export var MessageSource = /*#__PURE__*/ function(MessageSource) {
|
|
|
71
72
|
return;
|
|
72
73
|
}
|
|
73
74
|
if (labelsOrValue) {
|
|
74
|
-
|
|
75
|
+
validateLabels(labelsOrValue, this.labelNames, 'Gauge');
|
|
75
76
|
const labelKey = JSON.stringify(labelsOrValue);
|
|
76
77
|
const currentValue = this.labeledValues.get(labelKey) ?? 0;
|
|
77
78
|
this.labeledValues.set(labelKey, currentValue + (value ?? 1));
|
|
@@ -84,7 +85,7 @@ export var MessageSource = /*#__PURE__*/ function(MessageSource) {
|
|
|
84
85
|
this.currentValue = labelsOrValue;
|
|
85
86
|
return;
|
|
86
87
|
}
|
|
87
|
-
|
|
88
|
+
validateLabels(labelsOrValue, this.labelNames, 'Gauge');
|
|
88
89
|
const labelKey = JSON.stringify(labelsOrValue);
|
|
89
90
|
this.labeledValues.set(labelKey, value);
|
|
90
91
|
}
|
|
@@ -93,7 +94,7 @@ export var MessageSource = /*#__PURE__*/ function(MessageSource) {
|
|
|
93
94
|
* @param labels - Optional labels object
|
|
94
95
|
*/ dec(labels) {
|
|
95
96
|
if (labels) {
|
|
96
|
-
|
|
97
|
+
validateLabels(labels, this.labelNames, 'Gauge');
|
|
97
98
|
const labelKey = JSON.stringify(labels);
|
|
98
99
|
const currentValue = this.labeledValues.get(labelKey) ?? 0;
|
|
99
100
|
this.labeledValues.set(labelKey, currentValue - 1);
|
|
@@ -107,58 +108,157 @@ export var MessageSource = /*#__PURE__*/ function(MessageSource) {
|
|
|
107
108
|
this.currentValue = 0;
|
|
108
109
|
this.labeledValues.clear();
|
|
109
110
|
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Implementation of a Histogram collector
|
|
114
|
+
*/ export class OtelHistogram {
|
|
115
|
+
logger;
|
|
116
|
+
labelNames;
|
|
117
|
+
histogram;
|
|
118
|
+
constructor(logger, meter, name, help, buckets = [], labelNames = []){
|
|
119
|
+
this.logger = logger;
|
|
120
|
+
this.labelNames = labelNames;
|
|
121
|
+
this.histogram = meter.createHistogram(name, {
|
|
122
|
+
description: help,
|
|
123
|
+
advice: buckets.length ? {
|
|
124
|
+
explicitBucketBoundaries: buckets
|
|
125
|
+
} : undefined
|
|
126
|
+
});
|
|
127
|
+
}
|
|
110
128
|
/**
|
|
111
|
-
*
|
|
112
|
-
* @param labels -
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
throw new Error('Gauge was initialized without labels support');
|
|
129
|
+
* Starts a timer and returns a function that when called will record the time elapsed
|
|
130
|
+
* @param labels - Optional labels for the observation
|
|
131
|
+
*/ startTimer(labels) {
|
|
132
|
+
if (labels) {
|
|
133
|
+
validateLabels(labels, this.labelNames, 'Histogram');
|
|
117
134
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
135
|
+
const timer = new Timer();
|
|
136
|
+
return ()=>{
|
|
137
|
+
// Use timer.s() here to get the duration in seconds since this is only currently used by gossipsub_heartbeat_duration_seconds
|
|
138
|
+
const duration = timer.s();
|
|
139
|
+
if (labels) {
|
|
140
|
+
this.observe(labels, duration);
|
|
141
|
+
} else {
|
|
142
|
+
this.observe(duration);
|
|
121
143
|
}
|
|
122
|
-
}
|
|
144
|
+
};
|
|
123
145
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
return JSON.parse(labelStr);
|
|
131
|
-
} catch {
|
|
132
|
-
this.logger.error(`Failed to parse label string: ${labelStr}`);
|
|
133
|
-
return null;
|
|
146
|
+
observe(labelsOrValue, value) {
|
|
147
|
+
if (typeof labelsOrValue === 'number') {
|
|
148
|
+
this.histogram.record(labelsOrValue);
|
|
149
|
+
} else {
|
|
150
|
+
validateLabels(labelsOrValue, this.labelNames, 'Histogram');
|
|
151
|
+
this.histogram.record(value, labelsOrValue);
|
|
134
152
|
}
|
|
135
153
|
}
|
|
154
|
+
reset() {
|
|
155
|
+
// OpenTelemetry histograms cannot be reset, but we implement the interface
|
|
156
|
+
this.logger.silent('OpenTelemetry histograms cannot be fully reset');
|
|
157
|
+
}
|
|
136
158
|
}
|
|
137
159
|
/**
|
|
138
|
-
*
|
|
139
|
-
*/ class
|
|
160
|
+
* Implementation of an AvgMinMax collector
|
|
161
|
+
*/ export class OtelAvgMinMax {
|
|
140
162
|
logger;
|
|
141
|
-
|
|
163
|
+
labelNames;
|
|
164
|
+
gauges;
|
|
165
|
+
currentValues;
|
|
166
|
+
labeledValues;
|
|
167
|
+
constructor(logger, meter, name, help, labelNames = []){
|
|
142
168
|
this.logger = logger;
|
|
169
|
+
this.labelNames = labelNames;
|
|
170
|
+
this.currentValues = [];
|
|
171
|
+
this.labeledValues = new Map();
|
|
172
|
+
// Create three separate gauges for avg, min, and max
|
|
173
|
+
this.gauges = {
|
|
174
|
+
avg: meter.createObservableGauge(`${name}_avg`, {
|
|
175
|
+
description: `${help} (average)`
|
|
176
|
+
}),
|
|
177
|
+
min: meter.createObservableGauge(`${name}_min`, {
|
|
178
|
+
description: `${help} (minimum)`
|
|
179
|
+
}),
|
|
180
|
+
max: meter.createObservableGauge(`${name}_max`, {
|
|
181
|
+
description: `${help} (maximum)`
|
|
182
|
+
})
|
|
183
|
+
};
|
|
184
|
+
// Register callbacks for each gauge
|
|
185
|
+
this.gauges.avg.addCallback(this.observeAvg.bind(this));
|
|
186
|
+
this.gauges.min.addCallback(this.observeMin.bind(this));
|
|
187
|
+
this.gauges.max.addCallback(this.observeMax.bind(this));
|
|
143
188
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
189
|
+
set(labelsOrValues, values) {
|
|
190
|
+
if (Array.isArray(labelsOrValues)) {
|
|
191
|
+
this.currentValues = labelsOrValues;
|
|
192
|
+
return;
|
|
193
|
+
} else {
|
|
194
|
+
validateLabels(labelsOrValues, this.labelNames, 'AvgMinMax');
|
|
195
|
+
const labelKey = JSON.stringify(labelsOrValues);
|
|
196
|
+
this.labeledValues.set(labelKey, values || []);
|
|
197
|
+
}
|
|
147
198
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
199
|
+
/**
|
|
200
|
+
* Resets all stored values
|
|
201
|
+
*/ reset() {
|
|
202
|
+
this.currentValues = [];
|
|
203
|
+
this.labeledValues.clear();
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* General function to observe an aggregation
|
|
207
|
+
* @param result - Observer result
|
|
208
|
+
* @param aggregateFn - Function that calculates the aggregation
|
|
209
|
+
*/ observeAggregation(result, aggregateFn) {
|
|
210
|
+
// Observe unlabeled values
|
|
211
|
+
if (this.currentValues.length > 0) {
|
|
212
|
+
result.observe(aggregateFn(this.currentValues));
|
|
213
|
+
}
|
|
214
|
+
// Observe labeled values
|
|
215
|
+
for (const [labelStr, values] of this.labeledValues.entries()){
|
|
216
|
+
if (values.length > 0) {
|
|
217
|
+
const labels = parseLabelsSafely(labelStr, this.logger);
|
|
218
|
+
if (labels) {
|
|
219
|
+
result.observe(aggregateFn(values), labels);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
observeAvg(result) {
|
|
225
|
+
this.observeAggregation(result, (arr)=>arr.reduce((sum, val)=>sum + val, 0) / arr.length);
|
|
226
|
+
}
|
|
227
|
+
observeMin(result) {
|
|
228
|
+
this.observeAggregation(result, (arr)=>Math.min.apply(null, arr));
|
|
229
|
+
}
|
|
230
|
+
observeMax(result) {
|
|
231
|
+
this.observeAggregation(result, (arr)=>Math.max.apply(null, arr));
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Validates that provided labels match the expected schema
|
|
236
|
+
* @param labels - Labels object to validate
|
|
237
|
+
* @param labelNames - Array of allowed label names
|
|
238
|
+
* @param metricType - Type of metric for error message ('Gauge', 'Histogram', 'AvgMinMax')
|
|
239
|
+
* @throws Error if invalid labels are provided
|
|
240
|
+
*/ function validateLabels(labels, labelNames, metricType) {
|
|
241
|
+
if (labelNames.length === 0) {
|
|
242
|
+
throw new Error(`${metricType} was initialized without labels support`);
|
|
243
|
+
}
|
|
244
|
+
for (const key of Object.keys(labels)){
|
|
245
|
+
if (!labelNames.includes(key)) {
|
|
246
|
+
throw new Error(`Invalid label key: ${key}`);
|
|
247
|
+
}
|
|
151
248
|
}
|
|
152
249
|
}
|
|
153
250
|
/**
|
|
154
|
-
*
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
251
|
+
* Safely parses label string back to object
|
|
252
|
+
* @param labelStr - Stringified labels object
|
|
253
|
+
* @param logger - Logger instance for error reporting
|
|
254
|
+
* @returns Labels object or null if parsing fails
|
|
255
|
+
*/ function parseLabelsSafely(labelStr, logger) {
|
|
256
|
+
try {
|
|
257
|
+
return JSON.parse(labelStr);
|
|
258
|
+
} catch {
|
|
259
|
+
logger.error(`Failed to parse label string: ${labelStr}`);
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
162
262
|
}
|
|
163
263
|
/**
|
|
164
264
|
* Otel metrics Adapter
|
|
@@ -175,9 +275,9 @@ export var MessageSource = /*#__PURE__*/ function(MessageSource) {
|
|
|
175
275
|
return new OtelGauge(this.logger, this.meter, configuration.name, configuration.help, configuration.labelNames);
|
|
176
276
|
}
|
|
177
277
|
histogram(configuration) {
|
|
178
|
-
return new
|
|
278
|
+
return new OtelHistogram(this.logger, this.meter, configuration.name, configuration.help, configuration.buckets, configuration.labelNames);
|
|
179
279
|
}
|
|
180
280
|
avgMinMax(configuration) {
|
|
181
|
-
return new
|
|
281
|
+
return new OtelAvgMinMax(this.logger, this.meter, configuration.name, configuration.help, configuration.labelNames);
|
|
182
282
|
}
|
|
183
283
|
}
|
package/dest/start.js
CHANGED
|
@@ -2,21 +2,21 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
2
2
|
import { NoopTelemetryClient } from './noop.js';
|
|
3
3
|
import { OpenTelemetryClient } from './otel.js';
|
|
4
4
|
export * from './config.js';
|
|
5
|
-
let
|
|
5
|
+
let initialized = false;
|
|
6
6
|
let telemetry = new NoopTelemetryClient();
|
|
7
7
|
export function initTelemetryClient(config) {
|
|
8
8
|
const log = createLogger('telemetry:client');
|
|
9
|
-
if (
|
|
9
|
+
if (initialized) {
|
|
10
10
|
log.warn('Telemetry client has already been initialized once');
|
|
11
11
|
return telemetry;
|
|
12
12
|
}
|
|
13
|
-
if (config.metricsCollectorUrl) {
|
|
13
|
+
if (config.metricsCollectorUrl || config.publicMetricsCollectorUrl) {
|
|
14
14
|
log.info(`Using OpenTelemetry client with custom collector`);
|
|
15
15
|
telemetry = OpenTelemetryClient.createAndStart(config, log);
|
|
16
16
|
} else {
|
|
17
17
|
log.info('Using NoopTelemetryClient');
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
initialized = true;
|
|
20
20
|
return telemetry;
|
|
21
21
|
}
|
|
22
22
|
export function getTelemetryClient() {
|
package/dest/telemetry.d.ts
CHANGED
|
@@ -3,19 +3,28 @@ import type * as Attributes from './attributes.js';
|
|
|
3
3
|
import type * as Metrics from './metrics.js';
|
|
4
4
|
export { type Span, SpanStatusCode, ValueType } from '@opentelemetry/api';
|
|
5
5
|
type ValuesOf<T> = T extends Record<string, infer U> ? U : never;
|
|
6
|
+
type AttributeNames = ValuesOf<typeof Attributes>;
|
|
7
|
+
/**
|
|
8
|
+
* This is a set of attributes that could lead to high cardinality in the metrics.
|
|
9
|
+
* If you find yourself wanting to capture this data in a metric consider if it makes sense to capture
|
|
10
|
+
* as the metric value instead of an attribute or consider logging instead.
|
|
11
|
+
*
|
|
12
|
+
* Think twice before removing an attribute from this list.
|
|
13
|
+
*/
|
|
14
|
+
type BannedMetricAttributeNames = (typeof Attributes)['BLOCK_NUMBER' | 'BLOCK_ARCHIVE' | 'SLOT_NUMBER' | 'BLOCK_PARENT' | 'BLOCK_CANDIDATE_TXS_COUNT' | 'BLOCK_TXS_COUNT' | 'BLOCK_SIZE' | 'EPOCH_SIZE' | 'EPOCH_NUMBER' | 'TX_HASH' | 'PROVING_JOB_ID' | 'P2P_ID' | 'P2P_REQ_RESP_BATCH_REQUESTS_COUNT' | 'TARGET_ADDRESS' | 'MANA_USED' | 'TOTAL_INSTRUCTIONS'];
|
|
6
15
|
/** Global registry of attributes */
|
|
7
|
-
type AttributesType = Partial<Record<
|
|
8
|
-
|
|
16
|
+
export type AttributesType = Partial<Record<AttributeNames, AttributeValue>>;
|
|
17
|
+
/** Subset of attributes allowed to be added to metrics */
|
|
18
|
+
export type MetricAttributesType = Partial<Record<Exclude<AttributeNames, BannedMetricAttributeNames>, AttributeValue>>;
|
|
9
19
|
/** Global registry of metrics */
|
|
10
|
-
type MetricsType = (typeof Metrics)[keyof typeof Metrics];
|
|
11
|
-
export type
|
|
12
|
-
export type
|
|
13
|
-
export type
|
|
14
|
-
export type
|
|
15
|
-
export type
|
|
16
|
-
export type
|
|
17
|
-
export type
|
|
18
|
-
export type BatchObservableResult = OtelBatchObservableResult<AttributesType>;
|
|
20
|
+
export type MetricsType = (typeof Metrics)[keyof typeof Metrics];
|
|
21
|
+
export type Gauge = OtelGauge<MetricAttributesType>;
|
|
22
|
+
export type Histogram = OtelHistogram<MetricAttributesType>;
|
|
23
|
+
export type UpDownCounter = OtelUpDownCounter<MetricAttributesType>;
|
|
24
|
+
export type ObservableGauge = OtelObservableGauge<MetricAttributesType>;
|
|
25
|
+
export type ObservableUpDownCounter = OtelObservableUpDownCounter<MetricAttributesType>;
|
|
26
|
+
export type ObservableResult = OtelObservableResult<MetricAttributesType>;
|
|
27
|
+
export type BatchObservableResult = OtelBatchObservableResult<MetricAttributesType>;
|
|
19
28
|
export type { Tracer };
|
|
20
29
|
/**
|
|
21
30
|
* A meter that provides instruments for recording metrics.
|
|
@@ -80,6 +89,14 @@ export interface TelemetryClient {
|
|
|
80
89
|
* Flushes the telemetry client.
|
|
81
90
|
*/
|
|
82
91
|
flush(): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* Updates what telemetry is exported to the public collector
|
|
94
|
+
*/
|
|
95
|
+
setExportedPublicTelemetry(prefixes: string[]): void;
|
|
96
|
+
/**
|
|
97
|
+
* Updates the roles that would share telemetry (if enabled)
|
|
98
|
+
*/
|
|
99
|
+
setPublicTelemetryCollectFrom(roles: string[]): void;
|
|
83
100
|
}
|
|
84
101
|
/** Objects that adhere to this interface can use @trackSpan */
|
|
85
102
|
export interface Traceable {
|
package/dest/telemetry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,qBAAqB,IAAI,yBAAyB,EACvD,KAAK,KAAK,IAAI,SAAS,EACvB,KAAK,SAAS,IAAI,aAAa,EAC/B,KAAK,eAAe,IAAI,mBAAmB,EAC3C,KAAK,gBAAgB,IAAI,oBAAoB,EAC7C,KAAK,uBAAuB,IAAI,2BAA2B,EAC3D,KAAK,aAAa,IAAI,iBAAiB,EACvC,KAAK,IAAI,EAET,KAAK,MAAM,EACZ,MAAM,oBAAoB,CAAC;AAG5B,OAAO,KAAK,KAAK,UAAU,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,KAAK,OAAO,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entelemetry/api';
|
|
|
27
27
|
// run originalMethod wrapped in an active span
|
|
28
28
|
// "active" means the span will be alive for the duration of the function execution
|
|
29
29
|
// and if any other spans are started during the execution of originalMethod, they will be children of this span
|
|
30
|
-
// behind the scenes this uses AsyncLocalStorage https://nodejs.org/dist/latest-
|
|
30
|
+
// behind the scenes this uses AsyncLocalStorage https://nodejs.org/dist/latest-v22.x/docs/api/async_context.html
|
|
31
31
|
return this.tracer.startActiveSpan(name, async (span)=>{
|
|
32
32
|
span.setAttributes(currentAttrs ?? {});
|
|
33
33
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otel-pino-stream.d.ts","sourceRoot":"","sources":["../../src/vendor/otel-pino-stream.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"otel-pino-stream.d.ts","sourceRoot":"","sources":["../../src/vendor/otel-pino-stream.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AA2ElC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,WAI5C,MAAM,uBAIN,MAAM,aAOvB;AAED,UAAU,qBAAqB;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,GAAG,CAAC;IACZ,qBAAqB,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,MAAM,CAAC;CAC/C;AAED;;;;;GAKG;AACH,qBAAa,cAAe,SAAQ,QAAQ;IAC1C,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,OAAO,CAAC;IAChB,OAAO,CAAC,sBAAsB,CAAC;gBAEnB,OAAO,EAAE,qBAAqB;IAmBjC,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ;CAqGjE;AAMD,MAAM,CAAC,OAAO,WAAW,OAAO,EAAE,qBAAqB,GAAG,cAAc,CAMvE"}
|
|
@@ -20,7 +20,7 @@ import { millisToHrTime } from '@opentelemetry/core';
|
|
|
20
20
|
import { Writable } from 'stream';
|
|
21
21
|
import { registerOtelLoggerProvider } from '../otel_logger_provider.js';
|
|
22
22
|
import { getOtelResource } from '../otel_resource.js';
|
|
23
|
-
|
|
23
|
+
// This block is a copy (modulo code style and TypeScript types) of the Pino
|
|
24
24
|
// code that defines log level value and names. This file is part of
|
|
25
25
|
// *instrumenting* Pino, so we want to avoid a dependency on the library.
|
|
26
26
|
const DEFAULT_LEVELS = {
|
|
@@ -141,7 +141,7 @@ function severityNumberFromAztecPinoLevel(lvl) {
|
|
|
141
141
|
/* istanbul ignore if */ if (!s) {
|
|
142
142
|
return;
|
|
143
143
|
}
|
|
144
|
-
// Parse, and handle edge cases similar to how `pino-
|
|
144
|
+
// Parse, and handle edge cases similar to how `pino-abstract-transport` does:
|
|
145
145
|
// https://github.com/pinojs/pino-abstract-transport/blob/v1.2.0/index.js#L28-L45
|
|
146
146
|
// - Emitting an 'unknown' event on parse error mimicks pino-abstract-transport.
|
|
147
147
|
let recObj;
|
package/dest/wrappers/fetch.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type { Logger } from '@aztec/foundation/log';
|
|
|
7
7
|
* @param log - Optional logger for logging attempts.
|
|
8
8
|
* @returns A fetch function.
|
|
9
9
|
*/
|
|
10
|
-
export declare function makeTracedFetch(retries: number[], defaultNoRetry: boolean, fetch?: typeof defaultFetch, log?: Logger): (host: string,
|
|
10
|
+
export declare function makeTracedFetch(retries: number[], defaultNoRetry: boolean, fetch?: typeof defaultFetch, log?: Logger): (host: string, body: unknown, extraHeaders?: Record<string, string>, noRetry?: boolean) => Promise<{
|
|
11
11
|
response: any;
|
|
12
12
|
headers: {
|
|
13
13
|
get: (header: string) => string | null | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/wrappers/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAQpD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,cAAc,EAAE,OAAO,EAAE,KAAK,sBAAe,EAAE,GAAG,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/wrappers/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAQpD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,cAAc,EAAE,OAAO,EAAE,KAAK,sBAAe,EAAE,GAAG,CAAC,EAAE,MAAM,IACpG,MAAM,MAAM,EAAE,MAAM,OAAO,EAAE,eAAc,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,EAAE,UAAU,OAAO;;;;;GA2BlG"}
|