@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.
Files changed (86) hide show
  1. package/dest/attributes.d.ts +3 -1
  2. package/dest/attributes.d.ts.map +1 -1
  3. package/dest/attributes.js +31 -61
  4. package/dest/bench.d.ts +5 -5
  5. package/dest/bench.d.ts.map +1 -1
  6. package/dest/bench.js +28 -15
  7. package/dest/config.d.ts +0 -6
  8. package/dest/config.d.ts.map +1 -1
  9. package/dest/config.js +11 -44
  10. package/dest/event_loop_monitor.js +29 -19
  11. package/dest/index.d.ts +2 -1
  12. package/dest/index.d.ts.map +1 -1
  13. package/dest/index.js +2 -2
  14. package/dest/lmdb_metrics.d.ts +1 -1
  15. package/dest/lmdb_metrics.d.ts.map +1 -1
  16. package/dest/lmdb_metrics.js +21 -12
  17. package/dest/metrics.d.ts +10 -5
  18. package/dest/metrics.d.ts.map +1 -1
  19. package/dest/metrics.js +12 -10
  20. package/dest/noop.d.ts +1 -1
  21. package/dest/noop.d.ts.map +1 -1
  22. package/dest/noop.js +3 -6
  23. package/dest/otel.d.ts +4 -6
  24. package/dest/otel.d.ts.map +1 -1
  25. package/dest/otel.js +191 -90
  26. package/dest/otel_filter_metric_exporter.d.ts +2 -2
  27. package/dest/otel_filter_metric_exporter.d.ts.map +1 -1
  28. package/dest/otel_filter_metric_exporter.js +8 -6
  29. package/dest/otel_logger_provider.d.ts +1 -1
  30. package/dest/otel_logger_provider.d.ts.map +1 -1
  31. package/dest/otel_logger_provider.js +6 -7
  32. package/dest/otel_propagation.js +18 -12
  33. package/dest/otel_resource.d.ts.map +1 -1
  34. package/dest/otel_resource.js +3 -8
  35. package/dest/prom_otel_adapter.d.ts +2 -2
  36. package/dest/prom_otel_adapter.d.ts.map +1 -1
  37. package/dest/prom_otel_adapter.js +50 -53
  38. package/dest/start.d.ts +2 -2
  39. package/dest/start.d.ts.map +1 -1
  40. package/dest/start.js +3 -5
  41. package/dest/telemetry.d.ts +25 -25
  42. package/dest/telemetry.d.ts.map +1 -1
  43. package/dest/telemetry.js +25 -39
  44. package/dest/vendor/attributes.js +0 -1
  45. package/dest/vendor/otel-pino-stream.js +33 -49
  46. package/dest/with_tracer.d.ts +1 -1
  47. package/dest/with_tracer.d.ts.map +1 -1
  48. package/dest/with_tracer.js +3 -4
  49. package/dest/wrappers/fetch.d.ts +1 -1
  50. package/dest/wrappers/fetch.d.ts.map +1 -1
  51. package/dest/wrappers/fetch.js +15 -14
  52. package/dest/wrappers/index.js +0 -1
  53. package/dest/wrappers/json_rpc_server.d.ts +1 -1
  54. package/dest/wrappers/json_rpc_server.d.ts.map +1 -1
  55. package/dest/wrappers/json_rpc_server.js +4 -2
  56. package/dest/wrappers/l2_block_stream.d.ts +1 -1
  57. package/dest/wrappers/l2_block_stream.d.ts.map +1 -1
  58. package/dest/wrappers/l2_block_stream.js +24 -32
  59. package/package.json +5 -8
  60. package/src/attributes.ts +3 -1
  61. package/src/bench.ts +26 -32
  62. package/src/config.ts +1 -34
  63. package/src/event_loop_monitor.ts +3 -3
  64. package/src/index.ts +2 -1
  65. package/src/lmdb_metrics.ts +6 -6
  66. package/src/metrics.ts +10 -5
  67. package/src/noop.ts +1 -1
  68. package/src/otel.ts +53 -66
  69. package/src/otel_filter_metric_exporter.ts +2 -2
  70. package/src/otel_logger_provider.ts +1 -1
  71. package/src/otel_resource.ts +1 -11
  72. package/src/prom_otel_adapter.ts +8 -8
  73. package/src/start.ts +4 -4
  74. package/src/telemetry.ts +28 -28
  75. package/src/with_tracer.ts +1 -1
  76. package/src/wrappers/fetch.ts +1 -1
  77. package/src/wrappers/json_rpc_server.ts +1 -1
  78. package/src/wrappers/l2_block_stream.ts +2 -2
  79. package/dest/aztec_resource_detector.d.ts +0 -10
  80. package/dest/aztec_resource_detector.d.ts.map +0 -1
  81. package/dest/aztec_resource_detector.js +0 -20
  82. package/dest/histogram_utils.d.ts +0 -36
  83. package/dest/histogram_utils.d.ts.map +0 -1
  84. package/dest/histogram_utils.js +0 -50
  85. package/src/aztec_resource_detector.ts +0 -28
  86. package/src/histogram_utils.ts +0 -50
package/src/telemetry.ts CHANGED
@@ -12,35 +12,35 @@ import {
12
12
  type UpDownCounter as OtelUpDownCounter,
13
13
  type Span,
14
14
  SpanStatusCode,
15
- Tracer,
15
+ type Tracer,
16
16
  } from '@opentelemetry/api';
17
17
  import { isPromise } from 'node:util/types';
18
18
 
19
- import * as Attributes from './attributes.js';
20
- import * as Metrics from './metrics.js';
19
+ import type * as Attributes from './attributes.js';
20
+ import type * as Metrics from './metrics.js';
21
21
  import { getTelemetryClient } from './start.js';
22
22
 
23
- export { Span, SpanStatusCode, ValueType } from '@opentelemetry/api';
23
+ export { type Span, SpanStatusCode, ValueType } from '@opentelemetry/api';
24
24
 
25
25
  type ValuesOf<T> = T extends Record<string, infer U> ? U : never;
26
26
 
27
27
  /** Global registry of attributes */
28
- type Attributes = Partial<Record<ValuesOf<typeof Attributes>, AttributeValue>>;
29
- export { Attributes };
28
+ type AttributesType = Partial<Record<ValuesOf<typeof Attributes>, AttributeValue>>;
29
+ export type { AttributesType };
30
30
 
31
31
  /** Global registry of metrics */
32
- type Metrics = (typeof Metrics)[keyof typeof Metrics];
33
- export { Metrics };
32
+ type MetricsType = (typeof Metrics)[keyof typeof Metrics];
33
+ export type { MetricsType };
34
34
 
35
- export type Gauge = OtelGauge<Attributes>;
36
- export type Histogram = OtelHistogram<Attributes>;
37
- export type UpDownCounter = OtelUpDownCounter<Attributes>;
38
- export type ObservableGauge = OtelObservableGauge<Attributes>;
39
- export type ObservableUpDownCounter = OtelObservableUpDownCounter<Attributes>;
40
- export type ObservableResult = OtelObservableResult<Attributes>;
41
- export type BatchObservableResult = OtelBatchObservableResult<Attributes>;
35
+ export type Gauge = OtelGauge<AttributesType>;
36
+ export type Histogram = OtelHistogram<AttributesType>;
37
+ export type UpDownCounter = OtelUpDownCounter<AttributesType>;
38
+ export type ObservableGauge = OtelObservableGauge<AttributesType>;
39
+ export type ObservableUpDownCounter = OtelObservableUpDownCounter<AttributesType>;
40
+ export type ObservableResult = OtelObservableResult<AttributesType>;
41
+ export type BatchObservableResult = OtelBatchObservableResult<AttributesType>;
42
42
 
43
- export { Tracer };
43
+ export type { Tracer };
44
44
 
45
45
  // INTERNAL NOTE: this interface is the same as opentelemetry's Meter, but with proper types
46
46
  /**
@@ -52,23 +52,23 @@ export interface Meter {
52
52
  * @param name - The name of the gauge
53
53
  * @param options - The options for the gauge
54
54
  */
55
- createGauge(name: Metrics, options?: MetricOptions): Gauge;
55
+ createGauge(name: MetricsType, options?: MetricOptions): Gauge;
56
56
 
57
57
  /**
58
58
  * Creates a new gauge instrument. A gauge is a metric that represents a single numerical value that can arbitrarily go up and down.
59
59
  * @param name - The name of the gauge
60
60
  * @param options - The options for the gauge
61
61
  */
62
- createObservableGauge(name: Metrics, options?: MetricOptions): ObservableGauge;
62
+ createObservableGauge(name: MetricsType, options?: MetricOptions): ObservableGauge;
63
63
 
64
64
  addBatchObservableCallback(
65
- callback: BatchObservableCallback<Attributes>,
66
- observables: Observable<Attributes>[],
65
+ callback: BatchObservableCallback<AttributesType>,
66
+ observables: Observable<AttributesType>[],
67
67
  ): void;
68
68
 
69
69
  removeBatchObservableCallback(
70
- callback: BatchObservableCallback<Attributes>,
71
- observables: Observable<Attributes>[],
70
+ callback: BatchObservableCallback<AttributesType>,
71
+ observables: Observable<AttributesType>[],
72
72
  ): void;
73
73
 
74
74
  /**
@@ -76,21 +76,21 @@ export interface Meter {
76
76
  * @param name - The name of the histogram
77
77
  * @param options - The options for the histogram
78
78
  */
79
- createHistogram(name: Metrics, options?: MetricOptions): Histogram;
79
+ createHistogram(name: MetricsType, options?: MetricOptions): Histogram;
80
80
 
81
81
  /**
82
82
  * Creates a new counter instrument. A counter can go up or down with a delta from the previous value.
83
83
  * @param name - The name of the counter
84
84
  * @param options - The options for the counter
85
85
  */
86
- createUpDownCounter(name: Metrics, options?: MetricOptions): UpDownCounter;
86
+ createUpDownCounter(name: MetricsType, options?: MetricOptions): UpDownCounter;
87
87
 
88
88
  /**
89
89
  * Creates a new gauge instrument. A gauge is a metric that represents a single numerical value that can arbitrarily go up and down.
90
90
  * @param name - The name of the gauge
91
91
  * @param options - The options for the gauge
92
92
  */
93
- createObservableUpDownCounter(name: Metrics, options?: MetricOptions): ObservableUpDownCounter;
93
+ createObservableUpDownCounter(name: MetricsType, options?: MetricOptions): ObservableUpDownCounter;
94
94
  }
95
95
 
96
96
  /**
@@ -151,8 +151,8 @@ type SpanDecorator<T extends Traceable, F extends (...args: any[]) => any> = (
151
151
  */
152
152
  export function trackSpan<T extends Traceable, F extends (...args: any[]) => any>(
153
153
  spanName: string | ((this: T, ...args: Parameters<F>) => string),
154
- attributes?: Attributes | ((this: T, ...args: Parameters<F>) => Promise<Attributes> | Attributes),
155
- extraAttributes?: (this: T, returnValue: Awaited<ReturnType<F>>) => Attributes,
154
+ attributes?: AttributesType | ((this: T, ...args: Parameters<F>) => Promise<AttributesType> | AttributesType),
155
+ extraAttributes?: (this: T, returnValue: Awaited<ReturnType<F>>) => AttributesType,
156
156
  ): SpanDecorator<T, F> {
157
157
  // the return value of trackSpan is a decorator
158
158
  return (originalMethod: F, _context: ClassMethodDecoratorContext<T>) => {
@@ -202,7 +202,7 @@ export function trackSpan<T extends Traceable, F extends (...args: any[]) => any
202
202
  export function wrapCallbackInSpan<F extends (...args: any[]) => any>(
203
203
  tracer: Tracer,
204
204
  spanName: string,
205
- attributes: Attributes,
205
+ attributes: AttributesType,
206
206
  callback: F,
207
207
  ): F {
208
208
  const span = tracer.startSpan(spanName, { attributes });
@@ -1,4 +1,4 @@
1
- import { type TelemetryClient, type Tracer } from './telemetry.js';
1
+ import type { TelemetryClient, Tracer } from './telemetry.js';
2
2
 
3
3
  /**
4
4
  * A minimal class that enables recording metrics with a telemetry client.
@@ -1,5 +1,5 @@
1
1
  import { defaultFetch } from '@aztec/foundation/json-rpc/client';
2
- import { type Logger } from '@aztec/foundation/log';
2
+ import type { Logger } from '@aztec/foundation/log';
3
3
  import { makeBackoff, retry } from '@aztec/foundation/retry';
4
4
 
5
5
  import { SpanKind, SpanStatusCode, context, propagation } from '@opentelemetry/api';
@@ -1,5 +1,5 @@
1
1
  import { type SafeJsonRpcServerOptions, createSafeJsonRpcServer } from '@aztec/foundation/json-rpc/server';
2
- import { type ApiSchemaFor } from '@aztec/foundation/schemas';
2
+ import type { ApiSchemaFor } from '@aztec/stdlib/schemas';
3
3
 
4
4
  import { getOtelJsonRpcPropagationMiddleware } from '../otel_propagation.js';
5
5
 
@@ -1,10 +1,10 @@
1
+ import { createLogger } from '@aztec/foundation/log';
1
2
  import {
2
3
  type L2BlockSource,
3
4
  L2BlockStream,
4
5
  type L2BlockStreamEventHandler,
5
6
  type L2BlockStreamLocalDataProvider,
6
- } from '@aztec/circuit-types';
7
- import { createLogger } from '@aztec/foundation/log';
7
+ } from '@aztec/stdlib/block';
8
8
  import { type Traceable, type Tracer, trackSpan } from '@aztec/telemetry-client';
9
9
 
10
10
  /** Extends an L2BlockStream with a tracer to create a new trace per iteration. */
@@ -1,10 +0,0 @@
1
- import { type DetectorSync, type IResource } from '@opentelemetry/resources';
2
- /**
3
- * Detector for custom Aztec attributes
4
- */
5
- declare class AztecDetector implements DetectorSync {
6
- detect(): IResource;
7
- }
8
- export declare const aztecDetector: AztecDetector;
9
- export {};
10
- //# sourceMappingURL=aztec_resource_detector.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"aztec_resource_detector.d.ts","sourceRoot":"","sources":["../src/aztec_resource_detector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAAY,MAAM,0BAA0B,CAAC;AAUvF;;GAEG;AACH,cAAM,aAAc,YAAW,YAAY;IACzC,MAAM,IAAI,SAAS;CAWpB;AAED,eAAO,MAAM,aAAa,eAAsB,CAAC"}
@@ -1,20 +0,0 @@
1
- import { Resource } from '@opentelemetry/resources';
2
- import { ATTR_K8S_NAMESPACE_NAME, ATTR_K8S_POD_NAME, ATTR_K8S_POD_UID, ATTR_SERVICE_INSTANCE_ID, } from '@opentelemetry/semantic-conventions/incubating';
3
- import { getConfigEnvVars } from './config.js';
4
- /**
5
- * Detector for custom Aztec attributes
6
- */
7
- class AztecDetector {
8
- detect() {
9
- const config = getConfigEnvVars();
10
- return new Resource({
11
- [ATTR_K8S_POD_UID]: config.k8sPodUid,
12
- [ATTR_K8S_POD_NAME]: config.k8sPodName,
13
- // this will get set by serviceInstanceIdDetector if not running in K8s
14
- [ATTR_SERVICE_INSTANCE_ID]: config.k8sPodUid,
15
- [ATTR_K8S_NAMESPACE_NAME]: config.k8sNamespaceName,
16
- });
17
- }
18
- }
19
- export const aztecDetector = new AztecDetector();
20
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXp0ZWNfcmVzb3VyY2VfZGV0ZWN0b3IuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvYXp0ZWNfcmVzb3VyY2VfZGV0ZWN0b3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFxQyxRQUFRLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUN2RixPQUFPLEVBQ0wsdUJBQXVCLEVBQ3ZCLGlCQUFpQixFQUNqQixnQkFBZ0IsRUFDaEIsd0JBQXdCLEdBQ3pCLE1BQU0sZ0RBQWdELENBQUM7QUFFeEQsT0FBTyxFQUFFLGdCQUFnQixFQUFFLE1BQU0sYUFBYSxDQUFDO0FBRS9DOztHQUVHO0FBQ0gsTUFBTSxhQUFhO0lBQ2pCLE1BQU07UUFDSixNQUFNLE1BQU0sR0FBRyxnQkFBZ0IsRUFBRSxDQUFDO1FBRWxDLE9BQU8sSUFBSSxRQUFRLENBQUM7WUFDbEIsQ0FBQyxnQkFBZ0IsQ0FBQyxFQUFFLE1BQU0sQ0FBQyxTQUFTO1lBQ3BDLENBQUMsaUJBQWlCLENBQUMsRUFBRSxNQUFNLENBQUMsVUFBVTtZQUN0Qyx1RUFBdUU7WUFDdkUsQ0FBQyx3QkFBd0IsQ0FBQyxFQUFFLE1BQU0sQ0FBQyxTQUFTO1lBQzVDLENBQUMsdUJBQXVCLENBQUMsRUFBRSxNQUFNLENBQUMsZ0JBQWdCO1NBQ25ELENBQUMsQ0FBQztJQUNMLENBQUM7Q0FDRjtBQUVELE1BQU0sQ0FBQyxNQUFNLGFBQWEsR0FBRyxJQUFJLGFBQWEsRUFBRSxDQUFDIn0=
@@ -1,36 +0,0 @@
1
- /**
2
- * Creates a set of buckets that follow linear growth
3
- * @param start - The start of the range
4
- * @param end - The end of the range
5
- * @param count - The number of buckets
6
- * @returns - An array of bucket boundaries
7
- */
8
- export declare function linearBuckets(start: number, end: number, count: number): number[];
9
- /**
10
- * Creates an array of exponential buckets that follow the formulas at
11
- * https://opentelemetry.io/docs/specs/otel/metrics/data-model/#exponential-buckets
12
- *
13
- * The formula followed is: bucket[i] = base ** i, where base = 2 ** (2 ** -scale). Naturally base will be very small when scale > 0.
14
- * This ensures that between each power of 2, there are 2 ** scale intermediate buckets.
15
- *
16
- * @example
17
- * scale = 2, count = 8
18
- * base = 2 ** (2 ** -2) = 1.189207115
19
- * |bucket index| value |
20
- * |------------|-------|
21
- * | 0 | 1 |
22
- * | 1 | 1.18 |
23
- * | 2 | 1.41 |
24
- * | 3 | 1.68 |
25
- * | 4 | 2 |
26
- * | 5 | 2.37 |
27
- * | 6 | 2.82 |
28
- * | 7 | 3.36 |
29
- * | 8 | 4 |
30
- *
31
- * @param scale - The "precision" of the buckets. The higher the scale, the more buckets will be created
32
- * @param count - The total number of buckets
33
- * @returns - An array of bucket boundaries
34
- */
35
- export declare function exponentialBuckets(scale: number, count: number): number[];
36
- //# sourceMappingURL=histogram_utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"histogram_utils.d.ts","sourceRoot":"","sources":["../src/histogram_utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAOjF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAOzE"}
@@ -1,50 +0,0 @@
1
- /**
2
- * Creates a set of buckets that follow linear growth
3
- * @param start - The start of the range
4
- * @param end - The end of the range
5
- * @param count - The number of buckets
6
- * @returns - An array of bucket boundaries
7
- */
8
- export function linearBuckets(start, end, count) {
9
- const buckets = [];
10
- const step = (end - start) / count;
11
- for (let i = 0; i <= count; i++) {
12
- buckets.push(Math.floor(start + i * step));
13
- }
14
- return buckets;
15
- }
16
- /**
17
- * Creates an array of exponential buckets that follow the formulas at
18
- * https://opentelemetry.io/docs/specs/otel/metrics/data-model/#exponential-buckets
19
- *
20
- * The formula followed is: bucket[i] = base ** i, where base = 2 ** (2 ** -scale). Naturally base will be very small when scale > 0.
21
- * This ensures that between each power of 2, there are 2 ** scale intermediate buckets.
22
- *
23
- * @example
24
- * scale = 2, count = 8
25
- * base = 2 ** (2 ** -2) = 1.189207115
26
- * |bucket index| value |
27
- * |------------|-------|
28
- * | 0 | 1 |
29
- * | 1 | 1.18 |
30
- * | 2 | 1.41 |
31
- * | 3 | 1.68 |
32
- * | 4 | 2 |
33
- * | 5 | 2.37 |
34
- * | 6 | 2.82 |
35
- * | 7 | 3.36 |
36
- * | 8 | 4 |
37
- *
38
- * @param scale - The "precision" of the buckets. The higher the scale, the more buckets will be created
39
- * @param count - The total number of buckets
40
- * @returns - An array of bucket boundaries
41
- */
42
- export function exponentialBuckets(scale, count) {
43
- const buckets = [];
44
- const base = 2 ** (2 ** -scale);
45
- for (let i = 0; i <= count; i++) {
46
- buckets.push(base ** i);
47
- }
48
- return buckets;
49
- }
50
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGlzdG9ncmFtX3V0aWxzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2hpc3RvZ3JhbV91dGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFDSCxNQUFNLFVBQVUsYUFBYSxDQUFDLEtBQWEsRUFBRSxHQUFXLEVBQUUsS0FBYTtJQUNyRSxNQUFNLE9BQU8sR0FBYSxFQUFFLENBQUM7SUFDN0IsTUFBTSxJQUFJLEdBQUcsQ0FBQyxHQUFHLEdBQUcsS0FBSyxDQUFDLEdBQUcsS0FBSyxDQUFDO0lBQ25DLEtBQUssSUFBSSxDQUFDLEdBQUcsQ0FBQyxFQUFFLENBQUMsSUFBSSxLQUFLLEVBQUUsQ0FBQyxFQUFFLEVBQUUsQ0FBQztRQUNoQyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUMsS0FBSyxHQUFHLENBQUMsR0FBRyxJQUFJLENBQUMsQ0FBQyxDQUFDO0lBQzdDLENBQUM7SUFDRCxPQUFPLE9BQU8sQ0FBQztBQUNqQixDQUFDO0FBRUQ7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7R0F5Qkc7QUFDSCxNQUFNLFVBQVUsa0JBQWtCLENBQUMsS0FBYSxFQUFFLEtBQWE7SUFDN0QsTUFBTSxPQUFPLEdBQWEsRUFBRSxDQUFDO0lBQzdCLE1BQU0sSUFBSSxHQUFHLENBQUMsSUFBSSxDQUFDLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxDQUFDO0lBQ2hDLEtBQUssSUFBSSxDQUFDLEdBQUcsQ0FBQyxFQUFFLENBQUMsSUFBSSxLQUFLLEVBQUUsQ0FBQyxFQUFFLEVBQUUsQ0FBQztRQUNoQyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksSUFBSSxDQUFDLENBQUMsQ0FBQztJQUMxQixDQUFDO0lBQ0QsT0FBTyxPQUFPLENBQUM7QUFDakIsQ0FBQyJ9
@@ -1,28 +0,0 @@
1
- import { type DetectorSync, type IResource, Resource } from '@opentelemetry/resources';
2
- import {
3
- ATTR_K8S_NAMESPACE_NAME,
4
- ATTR_K8S_POD_NAME,
5
- ATTR_K8S_POD_UID,
6
- ATTR_SERVICE_INSTANCE_ID,
7
- } from '@opentelemetry/semantic-conventions/incubating';
8
-
9
- import { getConfigEnvVars } from './config.js';
10
-
11
- /**
12
- * Detector for custom Aztec attributes
13
- */
14
- class AztecDetector implements DetectorSync {
15
- detect(): IResource {
16
- const config = getConfigEnvVars();
17
-
18
- return new Resource({
19
- [ATTR_K8S_POD_UID]: config.k8sPodUid,
20
- [ATTR_K8S_POD_NAME]: config.k8sPodName,
21
- // this will get set by serviceInstanceIdDetector if not running in K8s
22
- [ATTR_SERVICE_INSTANCE_ID]: config.k8sPodUid,
23
- [ATTR_K8S_NAMESPACE_NAME]: config.k8sNamespaceName,
24
- });
25
- }
26
- }
27
-
28
- export const aztecDetector = new AztecDetector();
@@ -1,50 +0,0 @@
1
- /**
2
- * Creates a set of buckets that follow linear growth
3
- * @param start - The start of the range
4
- * @param end - The end of the range
5
- * @param count - The number of buckets
6
- * @returns - An array of bucket boundaries
7
- */
8
- export function linearBuckets(start: number, end: number, count: number): number[] {
9
- const buckets: number[] = [];
10
- const step = (end - start) / count;
11
- for (let i = 0; i <= count; i++) {
12
- buckets.push(Math.floor(start + i * step));
13
- }
14
- return buckets;
15
- }
16
-
17
- /**
18
- * Creates an array of exponential buckets that follow the formulas at
19
- * https://opentelemetry.io/docs/specs/otel/metrics/data-model/#exponential-buckets
20
- *
21
- * The formula followed is: bucket[i] = base ** i, where base = 2 ** (2 ** -scale). Naturally base will be very small when scale > 0.
22
- * This ensures that between each power of 2, there are 2 ** scale intermediate buckets.
23
- *
24
- * @example
25
- * scale = 2, count = 8
26
- * base = 2 ** (2 ** -2) = 1.189207115
27
- * |bucket index| value |
28
- * |------------|-------|
29
- * | 0 | 1 |
30
- * | 1 | 1.18 |
31
- * | 2 | 1.41 |
32
- * | 3 | 1.68 |
33
- * | 4 | 2 |
34
- * | 5 | 2.37 |
35
- * | 6 | 2.82 |
36
- * | 7 | 3.36 |
37
- * | 8 | 4 |
38
- *
39
- * @param scale - The "precision" of the buckets. The higher the scale, the more buckets will be created
40
- * @param count - The total number of buckets
41
- * @returns - An array of bucket boundaries
42
- */
43
- export function exponentialBuckets(scale: number, count: number): number[] {
44
- const buckets: number[] = [];
45
- const base = 2 ** (2 ** -scale);
46
- for (let i = 0; i <= count; i++) {
47
- buckets.push(base ** i);
48
- }
49
- return buckets;
50
- }