@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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # @mastra/observability
2
2
 
3
+ ## 1.5.1-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixed span serialization to avoid incorrect [Circular] placeholders in traces. ([#14263](https://github.com/mastra-ai/mastra/pull/14263))
8
+
9
+ - Updated dependencies [[`cb611a1`](https://github.com/mastra-ai/mastra/commit/cb611a1e89a4f4cf74c97b57e0c27bb56f2eceb5), [`62d1d3c`](https://github.com/mastra-ai/mastra/commit/62d1d3cc08fe8182e7080237fd975de862ec8c91), [`8681ecb`](https://github.com/mastra-ai/mastra/commit/8681ecb86184d5907267000e4576cc442a9a83fc), [`28d0249`](https://github.com/mastra-ai/mastra/commit/28d0249295782277040ad1e0d243e695b7ab1ce4), [`bb0f09d`](https://github.com/mastra-ai/mastra/commit/bb0f09dbac58401b36069f483acf5673202db5b5), [`5f7e9d0`](https://github.com/mastra-ai/mastra/commit/5f7e9d0db664020e1f3d97d7d18c6b0b9d4843d0)]:
10
+ - @mastra/core@1.15.0-alpha.0
11
+
3
12
  ## 1.5.0
4
13
 
5
14
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -17950,6 +17950,17 @@ function compressJsonSchema(schema, depth = 0) {
17950
17950
  if (depth > 3) {
17951
17951
  return schema.type || "object";
17952
17952
  }
17953
+ const compositionKeys = ["oneOf", "anyOf", "allOf"].filter((key) => Array.isArray(schema[key]));
17954
+ if (compositionKeys.length > 0) {
17955
+ const compressed2 = {};
17956
+ for (const key of compositionKeys) {
17957
+ compressed2[key] = schema[key].map((entry) => compressJsonSchema(entry, depth + 1));
17958
+ }
17959
+ if (typeof schema.type === "string") {
17960
+ compressed2.type = schema.type;
17961
+ }
17962
+ return compressed2;
17963
+ }
17953
17964
  if (schema.type !== "object" || !schema.properties) {
17954
17965
  return schema.type || schema;
17955
17966
  }
@@ -17983,7 +17994,7 @@ function compressJsonSchema(schema, depth = 0) {
17983
17994
  function deepClean(value, options = DEFAULT_DEEP_CLEAN_OPTIONS) {
17984
17995
  const { keysToStrip, maxDepth, maxStringLength, maxArrayLength, maxObjectKeys } = options;
17985
17996
  const stripSet = keysToStrip instanceof Set ? keysToStrip : new Set(Array.isArray(keysToStrip) ? keysToStrip : Object.keys(keysToStrip));
17986
- const seen = /* @__PURE__ */ new WeakSet();
17997
+ const ancestors = /* @__PURE__ */ new WeakSet();
17987
17998
  function helper(val, depth) {
17988
17999
  if (depth > maxDepth) {
17989
18000
  return "[MaxDepth]";
@@ -18016,59 +18027,85 @@ function deepClean(value, options = DEFAULT_DEEP_CLEAN_OPTIONS) {
18016
18027
  };
18017
18028
  }
18018
18029
  if (typeof val === "object") {
18019
- if (seen.has(val)) {
18030
+ if (ancestors.has(val)) {
18020
18031
  return "[Circular]";
18021
18032
  }
18022
- seen.add(val);
18033
+ ancestors.add(val);
18023
18034
  }
18024
- if (Array.isArray(val)) {
18025
- const limitedArray = val.slice(0, maxArrayLength);
18026
- const cleaned2 = limitedArray.map((item) => helper(item, depth + 1));
18027
- if (val.length > maxArrayLength) {
18028
- cleaned2.push(`[\u2026${val.length - maxArrayLength} more items]`);
18035
+ try {
18036
+ if (Array.isArray(val)) {
18037
+ const cleaned2 = [];
18038
+ for (let i = 0; i < Math.min(val.length, maxArrayLength); i++) {
18039
+ try {
18040
+ cleaned2.push(helper(val[i], depth + 1));
18041
+ } catch (error48) {
18042
+ cleaned2.push(`[${error48 instanceof Error ? truncateString(error48.message, 256) : "unknown error"}]`);
18043
+ }
18044
+ }
18045
+ if (val.length > maxArrayLength) {
18046
+ cleaned2.push(`[\u2026${val.length - maxArrayLength} more items]`);
18047
+ }
18048
+ return cleaned2;
18029
18049
  }
18030
- return cleaned2;
18031
- }
18032
- if (typeof Buffer !== "undefined" && Buffer.isBuffer(val)) {
18033
- return `[Buffer length=${val.length}]`;
18034
- }
18035
- if (ArrayBuffer.isView(val)) {
18036
- const ctor = val.constructor?.name ?? "TypedArray";
18037
- const byteLength = val.byteLength ?? "?";
18038
- return `[${ctor} byteLength=${byteLength}]`;
18039
- }
18040
- if (val instanceof ArrayBuffer) {
18041
- return `[ArrayBuffer byteLength=${val.byteLength}]`;
18042
- }
18043
- if (typeof val.serializeForSpan === "function") {
18044
- try {
18045
- return helper(val.serializeForSpan(), depth);
18046
- } catch {
18050
+ if (typeof Buffer !== "undefined" && Buffer.isBuffer(val)) {
18051
+ return `[Buffer length=${val.length}]`;
18047
18052
  }
18048
- }
18049
- if (isJsonSchema(val)) {
18050
- return helper(compressJsonSchema(val), depth);
18051
- }
18052
- const cleaned = {};
18053
- const entries = Object.entries(val);
18054
- let keyCount = 0;
18055
- for (const [key, v] of entries) {
18056
- if (stripSet.has(key)) {
18057
- continue;
18053
+ if (ArrayBuffer.isView(val)) {
18054
+ const ctor = val.constructor?.name ?? "TypedArray";
18055
+ const byteLength = val.byteLength ?? "?";
18056
+ return `[${ctor} byteLength=${byteLength}]`;
18058
18057
  }
18059
- if (keyCount >= maxObjectKeys) {
18060
- cleaned["__truncated"] = `${entries.length - keyCount} more keys omitted`;
18061
- break;
18058
+ if (val instanceof ArrayBuffer) {
18059
+ return `[ArrayBuffer byteLength=${val.byteLength}]`;
18062
18060
  }
18061
+ let serializeForSpan;
18063
18062
  try {
18064
- cleaned[key] = helper(v, depth + 1);
18065
- keyCount++;
18063
+ serializeForSpan = val.serializeForSpan;
18066
18064
  } catch (error48) {
18067
- cleaned[key] = `[${error48 instanceof Error ? error48.message : String(error48)}]`;
18068
- keyCount++;
18065
+ return `[serializeForSpan failed: ${error48 instanceof Error ? truncateString(error48.message, 256) : "unknown error"}]`;
18066
+ }
18067
+ if (typeof serializeForSpan === "function") {
18068
+ try {
18069
+ return helper(serializeForSpan.call(val), depth);
18070
+ } catch (error48) {
18071
+ return `[serializeForSpan failed: ${error48 instanceof Error ? truncateString(error48.message, 256) : "unknown error"}]`;
18072
+ }
18073
+ }
18074
+ let looksLikeJsonSchema = false;
18075
+ try {
18076
+ looksLikeJsonSchema = isJsonSchema(val);
18077
+ } catch {
18078
+ looksLikeJsonSchema = false;
18079
+ }
18080
+ if (looksLikeJsonSchema) {
18081
+ try {
18082
+ const compressed = compressJsonSchema(val);
18083
+ return compressed === val ? "[JSONSchema]" : helper(compressed, depth);
18084
+ } catch {
18085
+ }
18086
+ }
18087
+ const cleaned = {};
18088
+ const keys = Object.keys(val).filter((key) => !stripSet.has(key));
18089
+ let keyCount = 0;
18090
+ for (const key of keys) {
18091
+ if (keyCount >= maxObjectKeys) {
18092
+ cleaned["__truncated"] = `${keys.length - keyCount} more keys omitted`;
18093
+ break;
18094
+ }
18095
+ try {
18096
+ cleaned[key] = helper(val[key], depth + 1);
18097
+ keyCount++;
18098
+ } catch (error48) {
18099
+ cleaned[key] = `[${error48 instanceof Error ? truncateString(error48.message, 256) : "unknown error"}]`;
18100
+ keyCount++;
18101
+ }
18102
+ }
18103
+ return cleaned;
18104
+ } finally {
18105
+ if (typeof val === "object" && val !== null) {
18106
+ ancestors.delete(val);
18069
18107
  }
18070
18108
  }
18071
- return cleaned;
18072
18109
  }
18073
18110
  return helper(value, 0);
18074
18111
  }