@aztec/telemetry-client 0.0.1-commit.934299a21 → 0.0.1-commit.949a33fd8
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 +5 -1
- package/dest/attributes.d.ts.map +1 -1
- package/dest/attributes.js +2 -0
- package/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +7 -9
- package/dest/lmdb_metrics.d.ts +2 -2
- package/dest/lmdb_metrics.d.ts.map +1 -1
- package/dest/metrics.d.ts +27 -1
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +148 -0
- package/dest/monitored_batch_span_processor.d.ts +24 -0
- package/dest/monitored_batch_span_processor.d.ts.map +1 -0
- package/dest/monitored_batch_span_processor.js +59 -0
- package/dest/otel.d.ts +1 -1
- package/dest/otel.d.ts.map +1 -1
- package/dest/otel.js +59 -3
- package/dest/wrappers/fetch.d.ts +3 -3
- package/dest/wrappers/fetch.d.ts.map +1 -1
- package/dest/wrappers/fetch.js +3 -2
- package/package.json +3 -3
- package/src/attributes.ts +5 -0
- package/src/config.ts +12 -9
- package/src/metrics.ts +152 -0
- package/src/monitored_batch_span_processor.ts +72 -0
- package/src/otel.ts +33 -2
- package/src/wrappers/fetch.ts +9 -3
package/src/otel.ts
CHANGED
|
@@ -28,12 +28,13 @@ import {
|
|
|
28
28
|
type PeriodicExportingMetricReaderOptions,
|
|
29
29
|
View,
|
|
30
30
|
} from '@opentelemetry/sdk-metrics';
|
|
31
|
-
import {
|
|
31
|
+
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
|
|
32
32
|
import { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION } from '@opentelemetry/semantic-conventions';
|
|
33
33
|
|
|
34
34
|
import type { TelemetryClientConfig } from './config.js';
|
|
35
35
|
import { toMetricOptions } from './metric-utils.js';
|
|
36
36
|
import type { MetricDefinition } from './metrics.js';
|
|
37
|
+
import { MonitoredBatchSpanProcessor } from './monitored_batch_span_processor.js';
|
|
37
38
|
import { NodejsMetricsMonitor } from './nodejs_metrics_monitor.js';
|
|
38
39
|
import { OtelFilterMetricExporter, PublicOtelFilterMetricExporter } from './otel_filter_metric_exporter.js';
|
|
39
40
|
import { registerOtelLoggerProvider } from './otel_logger_provider.js';
|
|
@@ -334,6 +335,36 @@ export class OpenTelemetryClient implements TelemetryClient {
|
|
|
334
335
|
true,
|
|
335
336
|
),
|
|
336
337
|
}),
|
|
338
|
+
// L1 gas prices in gwei: priority fees ~0.01-10, base fees ~1-500, spikes to 1000+
|
|
339
|
+
new View({
|
|
340
|
+
instrumentType: InstrumentType.HISTOGRAM,
|
|
341
|
+
instrumentUnit: 'gwei',
|
|
342
|
+
aggregation: new ExplicitBucketHistogramAggregation(
|
|
343
|
+
[0.1, 0.5, 1, 2, 5, 10, 20, 50, 100, 200, 500, 1_000],
|
|
344
|
+
true,
|
|
345
|
+
),
|
|
346
|
+
}),
|
|
347
|
+
// L1 gas consumption: tx gas 100k-30M, calldata/blob gas varies
|
|
348
|
+
new View({
|
|
349
|
+
instrumentType: InstrumentType.HISTOGRAM,
|
|
350
|
+
instrumentUnit: 'gas',
|
|
351
|
+
aggregation: new ExplicitBucketHistogramAggregation(
|
|
352
|
+
[
|
|
353
|
+
10_000, 50_000, 100_000, 250_000, 500_000, 1_000_000, 2_000_000, 5_000_000, 10_000_000, 15_000_000,
|
|
354
|
+
30_000_000,
|
|
355
|
+
],
|
|
356
|
+
true,
|
|
357
|
+
),
|
|
358
|
+
}),
|
|
359
|
+
// L1 tx total fee in ETH: typically 0.001 - 1 ETH
|
|
360
|
+
new View({
|
|
361
|
+
instrumentType: InstrumentType.HISTOGRAM,
|
|
362
|
+
instrumentUnit: 'eth',
|
|
363
|
+
aggregation: new ExplicitBucketHistogramAggregation(
|
|
364
|
+
[0.0001, 0.0005, 0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1, 5, 10],
|
|
365
|
+
true,
|
|
366
|
+
),
|
|
367
|
+
}),
|
|
337
368
|
],
|
|
338
369
|
});
|
|
339
370
|
}
|
|
@@ -343,7 +374,7 @@ export class OpenTelemetryClient implements TelemetryClient {
|
|
|
343
374
|
const tracerProvider = new NodeTracerProvider({
|
|
344
375
|
resource,
|
|
345
376
|
spanProcessors: config.tracesCollectorUrl
|
|
346
|
-
? [new
|
|
377
|
+
? [new MonitoredBatchSpanProcessor(new OTLPTraceExporter({ url: config.tracesCollectorUrl.href }), log)]
|
|
347
378
|
: [],
|
|
348
379
|
});
|
|
349
380
|
|
package/src/wrappers/fetch.ts
CHANGED
|
@@ -9,12 +9,17 @@ import { ATTR_JSONRPC_METHOD, ATTR_JSONRPC_REQUEST_ID } from '../vendor/attribut
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Makes a fetch function that retries based on the given attempts and propagates trace information.
|
|
12
|
-
* @param retries - Sequence of intervals (in seconds) to retry.
|
|
12
|
+
* @param retries - Sequence of intervals (in seconds) to retry, or a factory function returning an iterator for custom/indefinite backoff.
|
|
13
13
|
* @param noRetry - Whether to stop retries on server errors.
|
|
14
14
|
* @param log - Optional logger for logging attempts.
|
|
15
15
|
* @returns A fetch function.
|
|
16
16
|
*/
|
|
17
|
-
export function makeTracedFetch(
|
|
17
|
+
export function makeTracedFetch(
|
|
18
|
+
retries: number[] | (() => Generator<number>),
|
|
19
|
+
defaultNoRetry: boolean,
|
|
20
|
+
fetch = defaultFetch,
|
|
21
|
+
log?: Logger,
|
|
22
|
+
) {
|
|
18
23
|
return (host: string, body: unknown, extraHeaders: Record<string, string> = {}, noRetry?: boolean) => {
|
|
19
24
|
const telemetry = getTelemetryClient();
|
|
20
25
|
return telemetry.getTracer('fetch').startActiveSpan(`JsonRpcClient`, { kind: SpanKind.CLIENT }, async span => {
|
|
@@ -27,10 +32,11 @@ export function makeTracedFetch(retries: number[], defaultNoRetry: boolean, fetc
|
|
|
27
32
|
}
|
|
28
33
|
const headers = { ...extraHeaders };
|
|
29
34
|
propagation.inject(context.active(), headers);
|
|
35
|
+
const backoff = typeof retries === 'function' ? retries() : makeBackoff(retries);
|
|
30
36
|
return await retry(
|
|
31
37
|
() => fetch(host, body, headers, noRetry ?? defaultNoRetry),
|
|
32
38
|
`JsonRpcClient request to ${host}`,
|
|
33
|
-
|
|
39
|
+
backoff,
|
|
34
40
|
log,
|
|
35
41
|
false,
|
|
36
42
|
);
|