@mastra/observability 1.16.6-alpha.3 → 1.16.6
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 +46 -0
- package/dist/exporters/auth-failure-cooldown.d.ts +1 -1
- package/dist/exporters/auth-failure-cooldown.d.ts.map +1 -1
- package/dist/exporters/mastra-platform.d.ts +21 -0
- package/dist/exporters/mastra-platform.d.ts.map +1 -1
- package/dist/index.cjs +125 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +125 -13
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
# @mastra/observability
|
|
2
2
|
|
|
3
|
+
## 1.16.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed span exports when `excludeSpanTypes` removes a parent span. Descendant spans now use the nearest exported parent, so exporters retain tool calls. ([#20881](https://github.com/mastra-ai/mastra/pull/20881))
|
|
8
|
+
|
|
9
|
+
- Use Vercel AI Gateway reported costs for completed model generations when every step reports a valid cost. ([#19921](https://github.com/mastra-ai/mastra/pull/19921))
|
|
10
|
+
|
|
11
|
+
- Fixed an issue where live workflow scores and feedback could be lost before their trace data reached observability storage. Mastra now logs a warning when it cannot save an annotation. ([#20795](https://github.com/mastra-ai/mastra/pull/20795))
|
|
12
|
+
|
|
13
|
+
- Preserved the provider response model on completed model inference spans. ([#21154](https://github.com/mastra-ai/mastra/pull/21154))
|
|
14
|
+
|
|
15
|
+
- Added automatic quota pause to MastraPlatformExporter. When the Mastra platform reports that an organization's observability quota is exhausted (by rejecting publish requests with `402 Payment Required` and the `x-mastra-observability: disabled` header), the exporter now stops uploading telemetry, drops events locally instead of retrying, and periodically probes the platform (honoring the `x-mastra-observability-retry-after` hint, defaulting to every 5 minutes). Exports resume automatically once the platform re-enables observability, with warnings logged on pause and resume. ([#21160](https://github.com/mastra-ai/mastra/pull/21160))
|
|
16
|
+
|
|
17
|
+
No quota-specific configuration is needed — any existing exporter setup gets this behavior automatically:
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { MastraPlatformExporter } from '@mastra/observability';
|
|
21
|
+
|
|
22
|
+
const exporter = new MastraPlatformExporter({
|
|
23
|
+
accessToken: process.env.MASTRA_PLATFORM_ACCESS_TOKEN,
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
- Updated dependencies [[`e7109ee`](https://github.com/mastra-ai/mastra/commit/e7109ee6f731bacc79c885906f3c7dca8d8f013a), [`b8ce7ec`](https://github.com/mastra-ai/mastra/commit/b8ce7ec96e39343c6c2f36d12d68a9ad816c09f7), [`2e4624e`](https://github.com/mastra-ai/mastra/commit/2e4624edb6917e61249cb60ee377735e7af7e4a9), [`45a9147`](https://github.com/mastra-ai/mastra/commit/45a914741f578754d79d8b7de7b4e4f304d8e14a), [`a3a3624`](https://github.com/mastra-ai/mastra/commit/a3a3624f646b98e409424d8defccbd334da9e8b8), [`6246914`](https://github.com/mastra-ai/mastra/commit/62469146636911f3cbbe0880bd011c6a897a59a7), [`6445eba`](https://github.com/mastra-ai/mastra/commit/6445eba6020abac681aba1cc9289f446cb400cbe), [`86b7b77`](https://github.com/mastra-ai/mastra/commit/86b7b777980d30f66e1fd134a37d2af4c22e54cc), [`1c75e32`](https://github.com/mastra-ai/mastra/commit/1c75e32f7fc0b9fb6f548b4407feaec8a1440212), [`296dc9a`](https://github.com/mastra-ai/mastra/commit/296dc9af29f3616e786c7825ec32e0df92d754c5), [`f59032a`](https://github.com/mastra-ai/mastra/commit/f59032a73699443555a08a479e7ac578975784f2), [`cdd5c33`](https://github.com/mastra-ai/mastra/commit/cdd5c33ac6c7118a9f139e6dc0e14e6a8ae31658), [`3f73c07`](https://github.com/mastra-ai/mastra/commit/3f73c076727e8c36b4fff7a1b40290fb68957fa8), [`772c0c8`](https://github.com/mastra-ai/mastra/commit/772c0c897cec383258de2e6178147f8014767c7b), [`d7cf7fa`](https://github.com/mastra-ai/mastra/commit/d7cf7fafc1ae1b50bd8462dd0e6c671a8606db93), [`7c1ebb1`](https://github.com/mastra-ai/mastra/commit/7c1ebb15690c4b3f0eabb19077cf8af573311e57), [`0f9a448`](https://github.com/mastra-ai/mastra/commit/0f9a448502157e59f7b76f24360ad497168f5ef8), [`578bf2e`](https://github.com/mastra-ai/mastra/commit/578bf2e6a88e9d5b8bf502204e15a95dfbb679ae), [`c47165c`](https://github.com/mastra-ai/mastra/commit/c47165c983c87594c6952f1fd2fa51a90205034c), [`289f4ce`](https://github.com/mastra-ai/mastra/commit/289f4ce16e3293370440172132c52ee787cbc09f), [`df31eb0`](https://github.com/mastra-ai/mastra/commit/df31eb0c7087d782a0d9346e467f9a4af4b0eef6), [`9571e3a`](https://github.com/mastra-ai/mastra/commit/9571e3a06ed2c5220196460bf82a2129255c3a8b), [`4f16ff8`](https://github.com/mastra-ai/mastra/commit/4f16ff824bf2f9b0ddc93f210477c10c8a4fb1ab), [`b4c89b4`](https://github.com/mastra-ai/mastra/commit/b4c89b4371b0c86da57403ad1a3b3ef0681f3128), [`e6534fa`](https://github.com/mastra-ai/mastra/commit/e6534fab031216f6cb48c4c9907cbfdce9d60bc6), [`210cb7a`](https://github.com/mastra-ai/mastra/commit/210cb7a167998c7bbf72cb3b93e6eb0563330239), [`06b2d87`](https://github.com/mastra-ai/mastra/commit/06b2d87e63bcdd0ed59215c6789692b9b12de376), [`1c67d85`](https://github.com/mastra-ai/mastra/commit/1c67d85e9da8285662f4dbbf47e0378c3fee0747), [`ac01d63`](https://github.com/mastra-ai/mastra/commit/ac01d6355974aec73fdb8781449ed12bac582094), [`80a3324`](https://github.com/mastra-ai/mastra/commit/80a33245d3110204de6f56d61211523ffe338692), [`e44e8f3`](https://github.com/mastra-ai/mastra/commit/e44e8f370b66c339ddcaba946d33da6d3c3f06cd), [`d9d2881`](https://github.com/mastra-ai/mastra/commit/d9d2881ede6dd6c023d144215fc812062aed0890), [`a810a05`](https://github.com/mastra-ai/mastra/commit/a810a058f62ad407cfc1701e0be36ae91145d7cf), [`ba24be6`](https://github.com/mastra-ai/mastra/commit/ba24be662439c331ab23a600041f93803c89eca8), [`842b5fe`](https://github.com/mastra-ai/mastra/commit/842b5fe22b6a7fa811bd14e48eb9af523ac989f2), [`990611b`](https://github.com/mastra-ai/mastra/commit/990611ba76eb876d86c9c594371ae5f02f94b432), [`80bdf3a`](https://github.com/mastra-ai/mastra/commit/80bdf3ae16ade6ff63bde0cb16fa2df8ab7dd4dd), [`c967a5e`](https://github.com/mastra-ai/mastra/commit/c967a5eec150c5dc5418c4a4388982d1fb7ad27c), [`dc4a25d`](https://github.com/mastra-ai/mastra/commit/dc4a25d41af4e2fe97a816070eaec6aa963ab53b), [`9ba1247`](https://github.com/mastra-ai/mastra/commit/9ba12470c77f1c03642d720ce67e517e878f666e), [`fd96298`](https://github.com/mastra-ai/mastra/commit/fd96298a8367622f4ebfcaa97b5b6c1fbbd14564), [`66bbfb5`](https://github.com/mastra-ai/mastra/commit/66bbfb5f05b473d39f88c0e4a481ccac41634f3a), [`dc4a25d`](https://github.com/mastra-ai/mastra/commit/dc4a25d41af4e2fe97a816070eaec6aa963ab53b), [`f8da216`](https://github.com/mastra-ai/mastra/commit/f8da21633e7eb0e31c9ce0fc30567870d19416d3), [`4a09a9c`](https://github.com/mastra-ai/mastra/commit/4a09a9c0474ef643558fcb5f0edc542b82f1cab0), [`5f798b3`](https://github.com/mastra-ai/mastra/commit/5f798b3362e9bdf4d690f85245606e146eef60b9), [`6a84954`](https://github.com/mastra-ai/mastra/commit/6a84954a2667f85b6d59da652dab1bbff007ccb0), [`1e83a47`](https://github.com/mastra-ai/mastra/commit/1e83a4734ab61ba5926af6793e3569a78b72ed37), [`52d8ef0`](https://github.com/mastra-ai/mastra/commit/52d8ef03801f1deb7ee48532fc4190dd4a33916c), [`cdd5c33`](https://github.com/mastra-ai/mastra/commit/cdd5c33ac6c7118a9f139e6dc0e14e6a8ae31658), [`7fdcaa6`](https://github.com/mastra-ai/mastra/commit/7fdcaa66105d64290f9b14432a12ec99f39c4d3a), [`d6c56f9`](https://github.com/mastra-ai/mastra/commit/d6c56f951db3213330b98b0abafa9778c8770e58), [`e08e789`](https://github.com/mastra-ai/mastra/commit/e08e789c1bf4cd2fe46363f7a4728536ceccc9bd), [`bf936e2`](https://github.com/mastra-ai/mastra/commit/bf936e2c89b2ff0dad5695b873ddc009ba96d41e), [`7fb580a`](https://github.com/mastra-ai/mastra/commit/7fb580ac73fbcacf2ff00872a3395f73ae1b9fa5), [`ed5d606`](https://github.com/mastra-ai/mastra/commit/ed5d606739c5e3fbdfa9f272df7809aa5ab43b1d), [`f53d5bd`](https://github.com/mastra-ai/mastra/commit/f53d5bd4885b29e4ac29a428a6044088ea8d6aa3), [`32980a3`](https://github.com/mastra-ai/mastra/commit/32980a3e2413d0274ac244d32c37d910edc13f00), [`01a2943`](https://github.com/mastra-ai/mastra/commit/01a2943a7d886edefdff072bfa51f055bab54437), [`82e3365`](https://github.com/mastra-ai/mastra/commit/82e3365ef7c9bf7bee2e7a7029035ea262d68895), [`6104347`](https://github.com/mastra-ai/mastra/commit/61043473ba6bfd0a25156824e853e13165562e6c), [`35cc901`](https://github.com/mastra-ai/mastra/commit/35cc90102cf834a84827acaf9eee0b6d6d1e2a3b), [`a8b4cf0`](https://github.com/mastra-ai/mastra/commit/a8b4cf02823cffebc4751a53337dfacf097c1ae1), [`9571e3a`](https://github.com/mastra-ai/mastra/commit/9571e3a06ed2c5220196460bf82a2129255c3a8b), [`333785c`](https://github.com/mastra-ai/mastra/commit/333785c93cbb01e42c60167e995457c28897ddbf), [`bda2235`](https://github.com/mastra-ai/mastra/commit/bda22353ee28f2df0eaea555f7cae1549f979c0b), [`efd5c81`](https://github.com/mastra-ai/mastra/commit/efd5c81cc25fde3c2ddd86fc1178deb4ec176e19), [`1b482c2`](https://github.com/mastra-ai/mastra/commit/1b482c2d89244dd758c41e5f927a2b44041388d2), [`45bfb88`](https://github.com/mastra-ai/mastra/commit/45bfb88fd52f1dd3be20e2a38905777c96499c90), [`ff28284`](https://github.com/mastra-ai/mastra/commit/ff2828416f14daff9d956e6a352fdaa23c950979), [`4bcdfaf`](https://github.com/mastra-ai/mastra/commit/4bcdfaf0eac3199d7cb171b0a19a92c9c341eea4), [`e3b9307`](https://github.com/mastra-ai/mastra/commit/e3b9307098daefbfae2a52ae2ef51bc9fc701190), [`d6834c5`](https://github.com/mastra-ai/mastra/commit/d6834c5a7866b16734d23900163c2414ed70d791), [`f33264f`](https://github.com/mastra-ai/mastra/commit/f33264f517ae603279afd5c4251e2b40f6dd3618), [`689f2c4`](https://github.com/mastra-ai/mastra/commit/689f2c4b6c0835fe455702b01d21daa8abcd9331), [`fcd0667`](https://github.com/mastra-ai/mastra/commit/fcd0667a4e378be35c9a1b1eb19cce78fbfd7282), [`cfd0d9e`](https://github.com/mastra-ai/mastra/commit/cfd0d9ec77ec3c69dd96f79cdb579e03d79f22ce), [`acc3513`](https://github.com/mastra-ai/mastra/commit/acc3513b19f79bf0a7ec2998694580edca54086c), [`1670533`](https://github.com/mastra-ai/mastra/commit/1670533986f6bacf567746245348125e3a106448), [`a7eb4a1`](https://github.com/mastra-ai/mastra/commit/a7eb4a11450f6170274ed5141bffe821d4fdd5a6), [`0976933`](https://github.com/mastra-ai/mastra/commit/0976933142333ec78451feef265b68bcb45aa5e7), [`242b945`](https://github.com/mastra-ai/mastra/commit/242b94558777bfbdeb42cbfea84afff0b6ad0633), [`c52d346`](https://github.com/mastra-ai/mastra/commit/c52d3462ec831a5d95926ecd3d3373f5928ad2e5), [`af4636a`](https://github.com/mastra-ai/mastra/commit/af4636a74463275d71c1d13a38f7d2b738f128bf), [`01a2943`](https://github.com/mastra-ai/mastra/commit/01a2943a7d886edefdff072bfa51f055bab54437), [`2eabc09`](https://github.com/mastra-ai/mastra/commit/2eabc097d86d52fbd0123da36a7c874154cc384f), [`0023e79`](https://github.com/mastra-ai/mastra/commit/0023e7919431078280abd11c89d1edeae35fcc69), [`c2ad51e`](https://github.com/mastra-ai/mastra/commit/c2ad51e2467f901eecba8c9f4a45e22a50bd7c18), [`25ca73d`](https://github.com/mastra-ai/mastra/commit/25ca73d25dee7ce9f0ca72939e3a505c4db7257e), [`2f9ef3f`](https://github.com/mastra-ai/mastra/commit/2f9ef3f4ca06fc2dcdd5088c26b7f4da6a016791), [`e7eefcb`](https://github.com/mastra-ai/mastra/commit/e7eefcb162cda7c493e8c3bf43050ead0efbcb2c), [`fea5cae`](https://github.com/mastra-ai/mastra/commit/fea5caedc7e2cfea51784a15e015952692027abf), [`4d7aca2`](https://github.com/mastra-ai/mastra/commit/4d7aca2fe75f225c83d1502d63079568e6ec163f), [`e1cead1`](https://github.com/mastra-ai/mastra/commit/e1cead17b5f3653cf00d2f90cc19b113119c02ba), [`01a2943`](https://github.com/mastra-ai/mastra/commit/01a2943a7d886edefdff072bfa51f055bab54437), [`d9d93b2`](https://github.com/mastra-ai/mastra/commit/d9d93b25e4a65ad5fa153fa35be7ed149c8d587f), [`c4ec889`](https://github.com/mastra-ai/mastra/commit/c4ec889561c0264c43f66d04d587bee4ce35e792), [`4b59f78`](https://github.com/mastra-ai/mastra/commit/4b59f786cbc9a7d1ef07a07517dbd4b96865e99d), [`eeae63e`](https://github.com/mastra-ai/mastra/commit/eeae63e7fbe8e1f237adc69bca6e2ac13c5ca907), [`3dc97ea`](https://github.com/mastra-ai/mastra/commit/3dc97ea415fad353b48a13095fad1835933cc12a), [`94e7ae9`](https://github.com/mastra-ai/mastra/commit/94e7ae970b37c888cd1244ef013292639a2fe6d1), [`e6a2860`](https://github.com/mastra-ai/mastra/commit/e6a2860649cc51f87d32d78b766ae2126446ba07), [`7010c5d`](https://github.com/mastra-ai/mastra/commit/7010c5d15728bf9c5dfe4fb6b1bf80ce23bf143a), [`bab06b1`](https://github.com/mastra-ai/mastra/commit/bab06b18923873a584bdfc71a6b4ec7fb4727fb7), [`3d01cd3`](https://github.com/mastra-ai/mastra/commit/3d01cd387321b6f9c5cac31d487c84bf51b19c78), [`7bf3086`](https://github.com/mastra-ai/mastra/commit/7bf308663f0115ca74ad20554ade740f06640859), [`4c186a0`](https://github.com/mastra-ai/mastra/commit/4c186a017275f45e6ed4c09de0f89550e2d09e8c), [`b0fa077`](https://github.com/mastra-ai/mastra/commit/b0fa077bcbc9b08551846fe372a0d3d15b71ed72), [`0282e16`](https://github.com/mastra-ai/mastra/commit/0282e16115538c8e9b248b90f0748eb01cb5dc98), [`a8dd139`](https://github.com/mastra-ai/mastra/commit/a8dd1391a9fe9a6632c25809ef236980afa9a020), [`6a667b4`](https://github.com/mastra-ai/mastra/commit/6a667b4b7cd6a93fe41fcdd357b08c5a8c09b9ab), [`9be8878`](https://github.com/mastra-ai/mastra/commit/9be8878dcf0388e84fc4873e0eec27bd49b881a4), [`e5786be`](https://github.com/mastra-ai/mastra/commit/e5786be02bb903073082bd9d6da880ebaacc343f), [`2440e09`](https://github.com/mastra-ai/mastra/commit/2440e096ea6c2def1ccc1eb2d0f3f5b88c4af940), [`2093fbd`](https://github.com/mastra-ai/mastra/commit/2093fbd53bb744bae19ec89f6d73db9a66fbe8a7), [`a59049b`](https://github.com/mastra-ai/mastra/commit/a59049b1652a13efff66ac826326b5ed9a550342), [`7bd85ea`](https://github.com/mastra-ai/mastra/commit/7bd85ea7588b71c25ce9f4019c88f8539be5dcbc), [`83fa004`](https://github.com/mastra-ai/mastra/commit/83fa0044bfda8b703a83883dbd8bef204844d13f), [`a463cdf`](https://github.com/mastra-ai/mastra/commit/a463cdf1c95c3059e70f0bff27959e8558bb899d), [`e7a5da4`](https://github.com/mastra-ai/mastra/commit/e7a5da4ef8e4dd452d2f232961b4e682a85ffe43), [`7b4393d`](https://github.com/mastra-ai/mastra/commit/7b4393d557411fdcf07b0e30e5acaf7cc85154ae), [`0ea6b80`](https://github.com/mastra-ai/mastra/commit/0ea6b8001408ce02b56e8be0536b0fd8cbaf8ad2)]:
|
|
28
|
+
- @mastra/core@1.58.0
|
|
29
|
+
|
|
30
|
+
## 1.16.6-alpha.4
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- Added automatic quota pause to MastraPlatformExporter. When the Mastra platform reports that an organization's observability quota is exhausted (by rejecting publish requests with `402 Payment Required` and the `x-mastra-observability: disabled` header), the exporter now stops uploading telemetry, drops events locally instead of retrying, and periodically probes the platform (honoring the `x-mastra-observability-retry-after` hint, defaulting to every 5 minutes). Exports resume automatically once the platform re-enables observability, with warnings logged on pause and resume. ([#21160](https://github.com/mastra-ai/mastra/pull/21160))
|
|
35
|
+
|
|
36
|
+
No quota-specific configuration is needed — any existing exporter setup gets this behavior automatically:
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
import { MastraPlatformExporter } from '@mastra/observability';
|
|
40
|
+
|
|
41
|
+
const exporter = new MastraPlatformExporter({
|
|
42
|
+
accessToken: process.env.MASTRA_PLATFORM_ACCESS_TOKEN,
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
- Updated dependencies [[`210cb7a`](https://github.com/mastra-ai/mastra/commit/210cb7a167998c7bbf72cb3b93e6eb0563330239), [`5f798b3`](https://github.com/mastra-ai/mastra/commit/5f798b3362e9bdf4d690f85245606e146eef60b9), [`01a2943`](https://github.com/mastra-ai/mastra/commit/01a2943a7d886edefdff072bfa51f055bab54437), [`01a2943`](https://github.com/mastra-ai/mastra/commit/01a2943a7d886edefdff072bfa51f055bab54437), [`25ca73d`](https://github.com/mastra-ai/mastra/commit/25ca73d25dee7ce9f0ca72939e3a505c4db7257e), [`e1cead1`](https://github.com/mastra-ai/mastra/commit/e1cead17b5f3653cf00d2f90cc19b113119c02ba), [`01a2943`](https://github.com/mastra-ai/mastra/commit/01a2943a7d886edefdff072bfa51f055bab54437)]:
|
|
47
|
+
- @mastra/core@1.58.0-alpha.14
|
|
48
|
+
|
|
3
49
|
## 1.16.6-alpha.3
|
|
4
50
|
|
|
5
51
|
### Patch Changes
|
|
@@ -4,7 +4,7 @@ export declare class AuthFailureError extends Error {
|
|
|
4
4
|
constructor(status: number, cause?: unknown);
|
|
5
5
|
}
|
|
6
6
|
export declare function isAuthFailureError(error: unknown): error is AuthFailureError;
|
|
7
|
-
export declare function fetchWithAuthFailureHandling(url: string, options: RequestInit, maxRetries: number): Promise<
|
|
7
|
+
export declare function fetchWithAuthFailureHandling(url: string, options: RequestInit, maxRetries: number, callerShouldRetry?: (response: Response) => boolean): Promise<Response>;
|
|
8
8
|
export declare class AuthFailureCooldown {
|
|
9
9
|
private readonly exporterName;
|
|
10
10
|
private readonly getLogger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-failure-cooldown.d.ts","sourceRoot":"","sources":["../../src/exporters/auth-failure-cooldown.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AASzD,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAK5C;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB,CAE5E;AAMD,wBAAsB,4BAA4B,CAChD,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"auth-failure-cooldown.d.ts","sourceRoot":"","sources":["../../src/exporters/auth-failure-cooldown.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AASzD,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAK5C;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB,CAE5E;AAMD,wBAAsB,4BAA4B,CAChD,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,MAAM,EAClB,iBAAiB,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,OAAO,GAClD,OAAO,CAAC,QAAQ,CAAC,CAqBnB;AAED,qBAAa,mBAAmB;IAM5B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAN5B,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,eAAe,CAAK;IAC5B,OAAO,CAAC,2BAA2B,CAAK;gBAGrB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,aAAa;IAGjD,OAAO,CAAC,gBAAgB;IAIxB,sBAAsB,IAAI,OAAO;IAIjC,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAS/C,KAAK,IAAI,MAAM;IAUf,aAAa,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,EAAE,CAAC;QAAC,gBAAgB,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;CAwBjG"}
|
|
@@ -21,6 +21,10 @@ export declare class MastraPlatformExporter extends BaseExporter {
|
|
|
21
21
|
private buffer;
|
|
22
22
|
private flushTimer;
|
|
23
23
|
private inFlightFlushes;
|
|
24
|
+
private quotaPaused;
|
|
25
|
+
private quotaProbeTimer;
|
|
26
|
+
private quotaProbeIntervalSeconds;
|
|
27
|
+
private shuttingDown;
|
|
24
28
|
constructor(config?: MastraPlatformExporterConfig);
|
|
25
29
|
protected _exportTracingEvent(event: TracingEvent): Promise<void>;
|
|
26
30
|
onLogEvent(event: LogEvent): Promise<void>;
|
|
@@ -45,7 +49,24 @@ export declare class MastraPlatformExporter extends BaseExporter {
|
|
|
45
49
|
/**
|
|
46
50
|
* Uploads a signal batch to the configured Mastra Observability API using fetchWithRetry.
|
|
47
51
|
*/
|
|
52
|
+
private buildPublishHeaders;
|
|
53
|
+
private buildPublishBody;
|
|
48
54
|
private batchUpload;
|
|
55
|
+
/**
|
|
56
|
+
* Enter the quota-exhausted paused state: drop buffered events, stop the
|
|
57
|
+
* flush timer, and start probing until the collector stops rejecting with
|
|
58
|
+
* 402. The gate is per-org, so a signal on any publish route pauses all
|
|
59
|
+
* five signal types.
|
|
60
|
+
*/
|
|
61
|
+
private enterQuotaPause;
|
|
62
|
+
private scheduleQuotaProbe;
|
|
63
|
+
/**
|
|
64
|
+
* Send an empty spans batch as a free probe. The collector treats an empty
|
|
65
|
+
* batch as a no-op, and an exhausted org still gets the 402 on it. A 402
|
|
66
|
+
* throws out of fetchWithRetry without the Response, so the retry predicate
|
|
67
|
+
* captures it to keep the retry-after hint.
|
|
68
|
+
*/
|
|
69
|
+
private probeQuotaStatus;
|
|
49
70
|
private flushSignalBatch;
|
|
50
71
|
private resetBuffer;
|
|
51
72
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mastra-platform.d.ts","sourceRoot":"","sources":["../../src/exporters/mastra-platform.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,YAAY,EAEZ,QAAQ,EACR,WAAW,EACX,UAAU,EACV,aAAa,EACd,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"mastra-platform.d.ts","sourceRoot":"","sources":["../../src/exporters/mastra-platform.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,YAAY,EAEZ,QAAQ,EACR,WAAW,EACX,UAAU,EACV,aAAa,EACd,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAEjD,MAAM,WAAW,4BAA6B,SAAQ,kBAAkB;IACtE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAkOD,qBAAa,sBAAuB,SAAQ,YAAY;IACtD,IAAI,SAA8B;IAElC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAmC;IAClE,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAsB;IAC1D,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,UAAU,CAA+B;IACjD,OAAO,CAAC,eAAe,CAA4B;IACnD,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,eAAe,CAA+B;IACtD,OAAO,CAAC,yBAAyB,CAAwC;IACzE,OAAO,CAAC,YAAY,CAAS;gBAEjB,MAAM,GAAE,4BAAiC;cAyErC,mBAAmB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBjE,UAAU,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAa1C,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAahD,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAa9C,eAAe,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAa1D,OAAO,CAAC,WAAW;IAQnB,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,gBAAgB;IAOxB,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,UAAU;IAelB,OAAO,CAAC,SAAS;IAMjB,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,cAAc;YAMR,mBAAmB;IAYjC,OAAO,CAAC,WAAW;IAenB,OAAO,CAAC,aAAa;YAoBP,WAAW;IA4EzB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,gBAAgB;YAIV,WAAW;IAoDzB;;;;;OAKG;IACH,OAAO,CAAC,eAAe;IAsBvB,OAAO,CAAC,kBAAkB;IAkB1B;;;;;OAKG;YACW,gBAAgB;YAoDhB,gBAAgB;IAmC9B,OAAO,CAAC,WAAW;IAUnB;;;;OAIG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA2BtB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAsChC"}
|
package/dist/index.cjs
CHANGED
|
@@ -5203,15 +5203,15 @@ function isAuthFailureError(error) {
|
|
|
5203
5203
|
function isAuthFailureStatus(status) {
|
|
5204
5204
|
return AUTH_FAILURE_STATUSES.has(status);
|
|
5205
5205
|
}
|
|
5206
|
-
async function fetchWithAuthFailureHandling(url, options, maxRetries) {
|
|
5206
|
+
async function fetchWithAuthFailureHandling(url, options, maxRetries, callerShouldRetry) {
|
|
5207
5207
|
let authFailureStatus;
|
|
5208
5208
|
try {
|
|
5209
|
-
await (0, _mastra_core_utils.fetchWithRetry)(url, options, maxRetries, { shouldRetryResponse: (response) => {
|
|
5209
|
+
return await (0, _mastra_core_utils.fetchWithRetry)(url, options, maxRetries, { shouldRetryResponse: (response) => {
|
|
5210
5210
|
if (isAuthFailureStatus(response.status)) {
|
|
5211
5211
|
authFailureStatus = response.status;
|
|
5212
5212
|
return false;
|
|
5213
5213
|
}
|
|
5214
|
-
return true;
|
|
5214
|
+
return callerShouldRetry?.(response) ?? true;
|
|
5215
5215
|
} });
|
|
5216
5216
|
} catch (error) {
|
|
5217
5217
|
if (authFailureStatus !== void 0) throw new AuthFailureError(authFailureStatus, error);
|
|
@@ -6341,6 +6341,25 @@ const SIGNAL_PUBLISH_SUFFIXES = {
|
|
|
6341
6341
|
feedback: "/feedback/publish"
|
|
6342
6342
|
};
|
|
6343
6343
|
const DEFAULT_PLATFORM_SPAN_FILTER = (span) => span.type !== _mastra_core_observability.SpanType.MODEL_CHUNK;
|
|
6344
|
+
const QUOTA_EXCEEDED_STATUS = 402;
|
|
6345
|
+
const OBSERVABILITY_STATUS_HEADER = "x-mastra-observability";
|
|
6346
|
+
const OBSERVABILITY_DISABLED_VALUE = "disabled";
|
|
6347
|
+
const OBSERVABILITY_RETRY_AFTER_HEADER = "x-mastra-observability-retry-after";
|
|
6348
|
+
const DEFAULT_QUOTA_PROBE_INTERVAL_SECONDS = 300;
|
|
6349
|
+
const MAX_QUOTA_PROBE_INTERVAL_SECONDS = Math.floor(2147483647 / 1e3);
|
|
6350
|
+
function isObservabilityDisabled(response) {
|
|
6351
|
+
return response.headers.get(OBSERVABILITY_STATUS_HEADER) === OBSERVABILITY_DISABLED_VALUE;
|
|
6352
|
+
}
|
|
6353
|
+
function isQuotaExceededResponse(response) {
|
|
6354
|
+
return response.status === QUOTA_EXCEEDED_STATUS || isObservabilityDisabled(response);
|
|
6355
|
+
}
|
|
6356
|
+
function parseQuotaRetryAfterSeconds(response) {
|
|
6357
|
+
const raw = response.headers.get(OBSERVABILITY_RETRY_AFTER_HEADER);
|
|
6358
|
+
if (!raw || !/^\d+$/.test(raw.trim())) return DEFAULT_QUOTA_PROBE_INTERVAL_SECONDS;
|
|
6359
|
+
const parsed = Number.parseInt(raw, 10);
|
|
6360
|
+
if (!Number.isFinite(parsed) || parsed <= 0) return DEFAULT_QUOTA_PROBE_INTERVAL_SECONDS;
|
|
6361
|
+
return Math.min(parsed, MAX_QUOTA_PROBE_INTERVAL_SECONDS);
|
|
6362
|
+
}
|
|
6344
6363
|
const SIGNAL_PUBLISH_SEGMENTS = {
|
|
6345
6364
|
traces: "spans",
|
|
6346
6365
|
logs: "logs",
|
|
@@ -6430,6 +6449,10 @@ var MastraPlatformExporter = class extends BaseExporter {
|
|
|
6430
6449
|
buffer;
|
|
6431
6450
|
flushTimer = null;
|
|
6432
6451
|
inFlightFlushes = /* @__PURE__ */ new Set();
|
|
6452
|
+
quotaPaused = false;
|
|
6453
|
+
quotaProbeTimer = null;
|
|
6454
|
+
quotaProbeIntervalSeconds = DEFAULT_QUOTA_PROBE_INTERVAL_SECONDS;
|
|
6455
|
+
shuttingDown = false;
|
|
6433
6456
|
constructor(config = {}) {
|
|
6434
6457
|
super(config);
|
|
6435
6458
|
if (config.projectId !== void 0 && !VALID_PROJECT_ID.test(config.projectId)) throw createInvalidProjectIdError(config.projectId);
|
|
@@ -6478,31 +6501,31 @@ var MastraPlatformExporter = class extends BaseExporter {
|
|
|
6478
6501
|
async _exportTracingEvent(event) {
|
|
6479
6502
|
if (event.type !== _mastra_core_observability.TracingEventType.SPAN_ENDED) return;
|
|
6480
6503
|
if (!DEFAULT_PLATFORM_SPAN_FILTER(event.exportedSpan)) return;
|
|
6481
|
-
if (this.authFailureCooldown.dropEventIfCoolingDown()) return;
|
|
6504
|
+
if (this.quotaPaused || this.authFailureCooldown.dropEventIfCoolingDown()) return;
|
|
6482
6505
|
this.addToBuffer(event);
|
|
6483
6506
|
await this.handleBufferedEvent();
|
|
6484
6507
|
}
|
|
6485
6508
|
async onLogEvent(event) {
|
|
6486
6509
|
if (this.isDisabled) return;
|
|
6487
|
-
if (this.authFailureCooldown.dropEventIfCoolingDown()) return;
|
|
6510
|
+
if (this.quotaPaused || this.authFailureCooldown.dropEventIfCoolingDown()) return;
|
|
6488
6511
|
this.addLogToBuffer(event);
|
|
6489
6512
|
await this.handleBufferedEvent();
|
|
6490
6513
|
}
|
|
6491
6514
|
async onMetricEvent(event) {
|
|
6492
6515
|
if (this.isDisabled) return;
|
|
6493
|
-
if (this.authFailureCooldown.dropEventIfCoolingDown()) return;
|
|
6516
|
+
if (this.quotaPaused || this.authFailureCooldown.dropEventIfCoolingDown()) return;
|
|
6494
6517
|
this.addMetricToBuffer(event);
|
|
6495
6518
|
await this.handleBufferedEvent();
|
|
6496
6519
|
}
|
|
6497
6520
|
async onScoreEvent(event) {
|
|
6498
6521
|
if (this.isDisabled) return;
|
|
6499
|
-
if (this.authFailureCooldown.dropEventIfCoolingDown()) return;
|
|
6522
|
+
if (this.quotaPaused || this.authFailureCooldown.dropEventIfCoolingDown()) return;
|
|
6500
6523
|
this.addScoreToBuffer(event);
|
|
6501
6524
|
await this.handleBufferedEvent();
|
|
6502
6525
|
}
|
|
6503
6526
|
async onFeedbackEvent(event) {
|
|
6504
6527
|
if (this.isDisabled) return;
|
|
6505
|
-
if (this.authFailureCooldown.dropEventIfCoolingDown()) return;
|
|
6528
|
+
if (this.quotaPaused || this.authFailureCooldown.dropEventIfCoolingDown()) return;
|
|
6506
6529
|
this.addFeedbackToBuffer(event);
|
|
6507
6530
|
await this.handleBufferedEvent();
|
|
6508
6531
|
}
|
|
@@ -6592,6 +6615,10 @@ var MastraPlatformExporter = class extends BaseExporter {
|
|
|
6592
6615
|
this.flushTimer = null;
|
|
6593
6616
|
}
|
|
6594
6617
|
if (this.buffer.totalSize === 0) return;
|
|
6618
|
+
if (this.quotaPaused) {
|
|
6619
|
+
this.resetBuffer();
|
|
6620
|
+
return;
|
|
6621
|
+
}
|
|
6595
6622
|
if (this.authFailureCooldown.dropEventsIfCoolingDown(this.buffer.totalSize)) {
|
|
6596
6623
|
this.resetBuffer();
|
|
6597
6624
|
return;
|
|
@@ -6641,11 +6668,16 @@ var MastraPlatformExporter = class extends BaseExporter {
|
|
|
6641
6668
|
/**
|
|
6642
6669
|
* Uploads a signal batch to the configured Mastra Observability API using fetchWithRetry.
|
|
6643
6670
|
*/
|
|
6644
|
-
|
|
6645
|
-
|
|
6671
|
+
buildPublishHeaders() {
|
|
6672
|
+
return {
|
|
6646
6673
|
Authorization: `Bearer ${this.platformConfig.accessToken}`,
|
|
6647
6674
|
"Content-Type": "application/json"
|
|
6648
6675
|
};
|
|
6676
|
+
}
|
|
6677
|
+
buildPublishBody(signal, records) {
|
|
6678
|
+
return JSON.stringify({ [SIGNAL_PUBLISH_SEGMENTS[signal]]: records });
|
|
6679
|
+
}
|
|
6680
|
+
async batchUpload(signal, records) {
|
|
6649
6681
|
const endpointMap = {
|
|
6650
6682
|
traces: this.platformConfig.tracesEndpoint,
|
|
6651
6683
|
logs: this.platformConfig.logsEndpoint,
|
|
@@ -6655,10 +6687,85 @@ var MastraPlatformExporter = class extends BaseExporter {
|
|
|
6655
6687
|
};
|
|
6656
6688
|
const options = {
|
|
6657
6689
|
method: "POST",
|
|
6658
|
-
headers,
|
|
6659
|
-
body:
|
|
6690
|
+
headers: this.buildPublishHeaders(),
|
|
6691
|
+
body: this.buildPublishBody(signal, records)
|
|
6660
6692
|
};
|
|
6661
|
-
|
|
6693
|
+
let quotaResponse;
|
|
6694
|
+
let response;
|
|
6695
|
+
try {
|
|
6696
|
+
response = await fetchWithAuthFailureHandling(endpointMap[signal], options, this.platformConfig.maxRetries, (res) => {
|
|
6697
|
+
if (isQuotaExceededResponse(res)) {
|
|
6698
|
+
quotaResponse = res;
|
|
6699
|
+
return false;
|
|
6700
|
+
}
|
|
6701
|
+
return true;
|
|
6702
|
+
});
|
|
6703
|
+
} catch (error) {
|
|
6704
|
+
if (quotaResponse) {
|
|
6705
|
+
this.enterQuotaPause(parseQuotaRetryAfterSeconds(quotaResponse));
|
|
6706
|
+
return;
|
|
6707
|
+
}
|
|
6708
|
+
throw error;
|
|
6709
|
+
}
|
|
6710
|
+
if (isObservabilityDisabled(response)) this.enterQuotaPause(parseQuotaRetryAfterSeconds(response));
|
|
6711
|
+
}
|
|
6712
|
+
/**
|
|
6713
|
+
* Enter the quota-exhausted paused state: drop buffered events, stop the
|
|
6714
|
+
* flush timer, and start probing until the collector stops rejecting with
|
|
6715
|
+
* 402. The gate is per-org, so a signal on any publish route pauses all
|
|
6716
|
+
* five signal types.
|
|
6717
|
+
*/
|
|
6718
|
+
enterQuotaPause(retryAfterSeconds) {
|
|
6719
|
+
this.quotaProbeIntervalSeconds = retryAfterSeconds;
|
|
6720
|
+
if (this.quotaPaused) return;
|
|
6721
|
+
this.quotaPaused = true;
|
|
6722
|
+
if (this.flushTimer) {
|
|
6723
|
+
clearTimeout(this.flushTimer);
|
|
6724
|
+
this.flushTimer = null;
|
|
6725
|
+
}
|
|
6726
|
+
this.resetBuffer();
|
|
6727
|
+
this.logger.warn(`Mastra observability paused: quota exhausted, dropping telemetry and probing every ${retryAfterSeconds}s`);
|
|
6728
|
+
this.scheduleQuotaProbe();
|
|
6729
|
+
}
|
|
6730
|
+
scheduleQuotaProbe() {
|
|
6731
|
+
if (this.shuttingDown) return;
|
|
6732
|
+
if (this.quotaProbeTimer) clearTimeout(this.quotaProbeTimer);
|
|
6733
|
+
this.quotaProbeTimer = setTimeout(() => {
|
|
6734
|
+
this.quotaProbeTimer = null;
|
|
6735
|
+
this.probeQuotaStatus();
|
|
6736
|
+
}, this.quotaProbeIntervalSeconds * 1e3);
|
|
6737
|
+
this.quotaProbeTimer.unref?.();
|
|
6738
|
+
}
|
|
6739
|
+
/**
|
|
6740
|
+
* Send an empty spans batch as a free probe. The collector treats an empty
|
|
6741
|
+
* batch as a no-op, and an exhausted org still gets the 402 on it. A 402
|
|
6742
|
+
* throws out of fetchWithRetry without the Response, so the retry predicate
|
|
6743
|
+
* captures it to keep the retry-after hint.
|
|
6744
|
+
*/
|
|
6745
|
+
async probeQuotaStatus() {
|
|
6746
|
+
if (this.shuttingDown || !this.quotaPaused) return;
|
|
6747
|
+
let quotaResponse;
|
|
6748
|
+
try {
|
|
6749
|
+
const response = await (0, _mastra_core_utils.fetchWithRetry)(this.platformConfig.tracesEndpoint, {
|
|
6750
|
+
method: "POST",
|
|
6751
|
+
headers: this.buildPublishHeaders(),
|
|
6752
|
+
body: this.buildPublishBody("traces", [])
|
|
6753
|
+
}, 1, { shouldRetryResponse: (res) => {
|
|
6754
|
+
if (isQuotaExceededResponse(res)) quotaResponse = res;
|
|
6755
|
+
return false;
|
|
6756
|
+
} });
|
|
6757
|
+
if (this.shuttingDown) return;
|
|
6758
|
+
if (!isObservabilityDisabled(response)) {
|
|
6759
|
+
this.quotaPaused = false;
|
|
6760
|
+
this.quotaProbeIntervalSeconds = DEFAULT_QUOTA_PROBE_INTERVAL_SECONDS;
|
|
6761
|
+
this.logger.warn("Mastra observability resumed: quota restored, exports re-enabled");
|
|
6762
|
+
return;
|
|
6763
|
+
}
|
|
6764
|
+
this.quotaProbeIntervalSeconds = parseQuotaRetryAfterSeconds(response);
|
|
6765
|
+
} catch {
|
|
6766
|
+
if (quotaResponse) this.quotaProbeIntervalSeconds = parseQuotaRetryAfterSeconds(quotaResponse);
|
|
6767
|
+
}
|
|
6768
|
+
this.scheduleQuotaProbe();
|
|
6662
6769
|
}
|
|
6663
6770
|
async flushSignalBatch(signal, records) {
|
|
6664
6771
|
if (records.length === 0) return {
|
|
@@ -6726,11 +6833,16 @@ var MastraPlatformExporter = class extends BaseExporter {
|
|
|
6726
6833
|
}
|
|
6727
6834
|
}
|
|
6728
6835
|
async shutdown() {
|
|
6836
|
+
this.shuttingDown = true;
|
|
6729
6837
|
if (this.isDisabled) return;
|
|
6730
6838
|
if (this.flushTimer) {
|
|
6731
6839
|
clearTimeout(this.flushTimer);
|
|
6732
6840
|
this.flushTimer = null;
|
|
6733
6841
|
}
|
|
6842
|
+
if (this.quotaProbeTimer) {
|
|
6843
|
+
clearTimeout(this.quotaProbeTimer);
|
|
6844
|
+
this.quotaProbeTimer = null;
|
|
6845
|
+
}
|
|
6734
6846
|
try {
|
|
6735
6847
|
await this.flush();
|
|
6736
6848
|
} catch (error) {
|