@mastra/observability 1.2.0 → 1.2.1-alpha.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.
- package/CHANGELOG.md +11 -0
- package/dist/exporters/default.d.ts +6 -0
- package/dist/exporters/default.d.ts.map +1 -1
- package/dist/index.cjs +37 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +37 -11
- package/dist/index.js.map +1 -1
- package/dist/spans/serialization.d.ts +1 -1
- package/dist/spans/serialization.d.ts.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @mastra/observability
|
|
2
2
|
|
|
3
|
+
## 1.2.1-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed telemetry spans being silently dropped when the default exporter was used. The exporter now holds spans in memory until initialization completes, ensuring all spans are propagated to your tracing backend. ([#12936](https://github.com/mastra-ai/mastra/pull/12936))
|
|
8
|
+
|
|
9
|
+
- Fixed `keysToStrip.has is not a function` crash in `deepClean()` when bundlers transform `new Set([...])` into a plain object or array. This affected agents with memory deployed to Mastra Cloud. ([#13322](https://github.com/mastra-ai/mastra/pull/13322))
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`0d9efb4`](https://github.com/mastra-ai/mastra/commit/0d9efb47992c34aa90581c18b9f51f774f6252a5), [`5caa13d`](https://github.com/mastra-ai/mastra/commit/5caa13d1b2a496e2565ab124a11de9a51ad3e3b9), [`940163f`](https://github.com/mastra-ai/mastra/commit/940163fc492401d7562301e6f106ccef4fefe06f), [`b260123`](https://github.com/mastra-ai/mastra/commit/b2601234bd093d358c92081a58f9b0befdae52b3), [`47892c8`](https://github.com/mastra-ai/mastra/commit/47892c85708eac348209f99f10f9a5f5267e11c0), [`45bb78b`](https://github.com/mastra-ai/mastra/commit/45bb78b70bd9db29678fe49476cd9f4ed01bfd0b), [`70eef84`](https://github.com/mastra-ai/mastra/commit/70eef84b8f44493598fdafa2980a0e7283415eda), [`d84e52d`](https://github.com/mastra-ai/mastra/commit/d84e52d0f6511283ddd21ed5fe7f945449d0f799), [`24b80af`](https://github.com/mastra-ai/mastra/commit/24b80af87da93bb84d389340181e17b7477fa9ca), [`608e156`](https://github.com/mastra-ai/mastra/commit/608e156def954c9604c5e3f6d9dfce3bcc7aeab0), [`2b2e157`](https://github.com/mastra-ai/mastra/commit/2b2e157a092cd597d9d3f0000d62b8bb4a7348ed), [`59d30b5`](https://github.com/mastra-ai/mastra/commit/59d30b5d0cb44ea7a1c440e7460dfb57eac9a9b5), [`453693b`](https://github.com/mastra-ai/mastra/commit/453693bf9e265ddccecef901d50da6caaea0fbc6), [`78d1c80`](https://github.com/mastra-ai/mastra/commit/78d1c808ad90201897a300af551bcc1d34458a20), [`c204b63`](https://github.com/mastra-ai/mastra/commit/c204b632d19e66acb6d6e19b11c4540dd6ad5380), [`742a417`](https://github.com/mastra-ai/mastra/commit/742a417896088220a3b5560c354c45c5ca6d88b9)]:
|
|
12
|
+
- @mastra/core@1.6.0-alpha.0
|
|
13
|
+
|
|
3
14
|
## 1.2.0
|
|
4
15
|
|
|
5
16
|
### Minor Changes
|
|
@@ -84,6 +84,12 @@ export declare class DefaultExporter extends BaseExporter {
|
|
|
84
84
|
*/
|
|
85
85
|
private flushWithRetries;
|
|
86
86
|
_exportTracingEvent(event: TracingEvent): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Resolves when an ongoing init call is finished
|
|
89
|
+
* Doesn't wait for the caller to call init
|
|
90
|
+
* @returns
|
|
91
|
+
*/
|
|
92
|
+
private waitForInit;
|
|
87
93
|
/**
|
|
88
94
|
* Force flush any buffered spans without shutting down the exporter.
|
|
89
95
|
* This is useful in serverless environments where you need to ensure spans
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../src/exporters/default.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA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AA0B;IAoC9C;;OAEG;IACG,IAAI,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgCvD;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAe1B;;OAEG;IACH,OAAO,CAAC,YAAY;IAIpB;;OAEG;IACH,OAAO,CAAC,eAAe;IAOvB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAS9B;;OAEG;IACH,OAAO,CAAC,WAAW;IAgFnB;;OAEG;IACH,OAAO,CAAC,WAAW;IAsBnB;;OAEG;IACH,OAAO,CAAC,WAAW;IAiBnB;;OAEG;IACH,OAAO,CAAC,aAAa;IAarB;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAiC3B,OAAO,CAAC,iBAAiB;IAgDzB,OAAO,CAAC,iBAAiB;IAczB;;OAEG;YACW,mBAAmB;IAyCjC;;OAEG;IACH,OAAO,CAAC,2BAA2B;IAgBnC;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAoB7B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAI3B;;OAEG;YACW,WAAW;IAsDzB;;OAEG;YACW,gBAAgB;IA+DxB,mBAAmB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IA0B7D;;;;OAIG;YACW,WAAW;IAOzB;;;;OAIG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAStB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAYhC"}
|
package/dist/index.cjs
CHANGED
|
@@ -5559,6 +5559,8 @@ var DefaultExporter = class extends BaseExporter {
|
|
|
5559
5559
|
#resolvedStrategy;
|
|
5560
5560
|
buffer;
|
|
5561
5561
|
#flushTimer = null;
|
|
5562
|
+
#isInitializing = false;
|
|
5563
|
+
#initPromises = /* @__PURE__ */ new Set();
|
|
5562
5564
|
// Track all spans that have been created, persists across flushes
|
|
5563
5565
|
allCreatedSpans = /* @__PURE__ */ new Set();
|
|
5564
5566
|
constructor(config = {}) {
|
|
@@ -5592,17 +5594,28 @@ var DefaultExporter = class extends BaseExporter {
|
|
|
5592
5594
|
* Initialize the exporter (called after all dependencies are ready)
|
|
5593
5595
|
*/
|
|
5594
5596
|
async init(options) {
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
this
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
this
|
|
5603
|
-
|
|
5597
|
+
try {
|
|
5598
|
+
this.#isInitializing = true;
|
|
5599
|
+
this.#storage = options.mastra?.getStorage();
|
|
5600
|
+
if (!this.#storage) {
|
|
5601
|
+
this.logger.warn("DefaultExporter disabled: Storage not available. Traces will not be persisted.");
|
|
5602
|
+
return;
|
|
5603
|
+
}
|
|
5604
|
+
this.#observability = await this.#storage.getStore("observability");
|
|
5605
|
+
if (!this.#observability) {
|
|
5606
|
+
this.logger.warn(
|
|
5607
|
+
"DefaultExporter disabled: Observability storage not available. Traces will not be persisted."
|
|
5608
|
+
);
|
|
5609
|
+
return;
|
|
5610
|
+
}
|
|
5611
|
+
this.initializeStrategy(this.#observability, this.#storage.constructor.name);
|
|
5612
|
+
} finally {
|
|
5613
|
+
this.#isInitializing = false;
|
|
5614
|
+
this.#initPromises.forEach((resolve) => {
|
|
5615
|
+
resolve();
|
|
5616
|
+
});
|
|
5617
|
+
this.#initPromises.clear();
|
|
5604
5618
|
}
|
|
5605
|
-
this.initializeStrategy(this.#observability, this.#storage.constructor.name);
|
|
5606
5619
|
}
|
|
5607
5620
|
/**
|
|
5608
5621
|
* Initialize the resolved strategy once observability store is available
|
|
@@ -6007,6 +6020,7 @@ var DefaultExporter = class extends BaseExporter {
|
|
|
6007
6020
|
}
|
|
6008
6021
|
}
|
|
6009
6022
|
async _exportTracingEvent(event) {
|
|
6023
|
+
await this.waitForInit();
|
|
6010
6024
|
if (!this.#observability) {
|
|
6011
6025
|
this.logger.debug("Cannot store traces. Observability storage is not initialized");
|
|
6012
6026
|
return;
|
|
@@ -6026,6 +6040,17 @@ var DefaultExporter = class extends BaseExporter {
|
|
|
6026
6040
|
break;
|
|
6027
6041
|
}
|
|
6028
6042
|
}
|
|
6043
|
+
/**
|
|
6044
|
+
* Resolves when an ongoing init call is finished
|
|
6045
|
+
* Doesn't wait for the caller to call init
|
|
6046
|
+
* @returns
|
|
6047
|
+
*/
|
|
6048
|
+
async waitForInit() {
|
|
6049
|
+
if (!this.#isInitializing) return;
|
|
6050
|
+
return new Promise((resolve) => {
|
|
6051
|
+
this.#initPromises.add(resolve);
|
|
6052
|
+
});
|
|
6053
|
+
}
|
|
6029
6054
|
/**
|
|
6030
6055
|
* Force flush any buffered spans without shutting down the exporter.
|
|
6031
6056
|
* This is useful in serverless environments where you need to ensure spans
|
|
@@ -7454,6 +7479,7 @@ function compressJsonSchema(schema, depth = 0) {
|
|
|
7454
7479
|
}
|
|
7455
7480
|
function deepClean(value, options = DEFAULT_DEEP_CLEAN_OPTIONS) {
|
|
7456
7481
|
const { keysToStrip, maxDepth, maxStringLength, maxArrayLength, maxObjectKeys } = options;
|
|
7482
|
+
const stripSet = keysToStrip instanceof Set ? keysToStrip : new Set(Array.isArray(keysToStrip) ? keysToStrip : Object.keys(keysToStrip));
|
|
7457
7483
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
7458
7484
|
function helper(val, depth) {
|
|
7459
7485
|
if (depth > maxDepth) {
|
|
@@ -7524,7 +7550,7 @@ function deepClean(value, options = DEFAULT_DEEP_CLEAN_OPTIONS) {
|
|
|
7524
7550
|
const entries = Object.entries(val);
|
|
7525
7551
|
let keyCount = 0;
|
|
7526
7552
|
for (const [key, v] of entries) {
|
|
7527
|
-
if (
|
|
7553
|
+
if (stripSet.has(key)) {
|
|
7528
7554
|
continue;
|
|
7529
7555
|
}
|
|
7530
7556
|
if (keyCount >= maxObjectKeys) {
|