@openclaw/diagnostics-otel 2026.9.35 → 2026.9.37
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.
|
@@ -182,14 +182,25 @@ function resolveContentCapturePolicy(value) {
|
|
|
182
182
|
function hasPreloadedOtelSdk() {
|
|
183
183
|
return process.env[PRELOADED_OTEL_SDK_ENV] === "1";
|
|
184
184
|
}
|
|
185
|
-
function
|
|
186
|
-
|
|
185
|
+
function createOtelContentRedactor() {
|
|
186
|
+
const redacted = /* @__PURE__ */ new Map();
|
|
187
|
+
return (value) => {
|
|
188
|
+
let result = redacted.get(value);
|
|
189
|
+
if (result === void 0) {
|
|
190
|
+
result = redactSensitiveText(value);
|
|
191
|
+
redacted.set(value, result);
|
|
192
|
+
}
|
|
193
|
+
return result;
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function normalizeOtelContentValue(value, redact = createOtelContentRedactor()) {
|
|
197
|
+
if (typeof value === "string") return clampOtelLogText(redact(value), MAX_OTEL_CONTENT_ATTRIBUTE_CHARS);
|
|
187
198
|
if (Array.isArray(value)) {
|
|
188
199
|
const items = [];
|
|
189
200
|
for (const item of value.slice(0, 200)) if (typeof item === "string") items.push(item);
|
|
190
|
-
if (items.length > 0) return
|
|
201
|
+
if (items.length > 0) return clampOtelLogText(redact(items.join("\n")), MAX_OTEL_CONTENT_ATTRIBUTE_CHARS);
|
|
191
202
|
}
|
|
192
|
-
const json = safeJsonString(value, MAX_OTEL_CONTENT_ATTRIBUTE_CHARS);
|
|
203
|
+
const json = safeJsonString(value, MAX_OTEL_CONTENT_ATTRIBUTE_CHARS, redact);
|
|
193
204
|
if (json) return json;
|
|
194
205
|
}
|
|
195
206
|
const TRUNCATED_JSON_TEXT_SUFFIX = "...(truncated)";
|
|
@@ -215,40 +226,45 @@ const JSON_TRUNCATION_ARRAY_ITEM_BUDGETS = [
|
|
|
215
226
|
];
|
|
216
227
|
const JSON_TRUNCATION_MAX_OBJECT_FIELDS = 64;
|
|
217
228
|
const JSON_TRUNCATION_MAX_DEPTH = 8;
|
|
218
|
-
|
|
229
|
+
const MAX_OTEL_REDACTED_JSON_CANDIDATE_CHARS = 4 * MAX_OTEL_CONTENT_ATTRIBUTE_CHARS;
|
|
230
|
+
function safeJsonString(value, maxChars, redact = createOtelContentRedactor()) {
|
|
219
231
|
if (value === void 0 || typeof value === "function" || typeof value === "symbol") return;
|
|
220
|
-
const
|
|
221
|
-
|
|
232
|
+
const json = serializeJsonForOtelAttribute(value);
|
|
233
|
+
const exact = redactJsonWithinAttributeBudget(json, maxChars);
|
|
234
|
+
if (exact) return exact;
|
|
222
235
|
for (const maxArrayItems of JSON_TRUNCATION_ARRAY_ITEM_BUDGETS) for (const maxStringChars of JSON_TRUNCATION_STRING_BUDGETS) {
|
|
223
|
-
const
|
|
236
|
+
const truncated = redactJsonWithinAttributeBudget(serializeJsonForOtelAttribute(truncateJsonValueForOtelAttribute(value, {
|
|
224
237
|
maxArrayItems,
|
|
225
238
|
maxDepth: JSON_TRUNCATION_MAX_DEPTH,
|
|
226
239
|
maxObjectFields: JSON_TRUNCATION_MAX_OBJECT_FIELDS,
|
|
227
240
|
maxStringChars,
|
|
228
|
-
seen: /* @__PURE__ */ new WeakSet()
|
|
229
|
-
|
|
230
|
-
|
|
241
|
+
seen: /* @__PURE__ */ new WeakSet(),
|
|
242
|
+
redact
|
|
243
|
+
})), maxChars);
|
|
244
|
+
if (truncated) return truncated;
|
|
231
245
|
}
|
|
232
|
-
|
|
246
|
+
return redactJsonWithinAttributeBudget(serializeJsonForOtelAttribute({
|
|
233
247
|
truncated: true,
|
|
234
|
-
reason:
|
|
248
|
+
reason: json ? "max_attribute_size" : "unserializable_value",
|
|
235
249
|
type: describeJsonValue(value)
|
|
236
|
-
});
|
|
237
|
-
return summary && summary.length <= maxChars ? summary : void 0;
|
|
250
|
+
}), maxChars);
|
|
238
251
|
}
|
|
239
|
-
function
|
|
252
|
+
function serializeJsonForOtelAttribute(value) {
|
|
240
253
|
try {
|
|
241
|
-
|
|
242
|
-
if (!json) return;
|
|
243
|
-
return redactSensitiveText(json);
|
|
254
|
+
return JSON.stringify(value) || void 0;
|
|
244
255
|
} catch {
|
|
245
256
|
return;
|
|
246
257
|
}
|
|
247
258
|
}
|
|
259
|
+
function redactJsonWithinAttributeBudget(json, maxChars) {
|
|
260
|
+
if (!json || json.length > MAX_OTEL_REDACTED_JSON_CANDIDATE_CHARS) return;
|
|
261
|
+
const redacted = redactSensitiveText(json);
|
|
262
|
+
return redacted.length <= maxChars ? redacted : void 0;
|
|
263
|
+
}
|
|
248
264
|
function truncateJsonValueForOtelAttribute(value, options) {
|
|
249
|
-
if (typeof value === "string") return truncateJsonTextForOtelAttribute(value, options.maxStringChars);
|
|
265
|
+
if (typeof value === "string") return truncateJsonTextForOtelAttribute(options.redact(value), options.maxStringChars);
|
|
250
266
|
if (typeof value === "number" || typeof value === "boolean" || value === null) return value;
|
|
251
|
-
if (typeof value === "bigint") return truncateJsonTextForOtelAttribute(String(value), options.maxStringChars);
|
|
267
|
+
if (typeof value === "bigint") return truncateJsonTextForOtelAttribute(options.redact(String(value)), options.maxStringChars);
|
|
252
268
|
if (value === void 0 || typeof value === "function" || typeof value === "symbol") return;
|
|
253
269
|
if (options.maxDepth <= 0) return {
|
|
254
270
|
truncated: true,
|
|
@@ -295,8 +311,7 @@ function truncateJsonObjectForOtelAttribute(value, options) {
|
|
|
295
311
|
options.seen.delete(value);
|
|
296
312
|
return result;
|
|
297
313
|
}
|
|
298
|
-
function truncateJsonTextForOtelAttribute(
|
|
299
|
-
const redacted = redactSensitiveText(value);
|
|
314
|
+
function truncateJsonTextForOtelAttribute(redacted, maxChars) {
|
|
300
315
|
if (redacted.length <= maxChars) return redacted;
|
|
301
316
|
const suffixBudget = Math.min(14, maxChars);
|
|
302
317
|
const prefixBudget = Math.max(0, maxChars - suffixBudget);
|
|
@@ -1423,6 +1438,7 @@ function redactInternalReasoningParts(value) {
|
|
|
1423
1438
|
if (!isRecord(part)) return part;
|
|
1424
1439
|
const redacted = { ...part };
|
|
1425
1440
|
for (const field of INTERNAL_REASONING_PART_FIELDS) delete redacted[field];
|
|
1441
|
+
if (part.type === "image" && typeof part.data === "string" && part.data.length > 131072) delete redacted.data;
|
|
1426
1442
|
return redacted;
|
|
1427
1443
|
});
|
|
1428
1444
|
}
|
|
@@ -1491,38 +1507,32 @@ function normalizeGenAiToolDefinitions(value) {
|
|
|
1491
1507
|
}
|
|
1492
1508
|
return definitions;
|
|
1493
1509
|
}
|
|
1494
|
-
function
|
|
1495
|
-
const json = safeJsonString(value, MAX_OTEL_CONTENT_ATTRIBUTE_CHARS);
|
|
1496
|
-
if (json)
|
|
1510
|
+
function assignJsonAttributes(attributes, keys, value, redact) {
|
|
1511
|
+
const json = safeJsonString(value, MAX_OTEL_CONTENT_ATTRIBUTE_CHARS, redact);
|
|
1512
|
+
if (!json) return false;
|
|
1513
|
+
for (const key of keys) attributes[key] = json;
|
|
1514
|
+
return true;
|
|
1497
1515
|
}
|
|
1498
|
-
function assignGenAiModelContentAttributes(attributes, content, policy) {
|
|
1516
|
+
function assignGenAiModelContentAttributes(attributes, content, policy, redact) {
|
|
1499
1517
|
if (policy.systemPrompt && typeof content?.systemPrompt === "string") {
|
|
1500
1518
|
const systemInstructions = [textPart(content.systemPrompt)];
|
|
1501
|
-
|
|
1519
|
+
assignJsonAttributes(attributes, [ATTR_GEN_AI_SYSTEM_INSTRUCTIONS], systemInstructions, redact);
|
|
1502
1520
|
}
|
|
1503
1521
|
if (policy.inputMessages) {
|
|
1504
1522
|
const inputMessages = normalizeGenAiMessages(content?.inputMessages, "user");
|
|
1505
|
-
if (inputMessages.length > 0)
|
|
1506
|
-
assignJsonAttribute(attributes, ATTR_GEN_AI_INPUT_MESSAGES, inputMessages);
|
|
1507
|
-
assignJsonAttribute(attributes, "input.value", inputMessages);
|
|
1508
|
-
attributes["input.mime_type"] = "application/json";
|
|
1509
|
-
}
|
|
1523
|
+
if (inputMessages.length > 0 && assignJsonAttributes(attributes, [ATTR_GEN_AI_INPUT_MESSAGES, "input.value"], inputMessages, redact)) attributes["input.mime_type"] = "application/json";
|
|
1510
1524
|
}
|
|
1511
1525
|
if (policy.toolDefinitions) {
|
|
1512
1526
|
const toolDefinitions = normalizeGenAiToolDefinitions(content?.toolDefinitions);
|
|
1513
|
-
if (toolDefinitions.length > 0)
|
|
1527
|
+
if (toolDefinitions.length > 0) assignJsonAttributes(attributes, [ATTR_GEN_AI_TOOL_DEFINITIONS], toolDefinitions, redact);
|
|
1514
1528
|
}
|
|
1515
1529
|
if (policy.outputMessages) {
|
|
1516
1530
|
const outputMessages = normalizeGenAiMessages(content?.outputMessages, "assistant");
|
|
1517
|
-
if (outputMessages.length > 0)
|
|
1518
|
-
assignJsonAttribute(attributes, ATTR_GEN_AI_OUTPUT_MESSAGES, outputMessages);
|
|
1519
|
-
assignJsonAttribute(attributes, "output.value", outputMessages);
|
|
1520
|
-
attributes["output.mime_type"] = "application/json";
|
|
1521
|
-
}
|
|
1531
|
+
if (outputMessages.length > 0 && assignJsonAttributes(attributes, [ATTR_GEN_AI_OUTPUT_MESSAGES, "output.value"], outputMessages, redact)) attributes["output.mime_type"] = "application/json";
|
|
1522
1532
|
}
|
|
1523
1533
|
}
|
|
1524
|
-
function assignOtelContentAttribute(attributes, key, value) {
|
|
1525
|
-
const normalized = normalizeOtelContentValue(value);
|
|
1534
|
+
function assignOtelContentAttribute(attributes, key, value, redact) {
|
|
1535
|
+
const normalized = normalizeOtelContentValue(value, redact);
|
|
1526
1536
|
if (normalized) attributes[key] = normalized;
|
|
1527
1537
|
}
|
|
1528
1538
|
function assignOtelToolIdentityAttributes(attributes, evt) {
|
|
@@ -1536,11 +1546,12 @@ function assignOtelModelContentAttributes(attributes, content, policy) {
|
|
|
1536
1546
|
inputMessages: redactInternalReasoningFromMessages(content.inputMessages),
|
|
1537
1547
|
outputMessages: redactInternalReasoningFromMessages(content.outputMessages)
|
|
1538
1548
|
} : void 0;
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
if (policy.
|
|
1542
|
-
if (policy.
|
|
1543
|
-
if (policy.
|
|
1549
|
+
const redact = createOtelContentRedactor();
|
|
1550
|
+
assignGenAiModelContentAttributes(attributes, redactedContent, policy, redact);
|
|
1551
|
+
if (policy.inputMessages) assignOtelContentAttribute(attributes, "openclaw.content.input_messages", redactedContent?.inputMessages, redact);
|
|
1552
|
+
if (policy.toolDefinitions) assignOtelContentAttribute(attributes, "openclaw.content.tool_definitions", content?.toolDefinitions, redact);
|
|
1553
|
+
if (policy.outputMessages) assignOtelContentAttribute(attributes, "openclaw.content.output_messages", redactedContent?.outputMessages, redact);
|
|
1554
|
+
if (policy.systemPrompt) assignOtelContentAttribute(attributes, "openclaw.content.system_prompt", content?.systemPrompt, redact);
|
|
1544
1555
|
}
|
|
1545
1556
|
function assignOtelToolContentAttributes(attributes, content, policy) {
|
|
1546
1557
|
if (policy.toolInputs) {
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as createDiagnosticsOtelService } from "./.setup/runtime-api-
|
|
1
|
+
import { t as createDiagnosticsOtelService } from "./.setup/runtime-api-CusZzQjb.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({
|
package/dist/runtime-api.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { t as createDiagnosticsOtelService } from "./.setup/runtime-api-CusZzQjb.mjs";
|
|
2
|
+
export { createDiagnosticsOtelService };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/diagnostics-otel",
|
|
3
|
-
"version": "2026.9.
|
|
3
|
+
"version": "2026.9.37",
|
|
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.9.
|
|
37
|
+
"pluginApi": ">=2026.9.37"
|
|
38
38
|
},
|
|
39
39
|
"build": {
|
|
40
|
-
"openclawVersion": "2026.9.
|
|
40
|
+
"openclawVersion": "2026.9.37"
|
|
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.9.
|
|
58
|
+
"openclaw": ">=2026.9.37"
|
|
59
59
|
},
|
|
60
60
|
"peerDependenciesMeta": {
|
|
61
61
|
"openclaw": {
|
|
@@ -1 +0,0 @@
|
|
|
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-ButGOVne.mjs","sha256":"8ecc60d34b8ca4e94372e9944f0bf67f01ea5484ec53e7de118e5944d2612984","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-recorder-runtime.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":"75ca4fc968d76c75a95a3177a493fbe8a74ea246dce450bdaf41faa376aefd35","facadeSource":"extensions/diagnostics-otel/index.ts","sources":["extensions/diagnostics-otel/index.ts"]},{"output":"runtime-api.js","sha256":"e5f5e8c2a9141861ae3b020fe203a5f36d75c881d3fb978287941372f459abee","facadeSource":"extensions/diagnostics-otel/runtime-api.ts","sources":[]}],"unrenderedSources":["extensions/diagnostics-otel/api.ts","extensions/diagnostics-otel/runtime-api.ts"]}
|