@superblocksteam/telemetry 2.0.161 → 2.0.162-next.0

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.
@@ -5,4 +5,5 @@
5
5
  */
6
6
  export { InMemorySpanExporter, InMemoryMetricExporter, InMemoryLogExporter, type CapturedMetric, type CapturedLogRecord, } from "./in-memory-exporter.js";
7
7
  export { initTestTelemetry, getTestTelemetryInstance, resetTestTelemetry, getTestTracer, withTestSpan, type TestTelemetryInstance, } from "./test-init.js";
8
+ export { captureMetrics, type CapturedPoint, type MetricsCapture, } from "./metrics-capture.js";
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,KAAK,cAAc,EACnB,KAAK,iBAAiB,GACvB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,kBAAkB,EAClB,aAAa,EACb,YAAY,EACZ,KAAK,qBAAqB,GAC3B,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,KAAK,cAAc,EACnB,KAAK,iBAAiB,GACvB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,kBAAkB,EAClB,aAAa,EACb,YAAY,EACZ,KAAK,qBAAqB,GAC3B,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,cAAc,EACd,KAAK,aAAa,EAClB,KAAK,cAAc,GACpB,MAAM,sBAAsB,CAAC"}
@@ -5,7 +5,7 @@
5
5
  * In-memory exporters and test helpers for telemetry assertions.
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.withTestSpan = exports.getTestTracer = exports.resetTestTelemetry = exports.getTestTelemetryInstance = exports.initTestTelemetry = exports.InMemoryLogExporter = exports.InMemoryMetricExporter = exports.InMemorySpanExporter = void 0;
8
+ exports.captureMetrics = exports.withTestSpan = exports.getTestTracer = exports.resetTestTelemetry = exports.getTestTelemetryInstance = exports.initTestTelemetry = exports.InMemoryLogExporter = exports.InMemoryMetricExporter = exports.InMemorySpanExporter = void 0;
9
9
  var in_memory_exporter_js_1 = require("./in-memory-exporter.js");
10
10
  Object.defineProperty(exports, "InMemorySpanExporter", { enumerable: true, get: function () { return in_memory_exporter_js_1.InMemorySpanExporter; } });
11
11
  Object.defineProperty(exports, "InMemoryMetricExporter", { enumerable: true, get: function () { return in_memory_exporter_js_1.InMemoryMetricExporter; } });
@@ -16,4 +16,6 @@ Object.defineProperty(exports, "getTestTelemetryInstance", { enumerable: true, g
16
16
  Object.defineProperty(exports, "resetTestTelemetry", { enumerable: true, get: function () { return test_init_js_1.resetTestTelemetry; } });
17
17
  Object.defineProperty(exports, "getTestTracer", { enumerable: true, get: function () { return test_init_js_1.getTestTracer; } });
18
18
  Object.defineProperty(exports, "withTestSpan", { enumerable: true, get: function () { return test_init_js_1.withTestSpan; } });
19
+ var metrics_capture_js_1 = require("./metrics-capture.js");
20
+ Object.defineProperty(exports, "captureMetrics", { enumerable: true, get: function () { return metrics_capture_js_1.captureMetrics; } });
19
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,iEAMiC;AAL/B,6HAAA,oBAAoB,OAAA;AACpB,+HAAA,sBAAsB,OAAA;AACtB,4HAAA,mBAAmB,OAAA;AAKrB,+CAOwB;AANtB,iHAAA,iBAAiB,OAAA;AACjB,wHAAA,wBAAwB,OAAA;AACxB,kHAAA,kBAAkB,OAAA;AAClB,6GAAA,aAAa,OAAA;AACb,4GAAA,YAAY,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,iEAMiC;AAL/B,6HAAA,oBAAoB,OAAA;AACpB,+HAAA,sBAAsB,OAAA;AACtB,4HAAA,mBAAmB,OAAA;AAKrB,+CAOwB;AANtB,iHAAA,iBAAiB,OAAA;AACjB,wHAAA,wBAAwB,OAAA;AACxB,kHAAA,kBAAkB,OAAA;AAClB,6GAAA,aAAa,OAAA;AACb,4GAAA,YAAY,OAAA;AAId,2DAI8B;AAH5B,oHAAA,cAAc,OAAA"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * In-memory metric capture for tests.
3
+ *
4
+ * `initTestTelemetry` registers only a tracer provider, so instruments have
5
+ * nowhere to record and its `metricExporter` always reads back empty. This
6
+ * installs a real SDK MeterProvider as the global and flattens what it
7
+ * collects into (name, attributes, value) triples.
8
+ *
9
+ * Installing a provider also re-binds instruments written against the lazy
10
+ * pattern, so a module imported before the harness ran still records.
11
+ */
12
+ export interface CapturedPoint {
13
+ attributes: Record<string, unknown>;
14
+ /** Histogram data points only. */
15
+ count?: number;
16
+ /** Histogram data points only. */
17
+ sum?: number;
18
+ /** Counter and gauge data points only. */
19
+ value?: number;
20
+ }
21
+ export interface MetricsCapture {
22
+ /** Every data point recorded since the last read. */
23
+ collect: () => Promise<CapturedPoint[]>;
24
+ /** Data points for one metric name, recorded since the last read. */
25
+ pointsFor: (metricName: string) => Promise<CapturedPoint[]>;
26
+ shutdown: () => Promise<void>;
27
+ }
28
+ export declare function captureMetrics(): MetricsCapture;
29
+ //# sourceMappingURL=metrics-capture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics-capture.d.ts","sourceRoot":"","sources":["../../src/testing/metrics-capture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAWH,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,kCAAkC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,qDAAqD;IACrD,OAAO,EAAE,MAAM,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IACxC,qEAAqE;IACrE,SAAS,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IAC5D,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/B;AAED,wBAAgB,cAAc,IAAI,cAAc,CA+D/C"}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ /**
3
+ * In-memory metric capture for tests.
4
+ *
5
+ * `initTestTelemetry` registers only a tracer provider, so instruments have
6
+ * nowhere to record and its `metricExporter` always reads back empty. This
7
+ * installs a real SDK MeterProvider as the global and flattens what it
8
+ * collects into (name, attributes, value) triples.
9
+ *
10
+ * Installing a provider also re-binds instruments written against the lazy
11
+ * pattern, so a module imported before the harness ran still records.
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.captureMetrics = captureMetrics;
15
+ const api_1 = require("@opentelemetry/api");
16
+ const sdk_metrics_1 = require("@opentelemetry/sdk-metrics");
17
+ function captureMetrics() {
18
+ const exporter = new sdk_metrics_1.InMemoryMetricExporter(sdk_metrics_1.AggregationTemporality.DELTA);
19
+ const reader = new sdk_metrics_1.PeriodicExportingMetricReader({
20
+ exporter,
21
+ exportIntervalMillis: 60_000,
22
+ });
23
+ const provider = new sdk_metrics_1.MeterProvider({ readers: [reader] });
24
+ api_1.metrics.disable();
25
+ api_1.metrics.setGlobalMeterProvider(provider);
26
+ const collectNamed = async () => {
27
+ await provider.forceFlush();
28
+ const collected = [];
29
+ for (const resourceMetric of exporter.getMetrics()) {
30
+ for (const scopeMetric of resourceMetric.scopeMetrics) {
31
+ for (const metric of scopeMetric.metrics) {
32
+ const name = metric.descriptor.name;
33
+ // Narrow on the metric, not the point: `dataPoints` is only typed
34
+ // once `dataPointType` has been checked.
35
+ if (metric.dataPointType === sdk_metrics_1.DataPointType.HISTOGRAM) {
36
+ for (const point of metric.dataPoints) {
37
+ collected.push({
38
+ attributes: point.attributes,
39
+ count: point.value.count,
40
+ name,
41
+ ...(point.value.sum === undefined
42
+ ? {}
43
+ : { sum: point.value.sum }),
44
+ });
45
+ }
46
+ }
47
+ else if (metric.dataPointType === sdk_metrics_1.DataPointType.SUM ||
48
+ metric.dataPointType === sdk_metrics_1.DataPointType.GAUGE) {
49
+ for (const point of metric.dataPoints) {
50
+ collected.push({
51
+ attributes: point.attributes,
52
+ name,
53
+ value: point.value,
54
+ });
55
+ }
56
+ }
57
+ }
58
+ }
59
+ }
60
+ exporter.reset();
61
+ return collected;
62
+ };
63
+ return {
64
+ collect: async () => (await collectNamed()).map(({ name: _name, ...point }) => point),
65
+ pointsFor: async (metricName) => (await collectNamed())
66
+ .filter((point) => point.name === metricName)
67
+ .map(({ name: _name, ...point }) => point),
68
+ shutdown: async () => {
69
+ await provider.shutdown();
70
+ api_1.metrics.disable();
71
+ },
72
+ };
73
+ }
74
+ //# sourceMappingURL=metrics-capture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics-capture.js","sourceRoot":"","sources":["../../src/testing/metrics-capture.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;AA6BH,wCA+DC;AA1FD,4CAA6C;AAC7C,4DAMoC;AAoBpC,SAAgB,cAAc;IAC5B,MAAM,QAAQ,GAAG,IAAI,oCAAsB,CAAC,oCAAsB,CAAC,KAAK,CAAC,CAAC;IAC1E,MAAM,MAAM,GAAG,IAAI,2CAA6B,CAAC;QAC/C,QAAQ;QACR,oBAAoB,EAAE,MAAM;KAC7B,CA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CAAC,UAAU,EAAE,CAAC;4BACtC,SAAS,CAAC,IAAI,CAAC;gCACb,UAAU,EAAE,KAAK,CAAC,UAAU;gCAC5B,IAAI;gCACJ,KAAK,EAAE,KAAK,CAAC,KAAK;6BACnB,CAAC,CAAC;wBACL,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QACD,QAAQ,CAAC,KAAK,EAAE,CAAC;QACjB,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IAEF,OAAO;QACL,OAAO,EAAE,KAAK,IAAI,EAAE,CAClB,CAAC,MAAM,YAAY,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC;QAClE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,CAC9B,CAAC,MAAM,YAAY,EAAE,CAAC;aACnB,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,UAAU,CAAC;aAC5C,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC;QAC9C,QAAQ,EAAE,KAAK,IAAI,EAAE;YACnB,MAAM,QAAQ,CAAC,QAAQ,EAAE,CAAC;YAC1B,aAAO,CAAC,OAAO,EAAE,CAAC;QACpB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -5,4 +5,5 @@
5
5
  */
6
6
  export { InMemorySpanExporter, InMemoryMetricExporter, InMemoryLogExporter, type CapturedMetric, type CapturedLogRecord, } from "./in-memory-exporter.js";
7
7
  export { initTestTelemetry, getTestTelemetryInstance, resetTestTelemetry, getTestTracer, withTestSpan, type TestTelemetryInstance, } from "./test-init.js";
8
+ export { captureMetrics, type CapturedPoint, type MetricsCapture, } from "./metrics-capture.js";
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,KAAK,cAAc,EACnB,KAAK,iBAAiB,GACvB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,kBAAkB,EAClB,aAAa,EACb,YAAY,EACZ,KAAK,qBAAqB,GAC3B,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,KAAK,cAAc,EACnB,KAAK,iBAAiB,GACvB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,kBAAkB,EAClB,aAAa,EACb,YAAY,EACZ,KAAK,qBAAqB,GAC3B,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,cAAc,EACd,KAAK,aAAa,EAClB,KAAK,cAAc,GACpB,MAAM,sBAAsB,CAAC"}
@@ -5,4 +5,5 @@
5
5
  */
6
6
  export { InMemorySpanExporter, InMemoryMetricExporter, InMemoryLogExporter, } from "./in-memory-exporter.js";
7
7
  export { initTestTelemetry, getTestTelemetryInstance, resetTestTelemetry, getTestTracer, withTestSpan, } from "./test-init.js";
8
+ export { captureMetrics, } from "./metrics-capture.js";
8
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,GAGpB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,kBAAkB,EAClB,aAAa,EACb,YAAY,GAEb,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,GAGpB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,kBAAkB,EAClB,aAAa,EACb,YAAY,GAEb,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,cAAc,GAGf,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * In-memory metric capture for tests.
3
+ *
4
+ * `initTestTelemetry` registers only a tracer provider, so instruments have
5
+ * nowhere to record and its `metricExporter` always reads back empty. This
6
+ * installs a real SDK MeterProvider as the global and flattens what it
7
+ * collects into (name, attributes, value) triples.
8
+ *
9
+ * Installing a provider also re-binds instruments written against the lazy
10
+ * pattern, so a module imported before the harness ran still records.
11
+ */
12
+ export interface CapturedPoint {
13
+ attributes: Record<string, unknown>;
14
+ /** Histogram data points only. */
15
+ count?: number;
16
+ /** Histogram data points only. */
17
+ sum?: number;
18
+ /** Counter and gauge data points only. */
19
+ value?: number;
20
+ }
21
+ export interface MetricsCapture {
22
+ /** Every data point recorded since the last read. */
23
+ collect: () => Promise<CapturedPoint[]>;
24
+ /** Data points for one metric name, recorded since the last read. */
25
+ pointsFor: (metricName: string) => Promise<CapturedPoint[]>;
26
+ shutdown: () => Promise<void>;
27
+ }
28
+ export declare function captureMetrics(): MetricsCapture;
29
+ //# sourceMappingURL=metrics-capture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics-capture.d.ts","sourceRoot":"","sources":["../../src/testing/metrics-capture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAWH,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,kCAAkC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,qDAAqD;IACrD,OAAO,EAAE,MAAM,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IACxC,qEAAqE;IACrE,SAAS,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IAC5D,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/B;AAED,wBAAgB,cAAc,IAAI,cAAc,CA+D/C"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * In-memory metric capture for tests.
3
+ *
4
+ * `initTestTelemetry` registers only a tracer provider, so instruments have
5
+ * nowhere to record and its `metricExporter` always reads back empty. This
6
+ * installs a real SDK MeterProvider as the global and flattens what it
7
+ * collects into (name, attributes, value) triples.
8
+ *
9
+ * Installing a provider also re-binds instruments written against the lazy
10
+ * pattern, so a module imported before the harness ran still records.
11
+ */
12
+ import { metrics } from "@opentelemetry/api";
13
+ import { AggregationTemporality, DataPointType, InMemoryMetricExporter, MeterProvider, PeriodicExportingMetricReader, } from "@opentelemetry/sdk-metrics";
14
+ export function captureMetrics() {
15
+ const exporter = new InMemoryMetricExporter(AggregationTemporality.DELTA);
16
+ const reader = new PeriodicExportingMetricReader({
17
+ exporter,
18
+ exportIntervalMillis: 60_000,
19
+ });
20
+ const provider = new MeterProvider({ readers: [reader] });
21
+ metrics.disable();
22
+ metrics.setGlobalMeterProvider(provider);
23
+ const collectNamed = async () => {
24
+ await provider.forceFlush();
25
+ const collected = [];
26
+ for (const resourceMetric of exporter.getMetrics()) {
27
+ for (const scopeMetric of resourceMetric.scopeMetrics) {
28
+ for (const metric of scopeMetric.metrics) {
29
+ const name = metric.descriptor.name;
30
+ // Narrow on the metric, not the point: `dataPoints` is only typed
31
+ // once `dataPointType` has been checked.
32
+ if (metric.dataPointType === DataPointType.HISTOGRAM) {
33
+ for (const point of metric.dataPoints) {
34
+ collected.push({
35
+ attributes: point.attributes,
36
+ count: point.value.count,
37
+ name,
38
+ ...(point.value.sum === undefined
39
+ ? {}
40
+ : { sum: point.value.sum }),
41
+ });
42
+ }
43
+ }
44
+ else if (metric.dataPointType === DataPointType.SUM ||
45
+ metric.dataPointType === DataPointType.GAUGE) {
46
+ for (const point of metric.dataPoints) {
47
+ collected.push({
48
+ attributes: point.attributes,
49
+ name,
50
+ value: point.value,
51
+ });
52
+ }
53
+ }
54
+ }
55
+ }
56
+ }
57
+ exporter.reset();
58
+ return collected;
59
+ };
60
+ return {
61
+ collect: async () => (await collectNamed()).map(({ name: _name, ...point }) => point),
62
+ pointsFor: async (metricName) => (await collectNamed())
63
+ .filter((point) => point.name === metricName)
64
+ .map(({ name: _name, ...point }) => point),
65
+ shutdown: async () => {
66
+ await provider.shutdown();
67
+ metrics.disable();
68
+ },
69
+ };
70
+ }
71
+ //# sourceMappingURL=metrics-capture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics-capture.js","sourceRoot":"","sources":["../../src/testing/metrics-capture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EACL,sBAAsB,EACtB,aAAa,EACb,sBAAsB,EACtB,aAAa,EACb,6BAA6B,GAC9B,MAAM,4BAA4B,CAAC;AAoBpC,MAAM,UAAU,cAAc;IAC5B,MAAM,QAAQ,GAAG,IAAI,sBAAsB,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;IAC1E,MAAM,MAAM,GAAG,IAAI,6BAA6B,CAAC;QAC/C,QAAQ;QACR,oBAAoB,EAAE,MAAM;KAC7B,CAAC,CAAC;IACH,MAAM,QAAQ,GAAG,IAAI,aAAa,CAAC,EAAE,OAAO,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC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I;gCACJ,KAAK,EAAE,KAAK,CAAC,KAAK;6BACnB,CAAC,CAAC;wBACL,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QACD,QAAQ,CAAC,KAAK,EAAE,CAAC;QACjB,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IAEF,OAAO;QACL,OAAO,EAAE,KAAK,IAAI,EAAE,CAClB,CAAC,MAAM,YAAY,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC;QAClE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,CAC9B,CAAC,MAAM,YAAY,EAAE,CAAC;aACnB,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,UAAU,CAAC;aAC5C,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC;QAC9C,QAAQ,EAAE,KAAK,IAAI,EAAE;YACnB,MAAM,QAAQ,CAAC,QAAQ,EAAE,CAAC;YAC1B,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,CAAC;KACF,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superblocksteam/telemetry",
3
- "version": "2.0.161",
3
+ "version": "2.0.162-next.0",
4
4
  "description": "Superblocks Telemetry - Canonical OTEL bootstrap with tier-aware policy enforcement",
5
5
  "license": "Superblocks Community Software License",
6
6
  "repository": {
@@ -68,7 +68,7 @@
68
68
  },
69
69
  "devDependencies": {
70
70
  "@eslint/js": "^9.39.1",
71
- "@superblocksteam/shared": "0.9611.2",
71
+ "@superblocksteam/shared": "0.9613.0",
72
72
  "@types/node": "^24",
73
73
  "chokidar-cli": "^3.0.0",
74
74
  "eslint": "^9.39.1",
@@ -81,7 +81,7 @@
81
81
  "vitest": "^2.0.0"
82
82
  },
83
83
  "peerDependencies": {
84
- "@superblocksteam/shared": "0.9611.2"
84
+ "@superblocksteam/shared": "0.9613.0"
85
85
  },
86
86
  "engines": {
87
87
  "node": ">=24"