@openclaw/diagnostics-otel 2026.11.5-beta.2 → 2026.11.5-beta.4

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.
@@ -39,16 +39,27 @@ function normalizeOtelErrorMessage(value) {
39
39
  function hasPreloadedOtelSdk() {
40
40
  return process.env[PRELOADED_OTEL_SDK_ENV] === "1";
41
41
  }
42
- function normalizeOtelContentValue(value) {
42
+ function createOtelContentRedactor() {
43
+ const redacted = /* @__PURE__ */ new Map();
44
+ return (value) => {
45
+ let result = redacted.get(value);
46
+ if (result === void 0) {
47
+ result = redactSensitiveText(value);
48
+ redacted.set(value, result);
49
+ }
50
+ return result;
51
+ };
52
+ }
53
+ function normalizeOtelContentValue(value, redact) {
43
54
  if (typeof value === "string") return normalizeOtelLogString(value, MAX_OTEL_CONTENT_ATTRIBUTE_CHARS);
44
55
  if (Array.isArray(value)) {
45
56
  const items = value.slice(0, 200).filter((item) => typeof item === "string");
46
57
  if (items.length > 0) return normalizeOtelLogString(items.join("\n"), MAX_OTEL_CONTENT_ATTRIBUTE_CHARS);
47
58
  }
48
- return safeJsonString(value);
59
+ return safeJsonString(value, redact);
49
60
  }
50
- function assignOtelContentAttr(attributes, key, value) {
51
- const normalized = normalizeOtelContentValue(value);
61
+ function assignOtelContentAttr(attributes, key, value, redact) {
62
+ const normalized = normalizeOtelContentValue(value, redact);
52
63
  if (normalized) attributes[key] = normalized;
53
64
  }
54
65
  const TRUNCATED_JSON_TEXT_SUFFIX = "...(truncated)";
@@ -74,34 +85,38 @@ const JSON_TRUNCATION_ARRAY_ITEM_BUDGETS = [
74
85
  ];
75
86
  const JSON_TRUNCATION_MAX_OBJECT_FIELDS = 64;
76
87
  const JSON_TRUNCATION_MAX_DEPTH = 8;
77
- function safeJsonString(value) {
88
+ const MAX_OTEL_REDACTED_JSON_CANDIDATE_CHARS = 4 * MAX_OTEL_CONTENT_ATTRIBUTE_CHARS;
89
+ function safeJsonString(value, redact = createOtelContentRedactor()) {
78
90
  if (value === void 0 || typeof value === "function" || typeof value === "symbol") return;
79
- const exact = stringifyJsonForOtelAttribute(value);
80
- if (exact && exact.length <= MAX_OTEL_CONTENT_ATTRIBUTE_CHARS) return exact;
91
+ const json = serializeJsonForOtelAttribute(value);
92
+ const exact = json && json.length <= MAX_OTEL_REDACTED_JSON_CANDIDATE_CHARS ? redactJsonWithinAttributeBudget(serializeJsonForOtelAttribute(value, redact)) : void 0;
93
+ if (exact) return exact;
81
94
  for (const maxArrayItems of JSON_TRUNCATION_ARRAY_ITEM_BUDGETS) for (const maxStringChars of JSON_TRUNCATION_STRING_BUDGETS) {
82
- const json = stringifyJsonForOtelAttribute(truncateJsonValueForOtelAttribute(value, maxArrayItems, maxStringChars));
83
- if (json && json.length <= MAX_OTEL_CONTENT_ATTRIBUTE_CHARS) return json;
95
+ const truncated = redactJsonWithinAttributeBudget(serializeJsonForOtelAttribute(truncateJsonValueForOtelAttribute(value, maxArrayItems, maxStringChars, redact)));
96
+ if (truncated) return truncated;
84
97
  }
85
- const summary = stringifyJsonForOtelAttribute({
98
+ return redactJsonWithinAttributeBudget(serializeJsonForOtelAttribute({
86
99
  truncated: true,
87
- reason: exact ? "max_attribute_size" : "unserializable_value",
100
+ reason: json ? "max_attribute_size" : "unserializable_value",
88
101
  type: describeJsonValue(value)
89
- });
90
- return summary && summary.length <= MAX_OTEL_CONTENT_ATTRIBUTE_CHARS ? summary : void 0;
102
+ }));
91
103
  }
92
- function stringifyJsonForOtelAttribute(value) {
104
+ function serializeJsonForOtelAttribute(value, redact) {
93
105
  try {
94
- const json = JSON.stringify(value);
95
- if (!json) return;
96
- return redactSensitiveText(json);
106
+ return JSON.stringify(value, redact ? (_key, field) => typeof field === "string" ? redact(field) : field : void 0) || void 0;
97
107
  } catch {
98
108
  return;
99
109
  }
100
110
  }
101
- function truncateJsonValueForOtelAttribute(input, maxArrayItems, maxStringChars) {
111
+ function redactJsonWithinAttributeBudget(json) {
112
+ if (!json || json.length > MAX_OTEL_REDACTED_JSON_CANDIDATE_CHARS) return;
113
+ const redacted = redactSensitiveText(json);
114
+ return redacted.length <= 131072 ? redacted : void 0;
115
+ }
116
+ function truncateJsonValueForOtelAttribute(input, maxArrayItems, maxStringChars, redact) {
102
117
  const seen = /* @__PURE__ */ new WeakSet();
103
118
  function visit(value, depth) {
104
- if (typeof value === "string" || typeof value === "bigint") return truncateJsonTextForOtelAttribute(String(value), maxStringChars);
119
+ if (typeof value === "string" || typeof value === "bigint") return truncateJsonTextForOtelAttribute(redact(String(value)), maxStringChars);
105
120
  if (typeof value === "number" || typeof value === "boolean" || value === null) return value;
106
121
  if (typeof value !== "object") return;
107
122
  if (depth <= 0) return {
@@ -139,8 +154,7 @@ function truncateJsonValueForOtelAttribute(input, maxArrayItems, maxStringChars)
139
154
  }
140
155
  return visit(input, JSON_TRUNCATION_MAX_DEPTH);
141
156
  }
142
- function truncateJsonTextForOtelAttribute(value, maxChars) {
143
- const redacted = redactSensitiveText(value);
157
+ function truncateJsonTextForOtelAttribute(redacted, maxChars) {
144
158
  if (redacted.length <= maxChars) return redacted;
145
159
  const suffixBudget = Math.min(14, maxChars);
146
160
  const prefixBudget = Math.max(0, maxChars - suffixBudget);
@@ -1055,6 +1069,7 @@ function redactInternalReasoningParts(value) {
1055
1069
  if (!isRecord(part)) return part;
1056
1070
  const redacted = { ...part };
1057
1071
  for (const field of INTERNAL_REASONING_PART_FIELDS) delete redacted[field];
1072
+ if (part.type === "image" && typeof part.data === "string" && part.data.length > 131072) delete redacted.data;
1058
1073
  return redacted;
1059
1074
  });
1060
1075
  }
@@ -1123,9 +1138,11 @@ function normalizeGenAiToolDefinitions(value) {
1123
1138
  }
1124
1139
  return definitions;
1125
1140
  }
1126
- function assignJsonAttribute(attributes, key, value) {
1127
- const json = safeJsonString(value);
1128
- if (json) attributes[key] = json;
1141
+ function assignJsonAttributes(attributes, keys, value, redact) {
1142
+ const json = safeJsonString(value, redact);
1143
+ if (!json) return false;
1144
+ for (const key of keys) attributes[key] = json;
1145
+ return true;
1129
1146
  }
1130
1147
  function assignOtelToolIdentityAttributes(attributes, evt) {
1131
1148
  attributes["gen_ai.operation.name"] = GEN_AI_OPERATION_NAME_VALUE_EXECUTE_TOOL;
@@ -1136,23 +1153,16 @@ function assignOtelModelContentAttributes(attributes, content, captureContent) {
1136
1153
  if (!captureContent) return;
1137
1154
  const redactedInput = redactInternalReasoningFromMessages(content?.inputMessages);
1138
1155
  const redactedOutput = redactInternalReasoningFromMessages(content?.outputMessages);
1156
+ const redact = createOtelContentRedactor();
1139
1157
  const inputMessages = normalizeGenAiMessages(redactedInput, "user");
1140
- if (inputMessages.length > 0) {
1141
- assignJsonAttribute(attributes, ATTR_GEN_AI_INPUT_MESSAGES, inputMessages);
1142
- assignJsonAttribute(attributes, "input.value", inputMessages);
1143
- attributes["input.mime_type"] = "application/json";
1144
- }
1158
+ if (inputMessages.length > 0 && assignJsonAttributes(attributes, [ATTR_GEN_AI_INPUT_MESSAGES, "input.value"], inputMessages, redact)) attributes["input.mime_type"] = "application/json";
1145
1159
  const toolDefinitions = normalizeGenAiToolDefinitions(content?.toolDefinitions);
1146
- if (toolDefinitions.length > 0) assignJsonAttribute(attributes, ATTR_GEN_AI_TOOL_DEFINITIONS, toolDefinitions);
1160
+ if (toolDefinitions.length > 0) assignJsonAttributes(attributes, [ATTR_GEN_AI_TOOL_DEFINITIONS], toolDefinitions, redact);
1147
1161
  const outputMessages = normalizeGenAiMessages(redactedOutput, "assistant");
1148
- if (outputMessages.length > 0) {
1149
- assignJsonAttribute(attributes, ATTR_GEN_AI_OUTPUT_MESSAGES, outputMessages);
1150
- assignJsonAttribute(attributes, "output.value", outputMessages);
1151
- attributes["output.mime_type"] = "application/json";
1152
- }
1153
- assignOtelContentAttr(attributes, "openclaw.content.input_messages", redactedInput);
1154
- assignOtelContentAttr(attributes, "openclaw.content.tool_definitions", content?.toolDefinitions);
1155
- assignOtelContentAttr(attributes, "openclaw.content.output_messages", redactedOutput);
1162
+ if (outputMessages.length > 0 && assignJsonAttributes(attributes, [ATTR_GEN_AI_OUTPUT_MESSAGES, "output.value"], outputMessages, redact)) attributes["output.mime_type"] = "application/json";
1163
+ assignOtelContentAttr(attributes, "openclaw.content.input_messages", redactedInput, redact);
1164
+ assignOtelContentAttr(attributes, "openclaw.content.tool_definitions", content?.toolDefinitions, redact);
1165
+ assignOtelContentAttr(attributes, "openclaw.content.output_messages", redactedOutput, redact);
1156
1166
  }
1157
1167
  function assignOtelToolContentAttributes(attributes, content, captureContent) {
1158
1168
  if (!captureContent) return;
@@ -1 +1 @@
1
- {"version":3,"entries":[{"output":"api.js","source":"extensions/diagnostics-otel/api.ts"},{"output":"index.js","source":"extensions/diagnostics-otel/index.ts"},{"output":"runtime-api.js","source":"extensions/diagnostics-otel/runtime-api.ts"}],"chunks":[{"output":".setup/runtime-api-BUbYdfto.mjs","sha256":"f46aec00ba9f3a5b0baca290b2b4f412a4a4628629f04eadbf8349db67cee61c","facadeSource":null,"sources":["extensions/diagnostics-otel/src/service-attributes.ts","extensions/diagnostics-otel/src/service-constants.ts","extensions/diagnostics-otel/src/service-content-normalization.ts","extensions/diagnostics-otel/src/service-events.ts","extensions/diagnostics-otel/src/service-exporter-health.ts","extensions/diagnostics-otel/src/service-exporter.ts","extensions/diagnostics-otel/src/service-genai-attributes.ts","extensions/diagnostics-otel/src/service-genai-content.ts","extensions/diagnostics-otel/src/service-logs.ts","extensions/diagnostics-otel/src/service-metrics.ts","extensions/diagnostics-otel/src/service-propagation.ts","extensions/diagnostics-otel/src/service-recorders-harness.ts","extensions/diagnostics-otel/src/service-recorders-model.ts","extensions/diagnostics-otel/src/service-recorders-operations.ts","extensions/diagnostics-otel/src/service-recorders-tools.ts","extensions/diagnostics-otel/src/service-recorders-usage.ts","extensions/diagnostics-otel/src/service-trace-context.ts","extensions/diagnostics-otel/src/service-traces.ts","extensions/diagnostics-otel/src/service.ts"]},{"output":"api.js","sha256":"605d6cf4480221a3ccac6ae6f372770ddff3ca620ff9688c2e669643ee4525c4","facadeSource":"extensions/diagnostics-otel/api.ts","sources":[]},{"output":"index.js","sha256":"7aed7d0879b4f47945d81025c1f3bf70df68e06433cb531cd1c610d5510efae3","facadeSource":"extensions/diagnostics-otel/index.ts","sources":["extensions/diagnostics-otel/index.ts"]},{"output":"runtime-api.js","sha256":"6590441b0a1edf5c1523d746090edf6a7514e0e31f5cf4d957c593200cd4c485","facadeSource":"extensions/diagnostics-otel/runtime-api.ts","sources":[]}],"unrenderedSources":["extensions/diagnostics-otel/api.ts","extensions/diagnostics-otel/runtime-api.ts"]}
1
+ {"version":3,"entries":[{"output":"api.js","source":"extensions/diagnostics-otel/api.ts"},{"output":"index.js","source":"extensions/diagnostics-otel/index.ts"},{"output":"runtime-api.js","source":"extensions/diagnostics-otel/runtime-api.ts"}],"chunks":[{"output":".setup/runtime-api-iB_eY9Ao.mjs","sha256":"f8831b36ab13c172cbc9e516ae144bab24d3da436f8bbc4fb6ebc456044a08b0","facadeSource":null,"sources":["extensions/diagnostics-otel/src/service-attributes.ts","extensions/diagnostics-otel/src/service-constants.ts","extensions/diagnostics-otel/src/service-content-normalization.ts","extensions/diagnostics-otel/src/service-events.ts","extensions/diagnostics-otel/src/service-exporter-health.ts","extensions/diagnostics-otel/src/service-exporter.ts","extensions/diagnostics-otel/src/service-genai-attributes.ts","extensions/diagnostics-otel/src/service-genai-content.ts","extensions/diagnostics-otel/src/service-logs.ts","extensions/diagnostics-otel/src/service-metrics.ts","extensions/diagnostics-otel/src/service-propagation.ts","extensions/diagnostics-otel/src/service-recorders-harness.ts","extensions/diagnostics-otel/src/service-recorders-model.ts","extensions/diagnostics-otel/src/service-recorders-operations.ts","extensions/diagnostics-otel/src/service-recorders-tools.ts","extensions/diagnostics-otel/src/service-recorders-usage.ts","extensions/diagnostics-otel/src/service-trace-context.ts","extensions/diagnostics-otel/src/service-traces.ts","extensions/diagnostics-otel/src/service.ts"]},{"output":"api.js","sha256":"605d6cf4480221a3ccac6ae6f372770ddff3ca620ff9688c2e669643ee4525c4","facadeSource":"extensions/diagnostics-otel/api.ts","sources":[]},{"output":"index.js","sha256":"0ff6bebd555669da1db5b33c3af9e66f20909397bc23ac2b8c76e3739ffe2421","facadeSource":"extensions/diagnostics-otel/index.ts","sources":["extensions/diagnostics-otel/index.ts"]},{"output":"runtime-api.js","sha256":"facf97b9fe5dcb84dc813877d4a5ca5acbb016236c08783ced4c911d19789de1","facadeSource":"extensions/diagnostics-otel/runtime-api.ts","sources":[]}],"unrenderedSources":["extensions/diagnostics-otel/api.ts","extensions/diagnostics-otel/runtime-api.ts"]}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as createDiagnosticsOtelService } from "./.setup/runtime-api-BUbYdfto.mjs";
1
+ import { t as createDiagnosticsOtelService } from "./.setup/runtime-api-iB_eY9Ao.mjs";
2
2
  import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
3
3
  //#region extensions/diagnostics-otel/index.ts
4
4
  var diagnostics_otel_default = definePluginEntry({
@@ -1 +1 @@
1
- export { t as createDiagnosticsOtelService } from "./.setup/runtime-api-BUbYdfto.mjs";
1
+ export { t as createDiagnosticsOtelService } from "./.setup/runtime-api-iB_eY9Ao.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/diagnostics-otel",
3
- "version": "2026.11.5-beta.2",
3
+ "version": "2026.11.5-beta.4",
4
4
  "description": "OpenClaw diagnostics OpenTelemetry exporter for metrics, traces, and logs.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,10 +34,10 @@
34
34
  "minHostVersion": ">=2026.4.25"
35
35
  },
36
36
  "compat": {
37
- "pluginApi": ">=2026.11.5-beta.2"
37
+ "pluginApi": ">=2026.11.5-beta.4"
38
38
  },
39
39
  "build": {
40
- "openclawVersion": "2026.11.5-beta.2"
40
+ "openclawVersion": "2026.11.5-beta.4"
41
41
  },
42
42
  "release": {
43
43
  "publishToClawHub": true,
@@ -55,7 +55,7 @@
55
55
  "assets/activity.svg"
56
56
  ],
57
57
  "peerDependencies": {
58
- "openclaw": ">=2026.11.5-beta.2"
58
+ "openclaw": ">=2026.11.5-beta.4"
59
59
  },
60
60
  "peerDependenciesMeta": {
61
61
  "openclaw": {