@aztec/telemetry-client 0.76.4 → 0.77.0-testnet-ignition.21
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 +3 -1
- package/dest/attributes.d.ts.map +1 -1
- package/dest/attributes.js +31 -61
- package/dest/bench.d.ts +5 -5
- package/dest/bench.d.ts.map +1 -1
- package/dest/bench.js +28 -15
- package/dest/config.d.ts +0 -6
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +11 -44
- package/dest/event_loop_monitor.js +29 -19
- package/dest/index.d.ts +2 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +2 -2
- package/dest/lmdb_metrics.d.ts +1 -1
- package/dest/lmdb_metrics.d.ts.map +1 -1
- package/dest/lmdb_metrics.js +21 -12
- package/dest/metrics.d.ts +10 -5
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +12 -10
- package/dest/noop.d.ts +1 -1
- package/dest/noop.d.ts.map +1 -1
- package/dest/noop.js +3 -6
- package/dest/otel.d.ts +4 -6
- package/dest/otel.d.ts.map +1 -1
- package/dest/otel.js +191 -90
- package/dest/otel_filter_metric_exporter.d.ts +2 -2
- package/dest/otel_filter_metric_exporter.d.ts.map +1 -1
- package/dest/otel_filter_metric_exporter.js +8 -6
- package/dest/otel_logger_provider.d.ts +1 -1
- package/dest/otel_logger_provider.d.ts.map +1 -1
- package/dest/otel_logger_provider.js +6 -7
- package/dest/otel_propagation.js +18 -12
- package/dest/otel_resource.d.ts.map +1 -1
- package/dest/otel_resource.js +3 -8
- package/dest/prom_otel_adapter.d.ts +2 -2
- package/dest/prom_otel_adapter.d.ts.map +1 -1
- package/dest/prom_otel_adapter.js +50 -53
- package/dest/start.d.ts +2 -2
- package/dest/start.d.ts.map +1 -1
- package/dest/start.js +3 -5
- package/dest/telemetry.d.ts +25 -25
- package/dest/telemetry.d.ts.map +1 -1
- package/dest/telemetry.js +25 -39
- package/dest/vendor/attributes.js +0 -1
- package/dest/vendor/otel-pino-stream.js +33 -49
- package/dest/with_tracer.d.ts +1 -1
- package/dest/with_tracer.d.ts.map +1 -1
- package/dest/with_tracer.js +3 -4
- package/dest/wrappers/fetch.d.ts +1 -1
- package/dest/wrappers/fetch.d.ts.map +1 -1
- package/dest/wrappers/fetch.js +15 -14
- package/dest/wrappers/index.js +0 -1
- package/dest/wrappers/json_rpc_server.d.ts +1 -1
- package/dest/wrappers/json_rpc_server.d.ts.map +1 -1
- package/dest/wrappers/json_rpc_server.js +4 -2
- package/dest/wrappers/l2_block_stream.d.ts +1 -1
- package/dest/wrappers/l2_block_stream.d.ts.map +1 -1
- package/dest/wrappers/l2_block_stream.js +24 -32
- package/package.json +5 -8
- package/src/attributes.ts +3 -1
- package/src/bench.ts +26 -32
- package/src/config.ts +1 -34
- package/src/event_loop_monitor.ts +3 -3
- package/src/index.ts +2 -1
- package/src/lmdb_metrics.ts +6 -6
- package/src/metrics.ts +10 -5
- package/src/noop.ts +1 -1
- package/src/otel.ts +53 -66
- package/src/otel_filter_metric_exporter.ts +2 -2
- package/src/otel_logger_provider.ts +1 -1
- package/src/otel_resource.ts +1 -11
- package/src/prom_otel_adapter.ts +8 -8
- package/src/start.ts +4 -4
- package/src/telemetry.ts +28 -28
- package/src/with_tracer.ts +1 -1
- package/src/wrappers/fetch.ts +1 -1
- package/src/wrappers/json_rpc_server.ts +1 -1
- package/src/wrappers/l2_block_stream.ts +2 -2
- package/dest/aztec_resource_detector.d.ts +0 -10
- package/dest/aztec_resource_detector.d.ts.map +0 -1
- package/dest/aztec_resource_detector.js +0 -20
- package/dest/histogram_utils.d.ts +0 -36
- package/dest/histogram_utils.d.ts.map +0 -1
- package/dest/histogram_utils.js +0 -50
- package/src/aztec_resource_detector.ts +0 -28
- package/src/histogram_utils.ts +0 -50
package/src/config.ts
CHANGED
|
@@ -1,26 +1,15 @@
|
|
|
1
|
-
import { type ConfigMappingsType,
|
|
1
|
+
import { type ConfigMappingsType, getConfigFromMappings } from '@aztec/foundation/config';
|
|
2
2
|
|
|
3
3
|
export interface TelemetryClientConfig {
|
|
4
|
-
useGcloudMetrics: boolean;
|
|
5
4
|
metricsCollectorUrl?: URL;
|
|
6
5
|
tracesCollectorUrl?: URL;
|
|
7
6
|
logsCollectorUrl?: URL;
|
|
8
|
-
serviceName: string;
|
|
9
|
-
networkName: string;
|
|
10
7
|
otelCollectIntervalMs: number;
|
|
11
8
|
otelExportTimeoutMs: number;
|
|
12
|
-
k8sPodUid?: string;
|
|
13
|
-
k8sPodName?: string;
|
|
14
|
-
k8sNamespaceName?: string;
|
|
15
9
|
otelExcludeMetrics?: string[];
|
|
16
10
|
}
|
|
17
11
|
|
|
18
12
|
export const telemetryClientConfigMappings: ConfigMappingsType<TelemetryClientConfig> = {
|
|
19
|
-
useGcloudMetrics: {
|
|
20
|
-
env: 'USE_GCLOUD_METRICS',
|
|
21
|
-
description: 'Whether to use GCP metrics and traces',
|
|
22
|
-
...booleanConfigHelper(false),
|
|
23
|
-
},
|
|
24
13
|
metricsCollectorUrl: {
|
|
25
14
|
env: 'OTEL_EXPORTER_OTLP_METRICS_ENDPOINT',
|
|
26
15
|
description: 'The URL of the telemetry collector for metrics',
|
|
@@ -36,16 +25,6 @@ export const telemetryClientConfigMappings: ConfigMappingsType<TelemetryClientCo
|
|
|
36
25
|
description: 'The URL of the telemetry collector for logs',
|
|
37
26
|
parseEnv: (val: string) => val && new URL(val),
|
|
38
27
|
},
|
|
39
|
-
serviceName: {
|
|
40
|
-
env: 'OTEL_SERVICE_NAME',
|
|
41
|
-
description: 'The name of the service (attached as metadata to collected metrics)',
|
|
42
|
-
defaultValue: 'aztec',
|
|
43
|
-
},
|
|
44
|
-
networkName: {
|
|
45
|
-
env: 'NETWORK_NAME',
|
|
46
|
-
description: 'The network ID of the telemetry service',
|
|
47
|
-
defaultValue: 'local',
|
|
48
|
-
},
|
|
49
28
|
otelCollectIntervalMs: {
|
|
50
29
|
env: 'OTEL_COLLECT_INTERVAL_MS',
|
|
51
30
|
description: 'The interval at which to collect metrics',
|
|
@@ -70,18 +49,6 @@ export const telemetryClientConfigMappings: ConfigMappingsType<TelemetryClientCo
|
|
|
70
49
|
: [],
|
|
71
50
|
defaultValue: [],
|
|
72
51
|
},
|
|
73
|
-
k8sPodUid: {
|
|
74
|
-
env: 'K8S_POD_UID',
|
|
75
|
-
description: 'The UID of the Kubernetes pod (injected automatically by k8s)',
|
|
76
|
-
},
|
|
77
|
-
k8sPodName: {
|
|
78
|
-
env: 'K8S_POD_NAME',
|
|
79
|
-
description: 'The name of the Kubernetes pod (injected automatically by k8s)',
|
|
80
|
-
},
|
|
81
|
-
k8sNamespaceName: {
|
|
82
|
-
env: 'K8S_NAMESPACE_NAME',
|
|
83
|
-
description: 'The name of the Kubernetes namespace (injected automatically by k8s)',
|
|
84
|
-
},
|
|
85
52
|
};
|
|
86
53
|
|
|
87
54
|
export function getConfigEnvVars(): TelemetryClientConfig {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type EventLoopUtilization, type IntervalHistogram, monitorEventLoopDelay, performance } from 'node:perf_hooks';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import * as Attributes from './attributes.js';
|
|
4
4
|
import * as Metrics from './metrics.js';
|
|
5
5
|
import {
|
|
6
6
|
type BatchObservableResult,
|
|
@@ -103,8 +103,8 @@ export class EventLoopMonitor {
|
|
|
103
103
|
// - https://youtu.be/WetXnEPraYM
|
|
104
104
|
obs.observe(this.eventLoopUilization, delta.utilization);
|
|
105
105
|
|
|
106
|
-
this.eventLoopTime.add(Math.floor(delta.idle), { [NODEJS_EVENT_LOOP_STATE]: 'idle' });
|
|
107
|
-
this.eventLoopTime.add(Math.floor(delta.active), { [NODEJS_EVENT_LOOP_STATE]: 'active' });
|
|
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
108
|
|
|
109
109
|
obs.observe(this.eventLoopDelayGauges.min, Math.floor(this.eventLoopDelay.min));
|
|
110
110
|
obs.observe(this.eventLoopDelayGauges.mean, Math.floor(this.eventLoopDelay.mean));
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './telemetry.js';
|
|
2
|
-
export * from './
|
|
2
|
+
export * as Metrics from './metrics.js';
|
|
3
|
+
export * as Attributes from './attributes.js';
|
|
3
4
|
export * from './with_tracer.js';
|
|
4
5
|
export * from './prom_otel_adapter.js';
|
|
5
6
|
export * from './lmdb_metrics.js';
|
package/src/lmdb_metrics.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as Metrics from './metrics.js';
|
|
2
2
|
import {
|
|
3
|
-
type
|
|
3
|
+
type AttributesType,
|
|
4
4
|
type BatchObservableResult,
|
|
5
5
|
type Meter,
|
|
6
6
|
type ObservableGauge,
|
|
@@ -14,18 +14,18 @@ export class LmdbMetrics {
|
|
|
14
14
|
private dbUsedSize: ObservableGauge;
|
|
15
15
|
private dbNumItems: ObservableGauge;
|
|
16
16
|
|
|
17
|
-
constructor(meter: Meter, private attributes?:
|
|
18
|
-
this.dbMapSize = meter.createObservableGauge(DB_MAP_SIZE, {
|
|
17
|
+
constructor(meter: Meter, private attributes?: AttributesType, private getStats?: LmdbStatsCallback) {
|
|
18
|
+
this.dbMapSize = meter.createObservableGauge(Metrics.DB_MAP_SIZE, {
|
|
19
19
|
description: 'LMDB Map Size',
|
|
20
20
|
valueType: ValueType.INT,
|
|
21
21
|
unit: 'By',
|
|
22
22
|
});
|
|
23
|
-
this.dbUsedSize = meter.createObservableGauge(DB_USED_SIZE, {
|
|
23
|
+
this.dbUsedSize = meter.createObservableGauge(Metrics.DB_USED_SIZE, {
|
|
24
24
|
description: 'LMDB Used Size',
|
|
25
25
|
valueType: ValueType.INT,
|
|
26
26
|
unit: 'By',
|
|
27
27
|
});
|
|
28
|
-
this.dbNumItems = meter.createObservableGauge(DB_NUM_ITEMS, {
|
|
28
|
+
this.dbNumItems = meter.createObservableGauge(Metrics.DB_NUM_ITEMS, {
|
|
29
29
|
description: 'LMDB Num Items',
|
|
30
30
|
valueType: ValueType.INT,
|
|
31
31
|
});
|
package/src/metrics.ts
CHANGED
|
@@ -37,6 +37,7 @@ export const MEMPOOL_ATTESTATIONS_SIZE = 'aztec.mempool.attestations_size';
|
|
|
37
37
|
|
|
38
38
|
export const ARCHIVER_SYNC_DURATION = 'aztec.archiver.sync_duration';
|
|
39
39
|
export const ARCHIVER_L1_BLOCKS_SYNCED = 'aztec.archiver.l1_blocks_synced';
|
|
40
|
+
export const ARCHIVER_L1_BLOCK_HEIGHT = 'aztec.archiver.l1_block_height';
|
|
40
41
|
export const ARCHIVER_BLOCK_HEIGHT = 'aztec.archiver.block_height';
|
|
41
42
|
export const ARCHIVER_TX_COUNT = 'aztec.archiver.tx_count';
|
|
42
43
|
export const ARCHIVER_ROLLUP_PROOF_DELAY = 'aztec.archiver.rollup_proof_delay';
|
|
@@ -68,6 +69,7 @@ export const L1_PUBLISHER_BLOB_COUNT = 'aztec.l1_publisher.blob_count';
|
|
|
68
69
|
export const L1_PUBLISHER_BLOB_INCLUSION_BLOCKS = 'aztec.l1_publisher.blob_inclusion_blocks';
|
|
69
70
|
export const L1_PUBLISHER_BLOB_TX_SUCCESS = 'aztec.l1_publisher.blob_tx_success';
|
|
70
71
|
export const L1_PUBLISHER_BLOB_TX_FAILURE = 'aztec.l1_publisher.blob_tx_failure';
|
|
72
|
+
export const L1_PUBLISHER_BALANCE = 'aztec.l1_publisher.balance';
|
|
71
73
|
|
|
72
74
|
export const PEER_MANAGER_GOODBYES_SENT = 'aztec.peer_manager.goodbyes_sent';
|
|
73
75
|
export const PEER_MANAGER_GOODBYES_RECEIVED = 'aztec.peer_manager.goodbyes_received';
|
|
@@ -100,11 +102,13 @@ export const PROVING_ORCHESTRATOR_BASE_ROLLUP_INPUTS_DURATION =
|
|
|
100
102
|
|
|
101
103
|
export const PROVING_QUEUE_JOB_SIZE = 'aztec.proving_queue.job_size';
|
|
102
104
|
export const PROVING_QUEUE_SIZE = 'aztec.proving_queue.size';
|
|
103
|
-
export const
|
|
104
|
-
export const
|
|
105
|
-
export const
|
|
106
|
-
export const
|
|
107
|
-
export const
|
|
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';
|
|
108
112
|
export const PROVING_QUEUE_JOB_WAIT = 'aztec.proving_queue.job_wait';
|
|
109
113
|
export const PROVING_QUEUE_JOB_DURATION = 'aztec.proving_queue.job_duration';
|
|
110
114
|
export const PROVING_QUEUE_DB_NUM_ITEMS = 'aztec.proving_queue.db.num_items';
|
|
@@ -130,6 +134,7 @@ export const WORLD_STATE_OLDEST_BLOCK = 'aztec.world_state.oldest_block';
|
|
|
130
134
|
export const WORLD_STATE_DB_USED_SIZE = 'aztec.world_state.db_used_size';
|
|
131
135
|
export const WORLD_STATE_DB_NUM_ITEMS = 'aztec.world_state.db_num_items';
|
|
132
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';
|
|
133
138
|
|
|
134
139
|
export const PROOF_VERIFIER_COUNT = 'aztec.proof_verifier.count';
|
|
135
140
|
|
package/src/noop.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Meter, type Span, type SpanContext, type Tracer, createNoopMeter } from '@opentelemetry/api';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import type { TelemetryClient } from './telemetry.js';
|
|
4
4
|
|
|
5
5
|
export class NoopTelemetryClient implements TelemetryClient {
|
|
6
6
|
getMeter(): Meter {
|
package/src/otel.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { type LogData, type Logger, addLogDataHandler } from '@aztec/foundation/log';
|
|
2
2
|
|
|
3
|
-
import { MetricExporter as GoogleCloudMetricExporter } from '@google-cloud/opentelemetry-cloud-monitoring-exporter';
|
|
4
|
-
import { TraceExporter as GoogleCloudTraceExporter } from '@google-cloud/opentelemetry-cloud-trace-exporter';
|
|
5
3
|
import {
|
|
6
4
|
DiagConsoleLogger,
|
|
7
5
|
DiagLogLevel,
|
|
@@ -16,8 +14,8 @@ import {
|
|
|
16
14
|
import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http';
|
|
17
15
|
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
|
|
18
16
|
import { HostMetrics } from '@opentelemetry/host-metrics';
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
17
|
+
import type { IResource } from '@opentelemetry/resources';
|
|
18
|
+
import type { LoggerProvider } from '@opentelemetry/sdk-logs';
|
|
21
19
|
import {
|
|
22
20
|
ExplicitBucketHistogramAggregation,
|
|
23
21
|
InstrumentType,
|
|
@@ -29,20 +27,18 @@ import {
|
|
|
29
27
|
import { BatchSpanProcessor, NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
|
|
30
28
|
import { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION } from '@opentelemetry/semantic-conventions';
|
|
31
29
|
|
|
32
|
-
import {
|
|
30
|
+
import type { TelemetryClientConfig } from './config.js';
|
|
33
31
|
import { EventLoopMonitor } from './event_loop_monitor.js';
|
|
34
|
-
import { linearBuckets } from './histogram_utils.js';
|
|
35
32
|
import { OtelFilterMetricExporter } from './otel_filter_metric_exporter.js';
|
|
36
33
|
import { registerOtelLoggerProvider } from './otel_logger_provider.js';
|
|
37
34
|
import { getOtelResource } from './otel_resource.js';
|
|
38
|
-
import
|
|
35
|
+
import type { TelemetryClient } from './telemetry.js';
|
|
39
36
|
|
|
40
37
|
export type OpenTelemetryClientFactory = (resource: IResource, log: Logger) => OpenTelemetryClient;
|
|
41
38
|
|
|
42
39
|
export class OpenTelemetryClient implements TelemetryClient {
|
|
43
40
|
hostMetrics: HostMetrics | undefined;
|
|
44
41
|
eventLoopMonitor: EventLoopMonitor | undefined;
|
|
45
|
-
targetInfo: Gauge | undefined;
|
|
46
42
|
private meters: Map<string, Meter> = new Map<string, Meter>();
|
|
47
43
|
private tracers: Map<string, Tracer> = new Map<string, Tracer>();
|
|
48
44
|
|
|
@@ -99,14 +95,6 @@ export class OpenTelemetryClient implements TelemetryClient {
|
|
|
99
95
|
this.meterProvider.getMeter(this.resource.attributes[ATTR_SERVICE_NAME] as string),
|
|
100
96
|
);
|
|
101
97
|
|
|
102
|
-
// See these two links for more information on providing target information:
|
|
103
|
-
// https://opentelemetry.io/docs/specs/otel/compatibility/prometheus_and_openmetrics/#resource-attributes
|
|
104
|
-
// https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#supporting-target-metadata-in-both-push-based-and-pull-based-systems
|
|
105
|
-
this.targetInfo = this.meterProvider.getMeter('target').createGauge('target_info', {
|
|
106
|
-
description: 'Target metadata',
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
this.targetInfo.record(1, this.resource.attributes);
|
|
110
98
|
this.hostMetrics.start();
|
|
111
99
|
this.eventLoopMonitor.start();
|
|
112
100
|
}
|
|
@@ -153,22 +141,20 @@ export class OpenTelemetryClient implements TelemetryClient {
|
|
|
153
141
|
|
|
154
142
|
views: [
|
|
155
143
|
// Every histogram matching the selector (type + unit) gets these custom buckets assigned
|
|
144
|
+
new View({
|
|
145
|
+
instrumentType: InstrumentType.HISTOGRAM,
|
|
146
|
+
instrumentUnit: 's',
|
|
147
|
+
aggregation: new ExplicitBucketHistogramAggregation(
|
|
148
|
+
[1, 2, 4, 6, 10, 15, 30, 60, 90, 120, 180, 240, 300, 480, 600],
|
|
149
|
+
true,
|
|
150
|
+
),
|
|
151
|
+
}),
|
|
156
152
|
new View({
|
|
157
153
|
instrumentType: InstrumentType.HISTOGRAM,
|
|
158
154
|
instrumentUnit: 'ms',
|
|
159
155
|
aggregation: new ExplicitBucketHistogramAggregation(
|
|
160
|
-
//
|
|
161
|
-
[
|
|
162
|
-
...linearBuckets(5, 100, 20), // 20 buckets between 5 and 100ms
|
|
163
|
-
...linearBuckets(100, 1_000, 20).slice(1), // another 20 buckets between 100ms and 1s. slice(1) to remove duplicate 100
|
|
164
|
-
...linearBuckets(1_000, 10_000, 20).slice(1),
|
|
165
|
-
...linearBuckets(10_000, 60_000, 20).slice(1),
|
|
166
|
-
...linearBuckets(60_000, 300_000, 20).slice(1),
|
|
167
|
-
...linearBuckets(300_000, 600_000, 20).slice(1),
|
|
168
|
-
...linearBuckets(600_000, 1_200_000, 20).slice(1),
|
|
169
|
-
...linearBuckets(1_200_000, 1_800_000, 20).slice(1),
|
|
170
|
-
...linearBuckets(1_800_000, 3_600_000, 20).slice(1), // 1hr
|
|
171
|
-
],
|
|
156
|
+
// 10ms to 1 minute
|
|
157
|
+
[10, 20, 35, 50, 75, 100, 250, 500, 750, 1_000, 2_500, 5_000, 7_500, 10_000, 15_000, 30_000, 60_000],
|
|
172
158
|
true,
|
|
173
159
|
),
|
|
174
160
|
}),
|
|
@@ -176,13 +162,10 @@ export class OpenTelemetryClient implements TelemetryClient {
|
|
|
176
162
|
instrumentType: InstrumentType.HISTOGRAM,
|
|
177
163
|
instrumentUnit: 'us',
|
|
178
164
|
aggregation: new ExplicitBucketHistogramAggregation(
|
|
165
|
+
// 1us to 1s
|
|
179
166
|
[
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
...linearBuckets(1_000, 10_000, 90).slice(1), // 90 buckets between 1ms and 10ms
|
|
183
|
-
...linearBuckets(10_000, 100_000, 20).slice(1), // 20 buckets between 10ms and 100ms
|
|
184
|
-
...linearBuckets(100_000, 1_000_000, 20).slice(1), // 20 buckets between 100ms and 1s
|
|
185
|
-
...linearBuckets(1_000_000, 60_000_000, 20).slice(1), // 20 buckets between 1s and 1m
|
|
167
|
+
5, 10, 25, 50, 75, 100, 250, 500, 750, 1_000, 2_500, 5_000, 7_500, 10_000, 25_000, 50_000, 100_000,
|
|
168
|
+
250_000, 500_000, 1_000_000,
|
|
186
169
|
],
|
|
187
170
|
true,
|
|
188
171
|
),
|
|
@@ -191,13 +174,26 @@ export class OpenTelemetryClient implements TelemetryClient {
|
|
|
191
174
|
instrumentType: InstrumentType.HISTOGRAM,
|
|
192
175
|
instrumentUnit: 'By',
|
|
193
176
|
aggregation: new ExplicitBucketHistogramAggregation(
|
|
194
|
-
//
|
|
177
|
+
// from 32 bytes to 2MB
|
|
195
178
|
[
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
179
|
+
32,
|
|
180
|
+
64,
|
|
181
|
+
128,
|
|
182
|
+
256,
|
|
183
|
+
512,
|
|
184
|
+
1024, // 1kb
|
|
185
|
+
2048,
|
|
186
|
+
4096,
|
|
187
|
+
8192,
|
|
188
|
+
16384,
|
|
189
|
+
32768,
|
|
190
|
+
65536,
|
|
191
|
+
131072,
|
|
192
|
+
262144,
|
|
193
|
+
524288,
|
|
194
|
+
1048576, // 1mb
|
|
195
|
+
1572864,
|
|
196
|
+
2097152, // 2mb
|
|
201
197
|
],
|
|
202
198
|
true,
|
|
203
199
|
),
|
|
@@ -206,7 +202,10 @@ export class OpenTelemetryClient implements TelemetryClient {
|
|
|
206
202
|
instrumentType: InstrumentType.HISTOGRAM,
|
|
207
203
|
instrumentUnit: 'gas/s',
|
|
208
204
|
aggregation: new ExplicitBucketHistogramAggregation(
|
|
209
|
-
[
|
|
205
|
+
[
|
|
206
|
+
1_000, 5_000, 10_000, 25_000, 50_000, 100_000, 250_000, 500_000, 750_000, 1_000_000, 2_000_000, 4_000_000,
|
|
207
|
+
8_000_000, 10_000_000, 15_000_000, 30_000_000,
|
|
208
|
+
],
|
|
210
209
|
true,
|
|
211
210
|
),
|
|
212
211
|
}),
|
|
@@ -214,7 +213,10 @@ export class OpenTelemetryClient implements TelemetryClient {
|
|
|
214
213
|
instrumentType: InstrumentType.HISTOGRAM,
|
|
215
214
|
instrumentUnit: 'mana/s',
|
|
216
215
|
aggregation: new ExplicitBucketHistogramAggregation(
|
|
217
|
-
[
|
|
216
|
+
[
|
|
217
|
+
1_000, 5_000, 10_000, 25_000, 50_000, 100_000, 250_000, 500_000, 750_000, 1_000_000, 2_000_000, 4_000_000,
|
|
218
|
+
8_000_000, 10_000_000, 15_000_000, 30_000_000,
|
|
219
|
+
],
|
|
218
220
|
true,
|
|
219
221
|
),
|
|
220
222
|
}),
|
|
@@ -222,7 +224,10 @@ export class OpenTelemetryClient implements TelemetryClient {
|
|
|
222
224
|
instrumentType: InstrumentType.HISTOGRAM,
|
|
223
225
|
instrumentUnit: 'gas/block',
|
|
224
226
|
aggregation: new ExplicitBucketHistogramAggregation(
|
|
225
|
-
[
|
|
227
|
+
[
|
|
228
|
+
1_000, 5_000, 10_000, 25_000, 50_000, 100_000, 250_000, 500_000, 750_000, 1_000_000, 2_000_000, 4_000_000,
|
|
229
|
+
8_000_000, 10_000_000, 15_000_000, 30_000_000,
|
|
230
|
+
],
|
|
226
231
|
true,
|
|
227
232
|
),
|
|
228
233
|
}),
|
|
@@ -230,7 +235,10 @@ export class OpenTelemetryClient implements TelemetryClient {
|
|
|
230
235
|
instrumentType: InstrumentType.HISTOGRAM,
|
|
231
236
|
instrumentUnit: 'gas/tx',
|
|
232
237
|
aggregation: new ExplicitBucketHistogramAggregation(
|
|
233
|
-
[
|
|
238
|
+
[
|
|
239
|
+
25_000, 50_000, 100_000, 250_000, 500_000, 750_000, 1_000_000, 2_000_000, 4_000_000, 8_000_000,
|
|
240
|
+
10_000_000, 15_000_000, 30_000_000,
|
|
241
|
+
],
|
|
234
242
|
true,
|
|
235
243
|
),
|
|
236
244
|
}),
|
|
@@ -238,25 +246,6 @@ export class OpenTelemetryClient implements TelemetryClient {
|
|
|
238
246
|
});
|
|
239
247
|
}
|
|
240
248
|
|
|
241
|
-
private static getGcloudClientFactory(config: TelemetryClientConfig): OpenTelemetryClientFactory {
|
|
242
|
-
return (resource: IResource, log: Logger) => {
|
|
243
|
-
const tracerProvider = new NodeTracerProvider({
|
|
244
|
-
resource,
|
|
245
|
-
spanProcessors: [new BatchSpanProcessor(new GoogleCloudTraceExporter({ resourceFilter: /.*/ }))],
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
tracerProvider.register();
|
|
249
|
-
|
|
250
|
-
const meterProvider = OpenTelemetryClient.createMeterProvider(resource, {
|
|
251
|
-
exporter: new OtelFilterMetricExporter(new GoogleCloudMetricExporter(), config.otelExcludeMetrics ?? []),
|
|
252
|
-
exportTimeoutMillis: config.otelExportTimeoutMs,
|
|
253
|
-
exportIntervalMillis: config.otelCollectIntervalMs,
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
return new OpenTelemetryClient(resource, meterProvider, tracerProvider, undefined, log);
|
|
257
|
-
};
|
|
258
|
-
}
|
|
259
|
-
|
|
260
249
|
private static getCustomClientFactory(config: TelemetryClientConfig): OpenTelemetryClientFactory {
|
|
261
250
|
return (resource: IResource, log: Logger) => {
|
|
262
251
|
const tracerProvider = new NodeTracerProvider({
|
|
@@ -287,9 +276,7 @@ export class OpenTelemetryClient implements TelemetryClient {
|
|
|
287
276
|
|
|
288
277
|
public static createAndStart(config: TelemetryClientConfig, log: Logger): OpenTelemetryClient {
|
|
289
278
|
const resource = getOtelResource();
|
|
290
|
-
const factory = config
|
|
291
|
-
? OpenTelemetryClient.getGcloudClientFactory(config)
|
|
292
|
-
: OpenTelemetryClient.getCustomClientFactory(config);
|
|
279
|
+
const factory = OpenTelemetryClient.getCustomClientFactory(config);
|
|
293
280
|
|
|
294
281
|
const service = factory(resource, log);
|
|
295
282
|
service.start();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { ExportResult } from '@opentelemetry/core';
|
|
2
|
+
import type { MetricData, PushMetricExporter, ResourceMetrics } from '@opentelemetry/sdk-metrics';
|
|
3
3
|
|
|
4
4
|
export class OtelFilterMetricExporter implements PushMetricExporter {
|
|
5
5
|
constructor(private readonly exporter: PushMetricExporter, private readonly excludeMetricPrefixes: string[]) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { logs as otelLogs } from '@opentelemetry/api-logs';
|
|
2
2
|
import { OTLPLogExporter } from '@opentelemetry/exporter-logs-otlp-http';
|
|
3
3
|
import { CompressionAlgorithm } from '@opentelemetry/otlp-exporter-base';
|
|
4
|
-
import {
|
|
4
|
+
import type { IResource } from '@opentelemetry/resources';
|
|
5
5
|
import { BatchLogRecordProcessor, LoggerProvider } from '@opentelemetry/sdk-logs';
|
|
6
6
|
|
|
7
7
|
export function registerOtelLoggerProvider(resource: IResource, otelLogsUrl?: URL) {
|
package/src/otel_resource.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { GcpDetectorSync } from '@google-cloud/opentelemetry-resource-util';
|
|
2
1
|
import {
|
|
3
2
|
type IResource,
|
|
4
3
|
detectResourcesSync,
|
|
@@ -8,18 +7,9 @@ import {
|
|
|
8
7
|
serviceInstanceIdDetectorSync,
|
|
9
8
|
} from '@opentelemetry/resources';
|
|
10
9
|
|
|
11
|
-
import { aztecDetector } from './aztec_resource_detector.js';
|
|
12
|
-
|
|
13
10
|
export function getOtelResource(): IResource {
|
|
14
11
|
const resource = detectResourcesSync({
|
|
15
|
-
detectors: [
|
|
16
|
-
osDetectorSync,
|
|
17
|
-
envDetectorSync,
|
|
18
|
-
processDetectorSync,
|
|
19
|
-
serviceInstanceIdDetectorSync,
|
|
20
|
-
aztecDetector,
|
|
21
|
-
new GcpDetectorSync(),
|
|
22
|
-
],
|
|
12
|
+
detectors: [osDetectorSync, envDetectorSync, processDetectorSync, serviceInstanceIdDetectorSync],
|
|
23
13
|
});
|
|
24
14
|
|
|
25
15
|
return resource;
|
package/src/prom_otel_adapter.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
|
2
2
|
|
|
3
3
|
import { Registry } from 'prom-client';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import type { Meter, MetricsType, ObservableGauge, TelemetryClient } from './telemetry.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Types matching the gossipsub and libp2p services
|
|
@@ -62,7 +62,7 @@ export interface MetricsRegister {
|
|
|
62
62
|
avgMinMax<Labels extends LabelsGeneric = NoLabels>(config: AvgMinMaxConfig<Labels>): IAvgMinMax<Labels>;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
/**Otel
|
|
65
|
+
/**Otel MetricsType Adapters
|
|
66
66
|
*
|
|
67
67
|
* Some dependencies we use export metrics directly in a Prometheus format
|
|
68
68
|
* This adapter is used to convert those metrics to a format that we can use with OpenTelemetry
|
|
@@ -93,7 +93,7 @@ export class OtelGauge<Labels extends LabelsGeneric = NoLabels> implements IGaug
|
|
|
93
93
|
help: string,
|
|
94
94
|
private labelNames: Array<keyof Labels> = [],
|
|
95
95
|
) {
|
|
96
|
-
this.gauge = meter.createObservableGauge(name as
|
|
96
|
+
this.gauge = meter.createObservableGauge(name as MetricsType, {
|
|
97
97
|
description: help,
|
|
98
98
|
});
|
|
99
99
|
|
|
@@ -237,7 +237,7 @@ class NoopOtelHistogram<Labels extends LabelsGeneric = NoLabels> implements IHis
|
|
|
237
237
|
constructor(
|
|
238
238
|
private logger: Logger,
|
|
239
239
|
_meter: Meter,
|
|
240
|
-
_name: string, //
|
|
240
|
+
_name: string, // MetricsType must be registered in the aztec labels registry
|
|
241
241
|
_help: string,
|
|
242
242
|
_buckets: number[] = [],
|
|
243
243
|
_labelNames: Array<keyof Labels> = [],
|
|
@@ -265,7 +265,7 @@ class NoopOtelAvgMinMax<Labels extends LabelsGeneric = NoLabels> implements IAvg
|
|
|
265
265
|
constructor(
|
|
266
266
|
private _logger: Logger,
|
|
267
267
|
_meter: Meter,
|
|
268
|
-
_name: string, //
|
|
268
|
+
_name: string, // MetricsType must be registered in the aztec labels registry
|
|
269
269
|
_help: string,
|
|
270
270
|
_labelNames: Array<keyof Labels> = [],
|
|
271
271
|
) {}
|
|
@@ -297,7 +297,7 @@ export class OtelMetricsAdapter extends Registry implements MetricsRegister {
|
|
|
297
297
|
return new OtelGauge<Labels>(
|
|
298
298
|
this.logger,
|
|
299
299
|
this.meter,
|
|
300
|
-
configuration.name as
|
|
300
|
+
configuration.name as MetricsType,
|
|
301
301
|
configuration.help,
|
|
302
302
|
configuration.labelNames,
|
|
303
303
|
);
|
|
@@ -307,7 +307,7 @@ export class OtelMetricsAdapter extends Registry implements MetricsRegister {
|
|
|
307
307
|
return new NoopOtelHistogram<Labels>(
|
|
308
308
|
this.logger,
|
|
309
309
|
this.meter,
|
|
310
|
-
configuration.name as
|
|
310
|
+
configuration.name as MetricsType,
|
|
311
311
|
configuration.help,
|
|
312
312
|
configuration.buckets,
|
|
313
313
|
configuration.labelNames,
|
|
@@ -318,7 +318,7 @@ export class OtelMetricsAdapter extends Registry implements MetricsRegister {
|
|
|
318
318
|
return new NoopOtelAvgMinMax<Labels>(
|
|
319
319
|
this.logger,
|
|
320
320
|
this.meter,
|
|
321
|
-
configuration.name as
|
|
321
|
+
configuration.name as MetricsType,
|
|
322
322
|
configuration.help,
|
|
323
323
|
configuration.labelNames,
|
|
324
324
|
);
|
package/src/start.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import type { TelemetryClientConfig } from './config.js';
|
|
4
4
|
import { NoopTelemetryClient } from './noop.js';
|
|
5
5
|
import { OpenTelemetryClient } from './otel.js';
|
|
6
|
-
import {
|
|
6
|
+
import type { TelemetryClient } from './telemetry.js';
|
|
7
7
|
|
|
8
8
|
export * from './config.js';
|
|
9
9
|
|
|
@@ -17,8 +17,8 @@ export function initTelemetryClient(config: TelemetryClientConfig): TelemetryCli
|
|
|
17
17
|
return telemetry;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
if (config.metricsCollectorUrl
|
|
21
|
-
log.info(`Using OpenTelemetry client
|
|
20
|
+
if (config.metricsCollectorUrl) {
|
|
21
|
+
log.info(`Using OpenTelemetry client with custom collector`);
|
|
22
22
|
telemetry = OpenTelemetryClient.createAndStart(config, log);
|
|
23
23
|
} else {
|
|
24
24
|
log.info('Using NoopTelemetryClient');
|