@mastra/observability 1.16.1-alpha.0 → 1.16.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 +11 -0
- package/dist/index.cjs +21 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -2
- package/dist/index.js.map +1 -1
- package/dist/metrics/pricing-registry.d.ts.map +1 -1
- package/dist/spans/base.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -998,6 +998,7 @@ var PricingModel = class {
|
|
|
998
998
|
|
|
999
999
|
// src/metrics/pricing-registry.ts
|
|
1000
1000
|
var DATA_FILE_NAME = "pricing-data.jsonl";
|
|
1001
|
+
var BEDROCK_GEOGRAPHY_PREFIXES = /* @__PURE__ */ new Set(["global", "us", "eu", "apac", "jp", "au"]);
|
|
1001
1002
|
var MINIFIED_METER_TO_CANONICAL = {
|
|
1002
1003
|
it: "input_tokens",
|
|
1003
1004
|
ot: "output_tokens",
|
|
@@ -1032,7 +1033,7 @@ var PricingRegistry = class _PricingRegistry {
|
|
|
1032
1033
|
return _PricingRegistry.globalRegistry;
|
|
1033
1034
|
}
|
|
1034
1035
|
get(args) {
|
|
1035
|
-
const variants = getModelVariants(args.model);
|
|
1036
|
+
const variants = getModelVariants(args.model, normalizeProvider(args.provider));
|
|
1036
1037
|
for (const variant of variants) {
|
|
1037
1038
|
const key = makePricingKey({ provider: args.provider, model: variant });
|
|
1038
1039
|
const match = this.pricingModels.get(key);
|
|
@@ -1126,7 +1127,7 @@ function normalizeProvider(provider) {
|
|
|
1126
1127
|
const dotIndex = normalized.indexOf(".");
|
|
1127
1128
|
return dotIndex !== -1 ? normalized.substring(0, dotIndex) : normalized;
|
|
1128
1129
|
}
|
|
1129
|
-
function getModelVariants(model) {
|
|
1130
|
+
function getModelVariants(model, provider) {
|
|
1130
1131
|
const variants = /* @__PURE__ */ new Set();
|
|
1131
1132
|
const add = (v) => {
|
|
1132
1133
|
variants.add(v);
|
|
@@ -1141,6 +1142,22 @@ function getModelVariants(model) {
|
|
|
1141
1142
|
add(withoutVendor);
|
|
1142
1143
|
add(withoutVendor.replace(/\./g, "-"));
|
|
1143
1144
|
}
|
|
1145
|
+
if (provider === "amazon-bedrock") {
|
|
1146
|
+
const addBedrockVariant = (v) => {
|
|
1147
|
+
add(v);
|
|
1148
|
+
add(v.replace(/-(?:v)?\d+(?::\d+)?$/, ""));
|
|
1149
|
+
};
|
|
1150
|
+
const segments = model.split(".");
|
|
1151
|
+
const withoutGeography = BEDROCK_GEOGRAPHY_PREFIXES.has(segments[0] ?? "") ? segments.slice(1).join(".") : model;
|
|
1152
|
+
addBedrockVariant(withoutGeography);
|
|
1153
|
+
addBedrockVariant(withoutGeography.replace(/\./g, "-"));
|
|
1154
|
+
const vendorSeparator = withoutGeography.indexOf(".");
|
|
1155
|
+
if (vendorSeparator !== -1) {
|
|
1156
|
+
const withoutVendor = withoutGeography.substring(vendorSeparator + 1);
|
|
1157
|
+
addBedrockVariant(withoutVendor);
|
|
1158
|
+
addBedrockVariant(withoutVendor.replace(/\./g, "-"));
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1144
1161
|
return [...variants];
|
|
1145
1162
|
}
|
|
1146
1163
|
function stripDateSuffix(model) {
|
|
@@ -1505,6 +1522,7 @@ function getDurationMetricName(span) {
|
|
|
1505
1522
|
return "mastra_agent_duration_ms";
|
|
1506
1523
|
case SpanType.TOOL_CALL:
|
|
1507
1524
|
case SpanType.MCP_TOOL_CALL:
|
|
1525
|
+
case SpanType.PROVIDER_TOOL_CALL:
|
|
1508
1526
|
return "mastra_tool_duration_ms";
|
|
1509
1527
|
case SpanType.CLIENT_TOOL_CALL:
|
|
1510
1528
|
return null;
|
|
@@ -2464,6 +2482,7 @@ function isSpanInternal(spanType, flags) {
|
|
|
2464
2482
|
// Tool-related spans
|
|
2465
2483
|
case SpanType.TOOL_CALL:
|
|
2466
2484
|
case SpanType.MCP_TOOL_CALL:
|
|
2485
|
+
case SpanType.PROVIDER_TOOL_CALL:
|
|
2467
2486
|
return (flags & InternalSpans.TOOL) !== 0;
|
|
2468
2487
|
// Model-related spans
|
|
2469
2488
|
case SpanType.MODEL_GENERATION:
|