@mastra/observability 1.15.2-alpha.0 → 1.15.2

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/dist/index.js CHANGED
@@ -1443,6 +1443,16 @@ function emitUsageMetrics(attrs, usage, metrics) {
1443
1443
  model,
1444
1444
  usage
1445
1445
  });
1446
+ if (isNoMatchingModelResult(metricCosts) && attrs.model && attrs.model !== model) {
1447
+ const configuredModelCosts = estimateCosts({
1448
+ provider,
1449
+ model: attrs.model,
1450
+ usage
1451
+ });
1452
+ if (!isNoMatchingModelResult(configuredModelCosts)) {
1453
+ metricCosts = configuredModelCosts;
1454
+ }
1455
+ }
1446
1456
  }
1447
1457
  } catch {
1448
1458
  metricCosts = /* @__PURE__ */ new Map();
@@ -1460,6 +1470,9 @@ function emitUsageMetrics(attrs, usage, metrics) {
1460
1470
  emit(sample.name, sample.value);
1461
1471
  }
1462
1472
  }
1473
+ function isNoMatchingModelResult(metricCosts) {
1474
+ return metricCosts.size > 0 && [...metricCosts.values()].every((costContext) => costContext.costMetadata?.error === "no_matching_model");
1475
+ }
1463
1476
  function getProvidedCostContext(attrs, usage) {
1464
1477
  const costContext = attrs.costContext;
1465
1478
  if (typeof costContext?.estimatedCost !== "number") {