@mastra/observability 1.14.0 → 1.14.1-alpha.1
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 +22 -0
- package/dist/index.cjs +45 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +45 -12
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @mastra/observability
|
|
2
2
|
|
|
3
|
+
## 1.14.1-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Added support for costs supplied by external SDK agent integrations. ([#16906](https://github.com/mastra-ai/mastra/pull/16906))
|
|
8
|
+
|
|
9
|
+
When an SDK agent records an estimated cost on its model generation span, observability now carries that cost onto the auto-extracted model token metric. This lets storage-backed metric queries and dashboards display costs reported by external agent SDKs, even when Mastra cannot calculate the cost from its own pricing registry.
|
|
10
|
+
|
|
11
|
+
- Updated dependencies:
|
|
12
|
+
- @mastra/core@1.38.0-alpha.7
|
|
13
|
+
|
|
14
|
+
## 1.14.1-alpha.0
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Added documentation explaining how to query and retrieve metric data from Mastra's observability store. Developers can now learn how to aggregate metrics, break them down by labels, visualize time series, and calculate percentiles using the in-process store API, HTTP endpoints, or CLI commands. ([#17178](https://github.com/mastra-ai/mastra/pull/17178))
|
|
19
|
+
|
|
20
|
+
- Fix null `estimatedCost` for OpenRouter models whose id carries a vendor prefix and a dotted version (e.g. `google/gemini-2.5-flash`). These previously failed to match the pricing data (`gemini-2-5-flash`), leaving cost unreported in Studio's "Total Model Cost". Cost is now estimated correctly for these routes. ([#17140](https://github.com/mastra-ai/mastra/pull/17140))
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [[`8ace89d`](https://github.com/mastra-ai/mastra/commit/8ace89df77f762e622d3b9f7f65ad7524350d050), [`fa63872`](https://github.com/mastra-ai/mastra/commit/fa6387280954e6b667bec5714b55ba082bc627ff), [`f07b646`](https://github.com/mastra-ai/mastra/commit/f07b64604ab7d25391179790b7fd4823df9e2dff), [`d8838ae`](https://github.com/mastra-ai/mastra/commit/d8838ae80b69780361693d27098f7f6684af12fe), [`40f9297`](https://github.com/mastra-ai/mastra/commit/40f9297003b921c62373d3e8d3a4bda76c9f6de3), [`0f0d1ba`](https://github.com/mastra-ai/mastra/commit/0f0d1ba67bfcb2204e571401662f1eceefc03357), [`8c31bcd`](https://github.com/mastra-ai/mastra/commit/8c31bcdb00e597880d5939b1b7d7566fbe5dacae), [`95b14cd`](https://github.com/mastra-ai/mastra/commit/95b14cdd820e86d97ac05fe568424c513a252e31), [`aa36be2`](https://github.com/mastra-ai/mastra/commit/aa36be23aa513b7dc53cb8ca16b7fab8f20e43ad), [`212c635`](https://github.com/mastra-ai/mastra/commit/212c635203e61d036ab41db8ff86c3893dc795b3), [`d8838ae`](https://github.com/mastra-ai/mastra/commit/d8838ae80b69780361693d27098f7f6684af12fe), [`9aa5a73`](https://github.com/mastra-ai/mastra/commit/9aa5a73e7e110f6e9365eec69364a33d5f03bb56), [`f73c789`](https://github.com/mastra-ai/mastra/commit/f73c789e8ef21561580395d2c410119cab5848c8), [`8bd16da`](https://github.com/mastra-ai/mastra/commit/8bd16da73a4cb874d739373643dbd6a6e7f88684), [`c8630f8`](https://github.com/mastra-ai/mastra/commit/c8630f80d4f40cb5d22e60ab162b618b1907167a), [`47f71dc`](https://github.com/mastra-ai/mastra/commit/47f71dc6fbcbd12d71e21a979e676e20a02bd77d), [`50ceae2`](https://github.com/mastra-ai/mastra/commit/50ceae270878e2f8fb2b2c6c2faab09df0007c8a), [`8cdde58`](https://github.com/mastra-ai/mastra/commit/8cdde5875bbba6702d9df226f2b20232b8d75d6c), [`847ff1e`](https://github.com/mastra-ai/mastra/commit/847ff1e0d94368d94b2e173e4e0908e115568ef3), [`259d409`](https://github.com/mastra-ai/mastra/commit/259d409a514174299dbde1ff5e1121209b3ba850), [`9e16c68`](https://github.com/mastra-ai/mastra/commit/9e16c6818b6485ccb43df28aba6f3a2219d28662), [`cefca33`](https://github.com/mastra-ai/mastra/commit/cefca33ae666e69810c935fedf95a929c173d1d7), [`d00e8c5`](https://github.com/mastra-ai/mastra/commit/d00e8c50daebe5bce5bf2f48bde39c86fc3d2fe4), [`36fa7e2`](https://github.com/mastra-ai/mastra/commit/36fa7e24d14e58a1eb46147097b32f583e5b8775), [`87e9774`](https://github.com/mastra-ai/mastra/commit/87e97741c1e493cd6d62f478eb810b49bda4d57c), [`65a72e7`](https://github.com/mastra-ai/mastra/commit/65a72e70c25eedea8ff985a6624b96be2850236b), [`0f77241`](https://github.com/mastra-ai/mastra/commit/0f7724108806703799a8ba80ad0f09414afd5066), [`92ff509`](https://github.com/mastra-ai/mastra/commit/92ff5098ef8a990438ca038077021a5f7541ec1d), [`3fce5e7`](https://github.com/mastra-ai/mastra/commit/3fce5e70d011d289043e75003ef3336ed4aa43c3), [`a763592`](https://github.com/mastra-ai/mastra/commit/a763592c3db46963ef1011cfe16fe372816e775e), [`80c7737`](https://github.com/mastra-ai/mastra/commit/80c7737e32d7917b5f356957d67c169d01744fd3), [`3f1cf47`](https://github.com/mastra-ai/mastra/commit/3f1cf476f74c1e4cc2df908837e05853a5347e31)]:
|
|
23
|
+
- @mastra/core@1.38.0-alpha.3
|
|
24
|
+
|
|
3
25
|
## 1.14.0
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -1145,7 +1145,9 @@ function getModelVariants(model) {
|
|
|
1145
1145
|
add(model.replace(/[./]/g, "-"));
|
|
1146
1146
|
const slashIndex = model.indexOf("/");
|
|
1147
1147
|
if (slashIndex !== -1) {
|
|
1148
|
-
|
|
1148
|
+
const withoutVendor = model.substring(slashIndex + 1);
|
|
1149
|
+
add(withoutVendor);
|
|
1150
|
+
add(withoutVendor.replace(/\./g, "-"));
|
|
1149
1151
|
}
|
|
1150
1152
|
return [...variants];
|
|
1151
1153
|
}
|
|
@@ -1436,18 +1438,23 @@ function emitAutoExtractedMetrics(span, metrics) {
|
|
|
1436
1438
|
}
|
|
1437
1439
|
function emitUsageMetrics(attrs, usage, metrics) {
|
|
1438
1440
|
let metricCosts = /* @__PURE__ */ new Map();
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1441
|
+
const providedCostContext = getProvidedCostContext(attrs, usage);
|
|
1442
|
+
if (providedCostContext) {
|
|
1443
|
+
metricCosts = providedCostContext;
|
|
1444
|
+
} else {
|
|
1445
|
+
try {
|
|
1446
|
+
const provider = attrs.provider;
|
|
1447
|
+
const model = attrs.responseModel ?? attrs.model;
|
|
1448
|
+
if (provider && model) {
|
|
1449
|
+
metricCosts = estimateCosts({
|
|
1450
|
+
provider,
|
|
1451
|
+
model,
|
|
1452
|
+
usage
|
|
1453
|
+
});
|
|
1454
|
+
}
|
|
1455
|
+
} catch {
|
|
1456
|
+
metricCosts = /* @__PURE__ */ new Map();
|
|
1448
1457
|
}
|
|
1449
|
-
} catch {
|
|
1450
|
-
metricCosts = /* @__PURE__ */ new Map();
|
|
1451
1458
|
}
|
|
1452
1459
|
const emit = (name, value) => {
|
|
1453
1460
|
const costContext = metricCosts.get(name);
|
|
@@ -1461,6 +1468,32 @@ function emitUsageMetrics(attrs, usage, metrics) {
|
|
|
1461
1468
|
emit(sample.name, sample.value);
|
|
1462
1469
|
}
|
|
1463
1470
|
}
|
|
1471
|
+
function getProvidedCostContext(attrs, usage) {
|
|
1472
|
+
const costContext = attrs.costContext;
|
|
1473
|
+
if (typeof costContext?.estimatedCost !== "number") {
|
|
1474
|
+
return void 0;
|
|
1475
|
+
}
|
|
1476
|
+
const carrierMetric = usage.inputTokens !== void 0 ? TokenMetrics.TOTAL_INPUT : TokenMetrics.TOTAL_OUTPUT;
|
|
1477
|
+
const provider = costContext.provider ?? attrs.provider;
|
|
1478
|
+
const model = costContext.model ?? attrs.responseModel ?? attrs.model;
|
|
1479
|
+
const contexts = /* @__PURE__ */ new Map();
|
|
1480
|
+
for (const sample of getTokenMetricSamples(usage)) {
|
|
1481
|
+
contexts.set(sample.name, {
|
|
1482
|
+
provider,
|
|
1483
|
+
model
|
|
1484
|
+
});
|
|
1485
|
+
}
|
|
1486
|
+
contexts.set(carrierMetric, {
|
|
1487
|
+
...costContext,
|
|
1488
|
+
provider,
|
|
1489
|
+
model,
|
|
1490
|
+
costMetadata: {
|
|
1491
|
+
...costContext.costMetadata,
|
|
1492
|
+
allocation: "query_total"
|
|
1493
|
+
}
|
|
1494
|
+
});
|
|
1495
|
+
return contexts;
|
|
1496
|
+
}
|
|
1464
1497
|
function getDurationMetricName(span) {
|
|
1465
1498
|
switch (span.type) {
|
|
1466
1499
|
case observability.SpanType.AGENT_RUN:
|