@mastra/observability 1.17.1-alpha.2 → 1.17.2-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 +32 -0
- package/dist/exporters/mastra-storage.d.ts +3 -6
- package/dist/exporters/mastra-storage.d.ts.map +1 -1
- package/dist/index.cjs +55 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +55 -51
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @mastra/observability
|
|
2
2
|
|
|
3
|
+
## 1.17.2-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed `MastraStorageExporter` staying disabled when a configured observability store is temporarily unavailable during startup. The exporter now recovers on a later event, so traces resume without restarting the process. (#21943) ([#21957](https://github.com/mastra-ai/mastra/pull/21957))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`f95f468`](https://github.com/mastra-ai/mastra/commit/f95f468cf1e7c2b924a13826494f98b8f2ccd581)]:
|
|
10
|
+
- @mastra/core@1.61.1-alpha.1
|
|
11
|
+
|
|
12
|
+
## 1.17.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Fixed the `__truncated` marker on span data. It now counts only the fields dropped by the object-key limit, so traces no longer report more omitted keys than were really dropped. Values beyond the limit are no longer read. ([#21630](https://github.com/mastra-ai/mastra/pull/21630))
|
|
17
|
+
|
|
18
|
+
- Fixed span serialization so internal tracing fields are removed only from framework-owned payloads while preserving user data with the same key names. ([#21332](https://github.com/mastra-ai/mastra/pull/21332))
|
|
19
|
+
|
|
20
|
+
- Advertise quota-pause support to the Mastra platform. `MastraPlatformExporter` now sends `x-mastra-observability-capabilities: quota-pause-v1` on every request (batch uploads for all five signal types, plus the traces recovery probe), letting the platform respond with `402 Payment Required` to clients that understand the quota-pause contract while shielding legacy clients from retry loops. No configuration change is required: ([#21447](https://github.com/mastra-ai/mastra/pull/21447))
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { MastraPlatformExporter } from '@mastra/observability';
|
|
24
|
+
|
|
25
|
+
const exporter = new MastraPlatformExporter({
|
|
26
|
+
accessToken: process.env.MASTRA_PLATFORM_ACCESS_TOKEN,
|
|
27
|
+
});
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
- Fixed Anthropic cache-write cost estimates by applying TTL-specific rates without double counting aggregate tokens. ([#21563](https://github.com/mastra-ai/mastra/pull/21563))
|
|
31
|
+
|
|
32
|
+
- Updated dependencies [[`587f6ef`](https://github.com/mastra-ai/mastra/commit/587f6efcfc25880b93760a8607d1cd381ec612fe), [`7e096f0`](https://github.com/mastra-ai/mastra/commit/7e096f02f0dddbf09b85d306458351245ed2f886), [`d7e6745`](https://github.com/mastra-ai/mastra/commit/d7e67456954863c55440ea9c49bc6ceb9949972d), [`6223446`](https://github.com/mastra-ai/mastra/commit/6223446ddce6166e96e0ba5e00d628b615dee8ca), [`15101bb`](https://github.com/mastra-ai/mastra/commit/15101bb53c0d934f31af6b8813b88191e382a5e5), [`4e7a421`](https://github.com/mastra-ai/mastra/commit/4e7a421dce8a48742f785d1e93ad2f43a572b282), [`c2c3deb`](https://github.com/mastra-ai/mastra/commit/c2c3debcf670c7082d0a5e553aa99818a864698c), [`d8308a2`](https://github.com/mastra-ai/mastra/commit/d8308a2be3c07e777393d1017a381dcae3890d30), [`b0a2a07`](https://github.com/mastra-ai/mastra/commit/b0a2a07800d42bd9823292e7db832374ed084c9c), [`74e5bd3`](https://github.com/mastra-ai/mastra/commit/74e5bd315b8b3a1e04cb6cf480bb0f5fc4951dc8), [`242e324`](https://github.com/mastra-ai/mastra/commit/242e3241e73cbd5c9bb86a31ebb49ca0256488d4), [`217e967`](https://github.com/mastra-ai/mastra/commit/217e9672d8b3160eb729d8e9f0044949e88da239), [`d774e89`](https://github.com/mastra-ai/mastra/commit/d774e8930c781df8c9effe3763e6b501c099b6cc), [`9c27a53`](https://github.com/mastra-ai/mastra/commit/9c27a53cd9d3de4f3f025bc387d94ce371c33f95), [`8f0a332`](https://github.com/mastra-ai/mastra/commit/8f0a3321bf180368d76fe7b36aa1a8f60f00b6de), [`0b4f108`](https://github.com/mastra-ai/mastra/commit/0b4f1089aa8d92e67c2a8e99726822c5ee410784), [`9acb50f`](https://github.com/mastra-ai/mastra/commit/9acb50f71cec9c362f06820033f90ae6b1f8282f), [`46e9e3f`](https://github.com/mastra-ai/mastra/commit/46e9e3f73babe1bc70080a596cf2ac0b9da48519), [`3f9a190`](https://github.com/mastra-ai/mastra/commit/3f9a19057c027155867b9317294ee4ca7bd0581a), [`dff25a1`](https://github.com/mastra-ai/mastra/commit/dff25a1103fa72ee082a9b6f805ebeb5ce400753), [`6db7a5d`](https://github.com/mastra-ai/mastra/commit/6db7a5dd3dd2b6f7ef75dcd804fcffef5fa83963), [`217e967`](https://github.com/mastra-ai/mastra/commit/217e9672d8b3160eb729d8e9f0044949e88da239), [`583e235`](https://github.com/mastra-ai/mastra/commit/583e23519c13af16c1746f9c49722d011216611b), [`b098de9`](https://github.com/mastra-ai/mastra/commit/b098de9d7cb9f672e0883a5c716465a3a689693d), [`e8808e3`](https://github.com/mastra-ai/mastra/commit/e8808e3d8eb585a2565be53e56a7e0e1477352a4), [`a77f8d4`](https://github.com/mastra-ai/mastra/commit/a77f8d4740d2178a74c41e4bf678b4fcd8fa0bb2), [`7f78585`](https://github.com/mastra-ai/mastra/commit/7f785857e401570e2ffb316911f126ed363aa537), [`33374ba`](https://github.com/mastra-ai/mastra/commit/33374ba359e4fb13eaa918ae925fe167a3c55414), [`940bf5c`](https://github.com/mastra-ai/mastra/commit/940bf5ccf04f2c9ebd8a1390431733222a03b1cd), [`c549e2f`](https://github.com/mastra-ai/mastra/commit/c549e2f40edc1cac5d9e74e82f90da22b48df084), [`58c43d3`](https://github.com/mastra-ai/mastra/commit/58c43d3f7cb2eeaeb8ac733ae71dde822348e588), [`ef6e295`](https://github.com/mastra-ai/mastra/commit/ef6e295b59bc25a5b61b633a89c97bcfce9fb465), [`208e1b3`](https://github.com/mastra-ai/mastra/commit/208e1b39f30f4b386e494394e9d71d96f0f90241), [`c938d34`](https://github.com/mastra-ai/mastra/commit/c938d34739936c8ecbabd67ad6a4a4396f41c4c6), [`88ddc7c`](https://github.com/mastra-ai/mastra/commit/88ddc7ce01d40175f13a3228b789a906779680bd), [`f2a4afd`](https://github.com/mastra-ai/mastra/commit/f2a4afd7e37e809669001ed17724b341a5c1f45e), [`d438148`](https://github.com/mastra-ai/mastra/commit/d438148e222c1e2fb3c652725ce75680962ebec4), [`ba05fe0`](https://github.com/mastra-ai/mastra/commit/ba05fe0738f70cb686777546e968237d09269142), [`40d358e`](https://github.com/mastra-ai/mastra/commit/40d358e29d55543803e64b49241122f598ffabc7), [`d26a8d4`](https://github.com/mastra-ai/mastra/commit/d26a8d4281f28414715b333c85bedaf70d0b2890), [`e80cd7e`](https://github.com/mastra-ai/mastra/commit/e80cd7e7683e7d732e1cc6784bcac1d2640d2ce3), [`ccbbcd9`](https://github.com/mastra-ai/mastra/commit/ccbbcd974eedff4367a54ed0e24c9ee742ab2f61), [`1d9a0ea`](https://github.com/mastra-ai/mastra/commit/1d9a0ea4a9901baee6cd56737243bd6d1f631ac0), [`677cdc6`](https://github.com/mastra-ai/mastra/commit/677cdc6af564dec29a13464d12b7ab2a4efc22e9), [`c549e2f`](https://github.com/mastra-ai/mastra/commit/c549e2f40edc1cac5d9e74e82f90da22b48df084), [`a7dd322`](https://github.com/mastra-ai/mastra/commit/a7dd32247d95afc539f483ca37f4594af0387f59), [`3f5c6f7`](https://github.com/mastra-ai/mastra/commit/3f5c6f728ea35da344248de9aa070f12849f3aa0), [`a318490`](https://github.com/mastra-ai/mastra/commit/a318490e17da32f338d50929c770d901a9b3dd72), [`b860493`](https://github.com/mastra-ai/mastra/commit/b86049391100e665d579f700c8a2034c036defc3), [`d4be8c1`](https://github.com/mastra-ai/mastra/commit/d4be8c1739d22d621e3f78790e1dd5eb5ecc3589), [`a5d2eb1`](https://github.com/mastra-ai/mastra/commit/a5d2eb10347eade1ae2816d88f466c25186c54a5), [`3667679`](https://github.com/mastra-ai/mastra/commit/3667679db057edfb086846d13369fdda4902ad65), [`49696e8`](https://github.com/mastra-ai/mastra/commit/49696e8e42f870674a0a58f5abcd22cc54dd2864), [`2ef2f23`](https://github.com/mastra-ai/mastra/commit/2ef2f230a7aed342e7dc3b2000cd42e4c43e08a7), [`763e0c6`](https://github.com/mastra-ai/mastra/commit/763e0c61e04d76ad9a9efd301aa57525ca0cbea9), [`20504b2`](https://github.com/mastra-ai/mastra/commit/20504b2ecebd0e077acda3d457ab57480a98ed3e), [`77e6b1b`](https://github.com/mastra-ai/mastra/commit/77e6b1bc4c46ce94fe501023fb4393c812ec6be3), [`c5f964d`](https://github.com/mastra-ai/mastra/commit/c5f964d3f77064e978f8066ec506eed77ba5c63c), [`23e0be2`](https://github.com/mastra-ai/mastra/commit/23e0be261381e49534b4ff3101c60ee64a946cbf), [`7fc8806`](https://github.com/mastra-ai/mastra/commit/7fc880627d3cbf995d31ea0e8b807bf15417e651), [`0e02eac`](https://github.com/mastra-ai/mastra/commit/0e02eacdb2e30e1697a41910b41163742a181dc1), [`4df174c`](https://github.com/mastra-ai/mastra/commit/4df174c32bddf093a82f273070b8380aef7c9e90), [`f7c25b5`](https://github.com/mastra-ai/mastra/commit/f7c25b5106ddfb48e591f98df7a51e0f2dd01dba), [`7aad631`](https://github.com/mastra-ai/mastra/commit/7aad631b43bc10db77d5b8c66b200d7a49d18bf2), [`512100a`](https://github.com/mastra-ai/mastra/commit/512100a7d8b7e9c920f2590c6b3612f5de0d3cff), [`e81744c`](https://github.com/mastra-ai/mastra/commit/e81744cd13c46619c142dc521dc0baac47607a84), [`f8f653f`](https://github.com/mastra-ai/mastra/commit/f8f653f10980d01a73706cc3c8689ca5e40ce808), [`dc09cc1`](https://github.com/mastra-ai/mastra/commit/dc09cc1083d861cde192c1cd235324dc75b8c731), [`9ef432b`](https://github.com/mastra-ai/mastra/commit/9ef432b6faa534b57b0d182a610e13dd9a7123ff), [`36b4649`](https://github.com/mastra-ai/mastra/commit/36b4649045a3a380cbab8ceca866db4086223aff), [`b9cf308`](https://github.com/mastra-ai/mastra/commit/b9cf30846f97f99ac1906ee8a68f4f2d117b0378), [`2e1d098`](https://github.com/mastra-ai/mastra/commit/2e1d0984e325fd319d32ea182f596b3170be3847), [`377eb81`](https://github.com/mastra-ai/mastra/commit/377eb81ce43b964e3a6b541df172da74a8ff3716), [`1794a79`](https://github.com/mastra-ai/mastra/commit/1794a79178c418004a7261b1ad9114066f7ef01d), [`0cdc5dc`](https://github.com/mastra-ai/mastra/commit/0cdc5dc69024957815da4f51acc4119eb4f447d7), [`5740ec6`](https://github.com/mastra-ai/mastra/commit/5740ec60c760ffdfbfaa59d603d03b847c864e05)]:
|
|
33
|
+
- @mastra/core@1.60.0
|
|
34
|
+
|
|
3
35
|
## 1.17.1-alpha.2
|
|
4
36
|
|
|
5
37
|
### Patch Changes
|
|
@@ -23,6 +23,9 @@ export declare class MastraStorageExporter extends BaseExporter {
|
|
|
23
23
|
* Initialize the exporter (called after all dependencies are ready)
|
|
24
24
|
*/
|
|
25
25
|
init(options: InitExporterOptions): Promise<void>;
|
|
26
|
+
private warnUnavailable;
|
|
27
|
+
private initializeStorage;
|
|
28
|
+
private ensureInitialized;
|
|
26
29
|
/**
|
|
27
30
|
* Checks if buffer should be flushed based on size or time triggers
|
|
28
31
|
*/
|
|
@@ -63,12 +66,6 @@ export declare class MastraStorageExporter extends BaseExporter {
|
|
|
63
66
|
*/
|
|
64
67
|
private flushBuffer;
|
|
65
68
|
_exportTracingEvent(event: TracingEvent): Promise<void>;
|
|
66
|
-
/**
|
|
67
|
-
* Resolves when an ongoing init call is finished
|
|
68
|
-
* Doesn't wait for the caller to call init
|
|
69
|
-
* @returns
|
|
70
|
-
*/
|
|
71
|
-
private waitForInit;
|
|
72
69
|
/**
|
|
73
70
|
* Handle metric events — buffer for batch flush.
|
|
74
71
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mastra-storage.d.ts","sourceRoot":"","sources":["../../src/exporters/mastra-storage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,WAAW,EACX,QAAQ,EACR,UAAU,EACV,aAAa,EAId,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAwB,sBAAsB,EAAwB,MAAM,sBAAsB,CAAC;AAS/G,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAItC,4FAA4F;AAC5F,MAAM,WAAW,2BAA4B,SAAQ,kBAAkB;IACrE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IAGtB,QAAQ,CAAC,EAAE,sBAAsB,GAAG,MAAM,CAAC;CAC5C;
|
|
1
|
+
{"version":3,"file":"mastra-storage.d.ts","sourceRoot":"","sources":["../../src/exporters/mastra-storage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,WAAW,EACX,QAAQ,EACR,UAAU,EACV,aAAa,EAId,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAwB,sBAAsB,EAAwB,MAAM,sBAAsB,CAAC;AAS/G,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAItC,4FAA4F;AAC5F,MAAM,WAAW,2BAA4B,SAAQ,kBAAkB;IACrE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IAGtB,QAAQ,CAAC,EAAE,sBAAsB,GAAG,MAAM,CAAC;CAC5C;AAkCD;;;GAGG;AACH,qBAAa,qBAAsB,SAAQ,YAAY;;IACrD,IAAI,SAA6B;gBAgBrB,MAAM,GAAE,2BAAgC;IAiBpD;;OAEG;IACG,IAAI,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAUvD,OAAO,CAAC,eAAe;YAUT,iBAAiB;YA6CjB,iBAAiB;IAS/B;;OAEG;IACH,OAAO,CAAC,WAAW;IAyBnB;;OAEG;IACH,OAAO,CAAC,aAAa;IAcrB,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,iBAAiB;IAiBzB;;;;OAIG;YACW,kBAAkB;IAQhC,OAAO,CAAC,iBAAiB;IAgBzB,OAAO,CAAC,QAAQ;IAsBhB;;;;OAIG;YACW,YAAY;IAkC1B;;;OAGG;YACW,gBAAgB;IA+D9B;;;;;;;OAOG;YACW,WAAW;IA+HnB,mBAAmB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAW7D;;OAEG;IACG,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAQtD;;OAEG;IACG,UAAU,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAQhD;;OAEG;IACG,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAQpD;;OAEG;IACG,eAAe,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ1D;;;;OAIG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAStB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAiBhC"}
|
package/dist/index.cjs
CHANGED
|
@@ -7123,8 +7123,8 @@ const FLUSH_SUCCEEDED = { failed: false };
|
|
|
7123
7123
|
var MastraStorageExporter = class extends BaseExporter {
|
|
7124
7124
|
name = "mastra-storage-exporter";
|
|
7125
7125
|
#config;
|
|
7126
|
-
#
|
|
7127
|
-
#
|
|
7126
|
+
#initializationPromise;
|
|
7127
|
+
#wasUnavailable = false;
|
|
7128
7128
|
#eventBuffer;
|
|
7129
7129
|
#storage;
|
|
7130
7130
|
#observabilityStorage;
|
|
@@ -7149,41 +7149,56 @@ var MastraStorageExporter = class extends BaseExporter {
|
|
|
7149
7149
|
* Initialize the exporter (called after all dependencies are ready)
|
|
7150
7150
|
*/
|
|
7151
7151
|
async init(options) {
|
|
7152
|
+
this.#emitDropEvent = options.emitDropEvent;
|
|
7153
|
+
this.#storage = options.mastra?.getStorage();
|
|
7154
|
+
if (!this.#storage) {
|
|
7155
|
+
this.logger.warn("MastraStorageExporter disabled: Storage not available. Traces will not be persisted.");
|
|
7156
|
+
return;
|
|
7157
|
+
}
|
|
7158
|
+
await this.ensureInitialized();
|
|
7159
|
+
}
|
|
7160
|
+
warnUnavailable(message, error) {
|
|
7161
|
+
if (this.#wasUnavailable) return;
|
|
7162
|
+
this.#wasUnavailable = true;
|
|
7163
|
+
if (error === void 0) {
|
|
7164
|
+
this.logger.warn(message);
|
|
7165
|
+
return;
|
|
7166
|
+
}
|
|
7167
|
+
this.logger.warn(message, { error: error instanceof Error ? error.message : String(error) });
|
|
7168
|
+
}
|
|
7169
|
+
async initializeStorage() {
|
|
7170
|
+
const storage = this.#storage;
|
|
7171
|
+
if (!storage) return;
|
|
7152
7172
|
try {
|
|
7153
|
-
this.#
|
|
7154
|
-
|
|
7155
|
-
this
|
|
7156
|
-
|
|
7157
|
-
this.logger.warn("MastraStorageExporter disabled: Storage not available. Traces will not be persisted.");
|
|
7158
|
-
return;
|
|
7159
|
-
}
|
|
7160
|
-
this.#observabilityStorage = await this.#storage.getStore("observability");
|
|
7161
|
-
if (!this.#observabilityStorage) {
|
|
7162
|
-
this.logger.warn("MastraStorageExporter disabled: Observability storage not available. Traces will not be persisted.");
|
|
7163
|
-
return;
|
|
7164
|
-
}
|
|
7165
|
-
if (!this.#resolvedStrategy) {
|
|
7166
|
-
this.#resolvedStrategy = resolveTracingStorageStrategy(this.#config, this.#observabilityStorage, this.#storage.constructor.name, this.logger);
|
|
7167
|
-
this.logger.debug("tracing storage exporter initialized", {
|
|
7168
|
-
strategy: this.#resolvedStrategy,
|
|
7169
|
-
source: this.#config.strategy !== "auto" ? "user" : "auto",
|
|
7170
|
-
storageAdapter: this.#storage.constructor.name,
|
|
7171
|
-
maxBatchSize: this.#config.maxBatchSize,
|
|
7172
|
-
maxBatchWaitMs: this.#config.maxBatchWaitMs
|
|
7173
|
-
});
|
|
7174
|
-
}
|
|
7175
|
-
if (this.#resolvedStrategy) this.#eventBuffer.init({ strategy: this.#resolvedStrategy });
|
|
7176
|
-
} finally {
|
|
7177
|
-
this.#isInitializing = false;
|
|
7178
|
-
/**
|
|
7179
|
-
* Assumes caller waits until export of a parent span is completed before calling
|
|
7180
|
-
* export for child spans , order is not relevant for resolve
|
|
7181
|
-
*/
|
|
7182
|
-
this.#initPromises.forEach((resolve) => {
|
|
7183
|
-
resolve();
|
|
7184
|
-
});
|
|
7185
|
-
this.#initPromises.clear();
|
|
7173
|
+
this.#observabilityStorage = await storage.getStore("observability");
|
|
7174
|
+
} catch (error) {
|
|
7175
|
+
this.warnUnavailable("MastraStorageExporter unavailable: Failed to initialize observability storage. Traces will not be persisted until storage becomes available.", error);
|
|
7176
|
+
return;
|
|
7186
7177
|
}
|
|
7178
|
+
if (!this.#observabilityStorage) {
|
|
7179
|
+
this.warnUnavailable("MastraStorageExporter unavailable: Observability storage not available. Traces will not be persisted until storage becomes available.");
|
|
7180
|
+
return;
|
|
7181
|
+
}
|
|
7182
|
+
this.#resolvedStrategy = resolveTracingStorageStrategy(this.#config, this.#observabilityStorage, storage.constructor.name, this.logger);
|
|
7183
|
+
this.#eventBuffer.init({ strategy: this.#resolvedStrategy });
|
|
7184
|
+
this.logger.debug("tracing storage exporter initialized", {
|
|
7185
|
+
strategy: this.#resolvedStrategy,
|
|
7186
|
+
source: this.#config.strategy !== "auto" ? "user" : "auto",
|
|
7187
|
+
storageAdapter: storage.constructor.name,
|
|
7188
|
+
maxBatchSize: this.#config.maxBatchSize,
|
|
7189
|
+
maxBatchWaitMs: this.#config.maxBatchWaitMs
|
|
7190
|
+
});
|
|
7191
|
+
if (this.#wasUnavailable) {
|
|
7192
|
+
this.#wasUnavailable = false;
|
|
7193
|
+
this.logger.info("MastraStorageExporter recovered: Observability storage is available. Traces will be persisted.");
|
|
7194
|
+
}
|
|
7195
|
+
}
|
|
7196
|
+
async ensureInitialized() {
|
|
7197
|
+
if (this.#observabilityStorage || !this.#storage) return;
|
|
7198
|
+
this.#initializationPromise ??= this.initializeStorage().finally(() => {
|
|
7199
|
+
this.#initializationPromise = void 0;
|
|
7200
|
+
});
|
|
7201
|
+
await this.#initializationPromise;
|
|
7187
7202
|
}
|
|
7188
7203
|
/**
|
|
7189
7204
|
* Checks if buffer should be flushed based on size or time triggers
|
|
@@ -7435,7 +7450,7 @@ var MastraStorageExporter = class extends BaseExporter {
|
|
|
7435
7450
|
}
|
|
7436
7451
|
}
|
|
7437
7452
|
async _exportTracingEvent(event) {
|
|
7438
|
-
await this.
|
|
7453
|
+
await this.ensureInitialized();
|
|
7439
7454
|
if (!this.#observabilityStorage) {
|
|
7440
7455
|
this.logger.debug("Cannot store traces. Observability storage is not initialized");
|
|
7441
7456
|
return;
|
|
@@ -7444,21 +7459,10 @@ var MastraStorageExporter = class extends BaseExporter {
|
|
|
7444
7459
|
await this.handleBatchedFlush();
|
|
7445
7460
|
}
|
|
7446
7461
|
/**
|
|
7447
|
-
* Resolves when an ongoing init call is finished
|
|
7448
|
-
* Doesn't wait for the caller to call init
|
|
7449
|
-
* @returns
|
|
7450
|
-
*/
|
|
7451
|
-
async waitForInit() {
|
|
7452
|
-
if (!this.#isInitializing) return;
|
|
7453
|
-
return new Promise((resolve) => {
|
|
7454
|
-
this.#initPromises.add(resolve);
|
|
7455
|
-
});
|
|
7456
|
-
}
|
|
7457
|
-
/**
|
|
7458
7462
|
* Handle metric events — buffer for batch flush.
|
|
7459
7463
|
*/
|
|
7460
7464
|
async onMetricEvent(event) {
|
|
7461
|
-
await this.
|
|
7465
|
+
await this.ensureInitialized();
|
|
7462
7466
|
if (!this.#observabilityStorage) return;
|
|
7463
7467
|
this.#eventBuffer.addEvent(event);
|
|
7464
7468
|
await this.handleBatchedFlush();
|
|
@@ -7467,7 +7471,7 @@ var MastraStorageExporter = class extends BaseExporter {
|
|
|
7467
7471
|
* Handle log events — buffer for batch flush.
|
|
7468
7472
|
*/
|
|
7469
7473
|
async onLogEvent(event) {
|
|
7470
|
-
await this.
|
|
7474
|
+
await this.ensureInitialized();
|
|
7471
7475
|
if (!this.#observabilityStorage) return;
|
|
7472
7476
|
this.#eventBuffer.addEvent(event);
|
|
7473
7477
|
await this.handleBatchedFlush();
|
|
@@ -7476,7 +7480,7 @@ var MastraStorageExporter = class extends BaseExporter {
|
|
|
7476
7480
|
* Handle score events — buffer for batch flush.
|
|
7477
7481
|
*/
|
|
7478
7482
|
async onScoreEvent(event) {
|
|
7479
|
-
await this.
|
|
7483
|
+
await this.ensureInitialized();
|
|
7480
7484
|
if (!this.#observabilityStorage) return;
|
|
7481
7485
|
this.#eventBuffer.addEvent(event);
|
|
7482
7486
|
await this.handleBatchedFlush();
|
|
@@ -7485,7 +7489,7 @@ var MastraStorageExporter = class extends BaseExporter {
|
|
|
7485
7489
|
* Handle feedback events — buffer for batch flush.
|
|
7486
7490
|
*/
|
|
7487
7491
|
async onFeedbackEvent(event) {
|
|
7488
|
-
await this.
|
|
7492
|
+
await this.ensureInitialized();
|
|
7489
7493
|
if (!this.#observabilityStorage) return;
|
|
7490
7494
|
this.#eventBuffer.addEvent(event);
|
|
7491
7495
|
await this.handleBatchedFlush();
|