@mastra/observability 1.7.1 → 1.7.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 +11 -0
- package/dist/index.cjs +6 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/usage.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -17883,6 +17883,9 @@ var CardinalityFilter = class {
|
|
|
17883
17883
|
};
|
|
17884
17884
|
|
|
17885
17885
|
// src/usage.ts
|
|
17886
|
+
function isV3RawUsage(raw) {
|
|
17887
|
+
return typeof raw === "object" && raw !== null && "inputTokens" in raw;
|
|
17888
|
+
}
|
|
17886
17889
|
function isDefined(value) {
|
|
17887
17890
|
return value != null;
|
|
17888
17891
|
}
|
|
@@ -17909,13 +17912,15 @@ function extractUsageMetrics(usage, providerMetadata) {
|
|
|
17909
17912
|
}
|
|
17910
17913
|
const anthropic = providerMetadata?.anthropic;
|
|
17911
17914
|
if (anthropic) {
|
|
17915
|
+
const rawV3InputUsage = isV3RawUsage(usage.raw) ? usage.raw.inputTokens : void 0;
|
|
17916
|
+
const hasV3CachedTotals = rawV3InputUsage?.total !== void 0 && (rawV3InputUsage.cacheRead !== void 0 || rawV3InputUsage.cacheWrite !== void 0);
|
|
17912
17917
|
if (!isDefined(inputDetails.cacheRead) && isDefined(anthropic.cacheReadInputTokens)) {
|
|
17913
17918
|
inputDetails.cacheRead = anthropic.cacheReadInputTokens;
|
|
17914
17919
|
}
|
|
17915
17920
|
if (!isDefined(inputDetails.cacheWrite) && isDefined(anthropic.cacheCreationInputTokens)) {
|
|
17916
17921
|
inputDetails.cacheWrite = anthropic.cacheCreationInputTokens;
|
|
17917
17922
|
}
|
|
17918
|
-
if (isDefined(inputDetails.cacheRead) || isDefined(inputDetails.cacheWrite)) {
|
|
17923
|
+
if (!hasV3CachedTotals && (isDefined(inputDetails.cacheRead) || isDefined(inputDetails.cacheWrite))) {
|
|
17919
17924
|
inputTokens = (usage.inputTokens ?? 0) + (inputDetails.cacheRead ?? 0) + (inputDetails.cacheWrite ?? 0);
|
|
17920
17925
|
}
|
|
17921
17926
|
}
|