@mastra/observability 1.19.0-alpha.0 → 1.19.0-alpha.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
@@ -1041,6 +1041,7 @@ var MetricsContextImpl = class {
1041
1041
  labels: filteredLabels,
1042
1042
  correlationContext: this.correlationContext,
1043
1043
  costContext,
1044
+ ...options?.usageId ? { usageId: options.usageId } : {},
1044
1045
  metadata: this.metadata
1045
1046
  }
1046
1047
  };
@@ -1577,7 +1578,7 @@ function estimateCosts(args, pricingRegistry = PricingRegistry.getGlobal()) {
1577
1578
  }
1578
1579
  if (usage.outputDetails?.reasoning) {
1579
1580
  const result = estimateCostForMeter({
1580
- meter: PricingMeter.OUTPUT_REASONING_TOKENS,
1581
+ meter: pricingTier.hasMatchingMeterForUsage(PricingMeter.OUTPUT_REASONING_TOKENS) ? PricingMeter.OUTPUT_REASONING_TOKENS : PricingMeter.OUTPUT_TOKENS,
1581
1582
  tokenCount: usage.outputDetails.reasoning,
1582
1583
  ...estimateFields
1583
1584
  });
@@ -1742,13 +1743,13 @@ function emitUsageMetrics(attrs, usage, metrics) {
1742
1743
  metricCosts = /* @__PURE__ */ new Map();
1743
1744
  }
1744
1745
  const labels = attrs.usageIncomplete ? { usageIncomplete: "true" } : void 0;
1746
+ const usageId = generateSignalId();
1745
1747
  const emit = (name, value) => {
1746
1748
  const costContext = metricCosts.get(name);
1747
- if (!costContext) {
1748
- metrics.emit(name, value, labels);
1749
- return;
1750
- }
1751
- metrics.emit(name, value, labels, { costContext });
1749
+ metrics.emit(name, value, labels, costContext ? {
1750
+ costContext,
1751
+ usageId
1752
+ } : { usageId });
1752
1753
  };
1753
1754
  for (const sample of getTokenMetricSamples(usage)) emit(sample.name, sample.value);
1754
1755
  }