@aztec/telemetry-client 0.0.1-commit.6d3c34e → 0.0.1-commit.7035c9bd6
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 +11 -1
- package/dest/attributes.d.ts.map +1 -1
- package/dest/attributes.js +5 -0
- package/dest/lmdb_metrics.d.ts +2 -2
- package/dest/lmdb_metrics.d.ts.map +1 -1
- package/dest/metric-utils.d.ts +21 -2
- package/dest/metric-utils.d.ts.map +1 -1
- package/dest/metric-utils.js +52 -0
- package/dest/metrics.d.ts +53 -4
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +276 -12
- package/dest/nodejs_metrics_monitor.d.ts +1 -1
- package/dest/nodejs_metrics_monitor.d.ts.map +1 -1
- package/dest/nodejs_metrics_monitor.js +7 -1
- package/dest/otel_resource.d.ts +1 -1
- package/dest/otel_resource.d.ts.map +1 -1
- package/dest/otel_resource.js +14 -2
- package/dest/prom_otel_adapter.d.ts +4 -4
- package/dest/prom_otel_adapter.d.ts.map +1 -1
- package/dest/prom_otel_adapter.js +4 -3
- package/dest/start.d.ts +3 -2
- package/dest/start.d.ts.map +1 -1
- package/dest/start.js +2 -2
- package/dest/telemetry.d.ts +4 -3
- package/dest/telemetry.d.ts.map +1 -1
- package/dest/telemetry.js +1 -1
- package/dest/wrappers/l2_block_stream.d.ts +2 -2
- package/dest/wrappers/l2_block_stream.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/attributes.ts +15 -0
- package/src/metric-utils.ts +64 -1
- package/src/metrics.ts +282 -12
- package/src/nodejs_metrics_monitor.ts +4 -1
- package/src/otel_resource.ts +19 -2
- package/src/prom_otel_adapter.ts +4 -5
- package/src/start.ts +6 -3
- package/src/telemetry.ts +4 -2
- package/src/wrappers/l2_block_stream.ts +1 -1
|
@@ -2,6 +2,7 @@ import type { Observable } from '@opentelemetry/api';
|
|
|
2
2
|
import { type EventLoopUtilization, type IntervalHistogram, monitorEventLoopDelay, performance } from 'node:perf_hooks';
|
|
3
3
|
|
|
4
4
|
import * as Attributes from './attributes.js';
|
|
5
|
+
import { createUpDownCounterWithDefault } from './metric-utils.js';
|
|
5
6
|
import * as Metrics from './metrics.js';
|
|
6
7
|
import type { BatchObservableResult, Meter, ObservableGauge, UpDownCounter } from './telemetry.js';
|
|
7
8
|
|
|
@@ -41,7 +42,9 @@ export class NodejsMetricsMonitor {
|
|
|
41
42
|
};
|
|
42
43
|
|
|
43
44
|
this.eventLoopUilization = meter.createObservableGauge(Metrics.NODEJS_EVENT_LOOP_UTILIZATION);
|
|
44
|
-
this.eventLoopTime = meter
|
|
45
|
+
this.eventLoopTime = createUpDownCounterWithDefault(meter, Metrics.NODEJS_EVENT_LOOP_TIME, {
|
|
46
|
+
[Attributes.NODEJS_EVENT_LOOP_STATE]: ['idle', 'active'],
|
|
47
|
+
});
|
|
45
48
|
this.eventLoopDelay = monitorEventLoopDelay();
|
|
46
49
|
|
|
47
50
|
this.memoryGauges = {
|
package/src/otel_resource.ts
CHANGED
|
@@ -7,10 +7,26 @@ import {
|
|
|
7
7
|
osDetectorSync,
|
|
8
8
|
serviceInstanceIdDetectorSync,
|
|
9
9
|
} from '@opentelemetry/resources';
|
|
10
|
-
import {
|
|
10
|
+
import { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION } from '@opentelemetry/semantic-conventions';
|
|
11
|
+
import { readFileSync } from 'fs';
|
|
12
|
+
import { dirname, resolve } from 'path';
|
|
13
|
+
import { fileURLToPath } from 'url';
|
|
11
14
|
|
|
12
15
|
import { AZTEC_NODE_ROLE, AZTEC_REGISTRY_ADDRESS, AZTEC_ROLLUP_ADDRESS, AZTEC_ROLLUP_VERSION } from './attributes.js';
|
|
13
16
|
|
|
17
|
+
/** Reads the Aztec client version from the release manifest. */
|
|
18
|
+
function getAztecVersion(): string | undefined {
|
|
19
|
+
try {
|
|
20
|
+
const releasePleasePath = resolve(
|
|
21
|
+
dirname(fileURLToPath(import.meta.url)),
|
|
22
|
+
'../../../.release-please-manifest.json',
|
|
23
|
+
);
|
|
24
|
+
return JSON.parse(readFileSync(releasePleasePath, 'utf-8'))['.'];
|
|
25
|
+
} catch {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
14
30
|
export function getOtelResource(): IResource {
|
|
15
31
|
const resource = detectResourcesSync({
|
|
16
32
|
detectors: [
|
|
@@ -42,7 +58,8 @@ const aztecNetworkDetectorSync: DetectorSync = {
|
|
|
42
58
|
}
|
|
43
59
|
const aztecAttributes = {
|
|
44
60
|
// this gets overwritten by OTEL_RESOURCE_ATTRIBUTES (if set)
|
|
45
|
-
[
|
|
61
|
+
[ATTR_SERVICE_NAME]: role ? `aztec-${role}` : undefined,
|
|
62
|
+
[ATTR_SERVICE_VERSION]: getAztecVersion(),
|
|
46
63
|
[AZTEC_NODE_ROLE]: role,
|
|
47
64
|
[AZTEC_ROLLUP_VERSION]: process.env.ROLLUP_VERSION ?? 'canonical',
|
|
48
65
|
[AZTEC_ROLLUP_ADDRESS]: process.env.ROLLUP_CONTRACT_ADDRESS,
|
package/src/prom_otel_adapter.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
1
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import { Timer } from '@aztec/foundation/timer';
|
|
3
3
|
|
|
4
4
|
import { Registry } from 'prom-client';
|
|
@@ -410,12 +410,11 @@ function parseLabelsSafely<Labels extends LabelsGeneric>(labelStr: string, logge
|
|
|
410
410
|
*/
|
|
411
411
|
export class OtelMetricsAdapter extends Registry implements MetricsRegister {
|
|
412
412
|
private readonly meter: Meter;
|
|
413
|
+
private logger: Logger;
|
|
413
414
|
|
|
414
|
-
constructor(
|
|
415
|
-
telemetryClient: TelemetryClient,
|
|
416
|
-
private logger: Logger = createLogger('telemetry:otel-metrics-adapter'),
|
|
417
|
-
) {
|
|
415
|
+
constructor(telemetryClient: TelemetryClient, bindings?: LoggerBindings) {
|
|
418
416
|
super();
|
|
417
|
+
this.logger = createLogger('telemetry:otel-metrics-adapter', bindings);
|
|
419
418
|
this.meter = telemetryClient.getMeter('metrics-adapter');
|
|
420
419
|
}
|
|
421
420
|
|
package/src/start.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
1
|
+
import { type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
2
2
|
|
|
3
3
|
import type { TelemetryClientConfig } from './config.js';
|
|
4
4
|
import { NoopTelemetryClient } from './noop.js';
|
|
@@ -9,8 +9,11 @@ export * from './config.js';
|
|
|
9
9
|
let initialized = false;
|
|
10
10
|
let telemetry: TelemetryClient = new NoopTelemetryClient();
|
|
11
11
|
|
|
12
|
-
export async function initTelemetryClient(
|
|
13
|
-
|
|
12
|
+
export async function initTelemetryClient(
|
|
13
|
+
config: TelemetryClientConfig,
|
|
14
|
+
bindings?: LoggerBindings,
|
|
15
|
+
): Promise<TelemetryClient> {
|
|
16
|
+
const log = createLogger('telemetry:client', bindings);
|
|
14
17
|
if (initialized) {
|
|
15
18
|
log.warn('Telemetry client has already been initialized once');
|
|
16
19
|
return telemetry;
|
package/src/telemetry.ts
CHANGED
|
@@ -20,7 +20,7 @@ import type * as Attributes from './attributes.js';
|
|
|
20
20
|
import type { MetricDefinition } from './metrics.js';
|
|
21
21
|
import { getTelemetryClient } from './start.js';
|
|
22
22
|
|
|
23
|
-
export { toMetricOptions } from './metric-utils.js';
|
|
23
|
+
export { toMetricOptions, createUpDownCounterWithDefault } from './metric-utils.js';
|
|
24
24
|
|
|
25
25
|
export { type Span, SpanStatusCode, ValueType, type Context } from '@opentelemetry/api';
|
|
26
26
|
|
|
@@ -56,8 +56,10 @@ type BannedMetricAttributeNames = (typeof Attributes)[
|
|
|
56
56
|
/** Global registry of attributes */
|
|
57
57
|
export type AttributesType = Partial<Record<AttributeNames, AttributeValue>>;
|
|
58
58
|
|
|
59
|
+
export type AllowedAttributeNames = Exclude<AttributeNames, BannedMetricAttributeNames>;
|
|
60
|
+
|
|
59
61
|
/** Subset of attributes allowed to be added to metrics */
|
|
60
|
-
export type MetricAttributesType = Partial<Record<
|
|
62
|
+
export type MetricAttributesType = Partial<Record<AllowedAttributeNames, AttributeValue>>;
|
|
61
63
|
|
|
62
64
|
/** Re-export MetricDefinition for convenience */
|
|
63
65
|
export type { MetricDefinition } from './metrics.js';
|
|
@@ -13,7 +13,7 @@ export class TraceableL2BlockStream extends L2BlockStream implements Traceable {
|
|
|
13
13
|
constructor(
|
|
14
14
|
l2BlockSource: Pick<
|
|
15
15
|
L2BlockSource,
|
|
16
|
-
'
|
|
16
|
+
'getBlocks' | 'getBlockHeader' | 'getL2Tips' | 'getCheckpoints' | 'getCheckpointedBlocks'
|
|
17
17
|
>,
|
|
18
18
|
localData: L2BlockStreamLocalDataProvider,
|
|
19
19
|
handler: L2BlockStreamEventHandler,
|