@mastra/observability 1.5.0 → 1.5.1-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 +9 -0
- package/dist/index.cjs +80 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +80 -43
- package/dist/index.js.map +1 -1
- package/dist/spans/serialization.d.ts.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -17947,6 +17947,17 @@ function compressJsonSchema(schema, depth = 0) {
|
|
|
17947
17947
|
if (depth > 3) {
|
|
17948
17948
|
return schema.type || "object";
|
|
17949
17949
|
}
|
|
17950
|
+
const compositionKeys = ["oneOf", "anyOf", "allOf"].filter((key) => Array.isArray(schema[key]));
|
|
17951
|
+
if (compositionKeys.length > 0) {
|
|
17952
|
+
const compressed2 = {};
|
|
17953
|
+
for (const key of compositionKeys) {
|
|
17954
|
+
compressed2[key] = schema[key].map((entry) => compressJsonSchema(entry, depth + 1));
|
|
17955
|
+
}
|
|
17956
|
+
if (typeof schema.type === "string") {
|
|
17957
|
+
compressed2.type = schema.type;
|
|
17958
|
+
}
|
|
17959
|
+
return compressed2;
|
|
17960
|
+
}
|
|
17950
17961
|
if (schema.type !== "object" || !schema.properties) {
|
|
17951
17962
|
return schema.type || schema;
|
|
17952
17963
|
}
|
|
@@ -17980,7 +17991,7 @@ function compressJsonSchema(schema, depth = 0) {
|
|
|
17980
17991
|
function deepClean(value, options = DEFAULT_DEEP_CLEAN_OPTIONS) {
|
|
17981
17992
|
const { keysToStrip, maxDepth, maxStringLength, maxArrayLength, maxObjectKeys } = options;
|
|
17982
17993
|
const stripSet = keysToStrip instanceof Set ? keysToStrip : new Set(Array.isArray(keysToStrip) ? keysToStrip : Object.keys(keysToStrip));
|
|
17983
|
-
const
|
|
17994
|
+
const ancestors = /* @__PURE__ */ new WeakSet();
|
|
17984
17995
|
function helper(val, depth) {
|
|
17985
17996
|
if (depth > maxDepth) {
|
|
17986
17997
|
return "[MaxDepth]";
|
|
@@ -18013,59 +18024,85 @@ function deepClean(value, options = DEFAULT_DEEP_CLEAN_OPTIONS) {
|
|
|
18013
18024
|
};
|
|
18014
18025
|
}
|
|
18015
18026
|
if (typeof val === "object") {
|
|
18016
|
-
if (
|
|
18027
|
+
if (ancestors.has(val)) {
|
|
18017
18028
|
return "[Circular]";
|
|
18018
18029
|
}
|
|
18019
|
-
|
|
18030
|
+
ancestors.add(val);
|
|
18020
18031
|
}
|
|
18021
|
-
|
|
18022
|
-
|
|
18023
|
-
|
|
18024
|
-
|
|
18025
|
-
|
|
18032
|
+
try {
|
|
18033
|
+
if (Array.isArray(val)) {
|
|
18034
|
+
const cleaned2 = [];
|
|
18035
|
+
for (let i = 0; i < Math.min(val.length, maxArrayLength); i++) {
|
|
18036
|
+
try {
|
|
18037
|
+
cleaned2.push(helper(val[i], depth + 1));
|
|
18038
|
+
} catch (error48) {
|
|
18039
|
+
cleaned2.push(`[${error48 instanceof Error ? truncateString(error48.message, 256) : "unknown error"}]`);
|
|
18040
|
+
}
|
|
18041
|
+
}
|
|
18042
|
+
if (val.length > maxArrayLength) {
|
|
18043
|
+
cleaned2.push(`[\u2026${val.length - maxArrayLength} more items]`);
|
|
18044
|
+
}
|
|
18045
|
+
return cleaned2;
|
|
18026
18046
|
}
|
|
18027
|
-
|
|
18028
|
-
|
|
18029
|
-
if (typeof Buffer !== "undefined" && Buffer.isBuffer(val)) {
|
|
18030
|
-
return `[Buffer length=${val.length}]`;
|
|
18031
|
-
}
|
|
18032
|
-
if (ArrayBuffer.isView(val)) {
|
|
18033
|
-
const ctor = val.constructor?.name ?? "TypedArray";
|
|
18034
|
-
const byteLength = val.byteLength ?? "?";
|
|
18035
|
-
return `[${ctor} byteLength=${byteLength}]`;
|
|
18036
|
-
}
|
|
18037
|
-
if (val instanceof ArrayBuffer) {
|
|
18038
|
-
return `[ArrayBuffer byteLength=${val.byteLength}]`;
|
|
18039
|
-
}
|
|
18040
|
-
if (typeof val.serializeForSpan === "function") {
|
|
18041
|
-
try {
|
|
18042
|
-
return helper(val.serializeForSpan(), depth);
|
|
18043
|
-
} catch {
|
|
18047
|
+
if (typeof Buffer !== "undefined" && Buffer.isBuffer(val)) {
|
|
18048
|
+
return `[Buffer length=${val.length}]`;
|
|
18044
18049
|
}
|
|
18045
|
-
|
|
18046
|
-
|
|
18047
|
-
|
|
18048
|
-
|
|
18049
|
-
const cleaned = {};
|
|
18050
|
-
const entries = Object.entries(val);
|
|
18051
|
-
let keyCount = 0;
|
|
18052
|
-
for (const [key, v] of entries) {
|
|
18053
|
-
if (stripSet.has(key)) {
|
|
18054
|
-
continue;
|
|
18050
|
+
if (ArrayBuffer.isView(val)) {
|
|
18051
|
+
const ctor = val.constructor?.name ?? "TypedArray";
|
|
18052
|
+
const byteLength = val.byteLength ?? "?";
|
|
18053
|
+
return `[${ctor} byteLength=${byteLength}]`;
|
|
18055
18054
|
}
|
|
18056
|
-
if (
|
|
18057
|
-
|
|
18058
|
-
break;
|
|
18055
|
+
if (val instanceof ArrayBuffer) {
|
|
18056
|
+
return `[ArrayBuffer byteLength=${val.byteLength}]`;
|
|
18059
18057
|
}
|
|
18058
|
+
let serializeForSpan;
|
|
18060
18059
|
try {
|
|
18061
|
-
|
|
18062
|
-
keyCount++;
|
|
18060
|
+
serializeForSpan = val.serializeForSpan;
|
|
18063
18061
|
} catch (error48) {
|
|
18064
|
-
|
|
18065
|
-
|
|
18062
|
+
return `[serializeForSpan failed: ${error48 instanceof Error ? truncateString(error48.message, 256) : "unknown error"}]`;
|
|
18063
|
+
}
|
|
18064
|
+
if (typeof serializeForSpan === "function") {
|
|
18065
|
+
try {
|
|
18066
|
+
return helper(serializeForSpan.call(val), depth);
|
|
18067
|
+
} catch (error48) {
|
|
18068
|
+
return `[serializeForSpan failed: ${error48 instanceof Error ? truncateString(error48.message, 256) : "unknown error"}]`;
|
|
18069
|
+
}
|
|
18070
|
+
}
|
|
18071
|
+
let looksLikeJsonSchema = false;
|
|
18072
|
+
try {
|
|
18073
|
+
looksLikeJsonSchema = isJsonSchema(val);
|
|
18074
|
+
} catch {
|
|
18075
|
+
looksLikeJsonSchema = false;
|
|
18076
|
+
}
|
|
18077
|
+
if (looksLikeJsonSchema) {
|
|
18078
|
+
try {
|
|
18079
|
+
const compressed = compressJsonSchema(val);
|
|
18080
|
+
return compressed === val ? "[JSONSchema]" : helper(compressed, depth);
|
|
18081
|
+
} catch {
|
|
18082
|
+
}
|
|
18083
|
+
}
|
|
18084
|
+
const cleaned = {};
|
|
18085
|
+
const keys = Object.keys(val).filter((key) => !stripSet.has(key));
|
|
18086
|
+
let keyCount = 0;
|
|
18087
|
+
for (const key of keys) {
|
|
18088
|
+
if (keyCount >= maxObjectKeys) {
|
|
18089
|
+
cleaned["__truncated"] = `${keys.length - keyCount} more keys omitted`;
|
|
18090
|
+
break;
|
|
18091
|
+
}
|
|
18092
|
+
try {
|
|
18093
|
+
cleaned[key] = helper(val[key], depth + 1);
|
|
18094
|
+
keyCount++;
|
|
18095
|
+
} catch (error48) {
|
|
18096
|
+
cleaned[key] = `[${error48 instanceof Error ? truncateString(error48.message, 256) : "unknown error"}]`;
|
|
18097
|
+
keyCount++;
|
|
18098
|
+
}
|
|
18099
|
+
}
|
|
18100
|
+
return cleaned;
|
|
18101
|
+
} finally {
|
|
18102
|
+
if (typeof val === "object" && val !== null) {
|
|
18103
|
+
ancestors.delete(val);
|
|
18066
18104
|
}
|
|
18067
18105
|
}
|
|
18068
|
-
return cleaned;
|
|
18069
18106
|
}
|
|
18070
18107
|
return helper(value, 0);
|
|
18071
18108
|
}
|