@openclaw/diagnostics-otel 2026.5.31-beta.4 → 2026.6.1-beta.2
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/dist/index.js +189 -34
- package/npm-shrinkwrap.json +2 -2
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import { NodeSDK } from "@opentelemetry/sdk-node";
|
|
|
11
11
|
import { BatchSpanProcessor, ParentBasedSampler, TraceIdRatioBasedSampler } from "@opentelemetry/sdk-trace-base";
|
|
12
12
|
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";
|
|
13
13
|
import { ATTR_GEN_AI_INPUT_MESSAGES, ATTR_GEN_AI_OUTPUT_MESSAGES, ATTR_GEN_AI_SYSTEM_INSTRUCTIONS, ATTR_GEN_AI_TOOL_DEFINITIONS } from "@opentelemetry/semantic-conventions/incubating";
|
|
14
|
+
import { waitForDiagnosticEventsDrained } from "openclaw/plugin-sdk/diagnostic-runtime";
|
|
14
15
|
import { registerUnhandledRejectionHandler } from "openclaw/plugin-sdk/runtime-env";
|
|
15
16
|
//#region extensions/diagnostics-otel/src/service.ts
|
|
16
17
|
const DEFAULT_SERVICE_NAME = "openclaw";
|
|
@@ -89,6 +90,8 @@ const GEN_AI_OPERATION_DURATION_BUCKETS = [
|
|
|
89
90
|
40.96,
|
|
90
91
|
81.92
|
|
91
92
|
];
|
|
93
|
+
const MAX_RETAINED_TRUSTED_SPAN_CONTEXTS = 1024;
|
|
94
|
+
const RETAINED_TRUSTED_SPAN_CONTEXT_TIMEOUT_MS = 5e3;
|
|
92
95
|
const NO_CONTENT_CAPTURE = {
|
|
93
96
|
inputMessages: false,
|
|
94
97
|
outputMessages: false,
|
|
@@ -764,12 +767,14 @@ function createDiagnosticsOtelService() {
|
|
|
764
767
|
const tracer = trace.getTracer("openclaw");
|
|
765
768
|
const activeTrustedSpans = /* @__PURE__ */ new Map();
|
|
766
769
|
const activeTrustedSpanAliases = /* @__PURE__ */ new Map();
|
|
767
|
-
const
|
|
770
|
+
const retainedTrustedSpanContexts = /* @__PURE__ */ new Map();
|
|
771
|
+
const retainedTrustedSpanContextCleanupTimers = /* @__PURE__ */ new Set();
|
|
768
772
|
stopActiveTrustedSpans = () => {
|
|
769
773
|
const stopAt = Date.now();
|
|
770
|
-
for (const handle of
|
|
771
|
-
|
|
772
|
-
|
|
774
|
+
for (const handle of retainedTrustedSpanContextCleanupTimers) clearTimeout(handle);
|
|
775
|
+
retainedTrustedSpanContextCleanupTimers.clear();
|
|
776
|
+
retainedTrustedSpanContexts.clear();
|
|
777
|
+
for (const span of new Set([...activeTrustedSpans.values(), ...Array.from(activeTrustedSpanAliases.values(), (entry) => entry.span)])) span.end(stopAt);
|
|
773
778
|
activeTrustedSpans.clear();
|
|
774
779
|
activeTrustedSpanAliases.clear();
|
|
775
780
|
};
|
|
@@ -1072,18 +1077,75 @@ function createDiagnosticsOtelService() {
|
|
|
1072
1077
|
}, parentContext);
|
|
1073
1078
|
};
|
|
1074
1079
|
const trustedTraceContext = (evt, metadata) => metadata.trusted ? normalizeTraceContext(evt.trace) : void 0;
|
|
1080
|
+
const internalOrTrustedTraceContext = (evt, metadata) => metadata.trusted || metadata.internal ? normalizeTraceContext(evt.trace) : void 0;
|
|
1081
|
+
const trustedSpanAliasOwner = (evt) => {
|
|
1082
|
+
if ("runId" in evt && evt.runId) return {
|
|
1083
|
+
kind: "run",
|
|
1084
|
+
id: evt.runId
|
|
1085
|
+
};
|
|
1086
|
+
};
|
|
1087
|
+
const sameTrustedSpanAliasOwner = (left, right) => Boolean(left && right && left.kind === right.kind && left.id === right.id);
|
|
1088
|
+
const trustedSpanAliasKey = (spanId, owner) => `${spanId}:${owner.kind}:${owner.id}`;
|
|
1089
|
+
const retainedTrustedSpanContextKey = (traceId, spanId, owner) => `${traceId}:${owner ? trustedSpanAliasKey(spanId, owner) : spanId}`;
|
|
1090
|
+
const retainedTrustedSpanContext = (traceContext, spanId, owner) => {
|
|
1091
|
+
if (!traceContext?.traceId || !spanId) return;
|
|
1092
|
+
const retained = (owner ? retainedTrustedSpanContexts.get(retainedTrustedSpanContextKey(traceContext.traceId, spanId, owner)) : void 0) ?? retainedTrustedSpanContexts.get(retainedTrustedSpanContextKey(traceContext.traceId, spanId));
|
|
1093
|
+
if (retained?.spanContext.traceId !== traceContext.traceId) return;
|
|
1094
|
+
if (retained.owner && !sameTrustedSpanAliasOwner(retained.owner, owner)) return;
|
|
1095
|
+
return retained.spanContext;
|
|
1096
|
+
};
|
|
1097
|
+
const activeTrustedSpanAlias = (spanId, owner) => {
|
|
1098
|
+
if (!owner) return;
|
|
1099
|
+
const alias = activeTrustedSpanAliases.get(trustedSpanAliasKey(spanId, owner));
|
|
1100
|
+
if (!alias || !sameTrustedSpanAliasOwner(alias.owner, owner)) return;
|
|
1101
|
+
return alias.span;
|
|
1102
|
+
};
|
|
1103
|
+
const internalOrTrustedParentContext = (evt, metadata) => {
|
|
1104
|
+
const traceContext = internalOrTrustedTraceContext(evt, metadata);
|
|
1105
|
+
const parentSpanId = traceContext?.parentSpanId ?? traceContext?.spanId;
|
|
1106
|
+
if (!traceContext || !parentSpanId) return;
|
|
1107
|
+
return contextForTraceContext({
|
|
1108
|
+
...traceContext,
|
|
1109
|
+
spanId: parentSpanId
|
|
1110
|
+
});
|
|
1111
|
+
};
|
|
1112
|
+
const internalOrTrustedExplicitParentContext = (evt, metadata) => {
|
|
1113
|
+
const traceContext = internalOrTrustedTraceContext(evt, metadata);
|
|
1114
|
+
if (!traceContext?.parentSpanId) return;
|
|
1115
|
+
return contextForTraceContext({
|
|
1116
|
+
...traceContext,
|
|
1117
|
+
spanId: traceContext.parentSpanId
|
|
1118
|
+
});
|
|
1119
|
+
};
|
|
1075
1120
|
const activeTrustedParentContext = (evt, metadata) => {
|
|
1076
|
-
const
|
|
1121
|
+
const traceContext = trustedTraceContext(evt, metadata);
|
|
1122
|
+
const parentSpanId = traceContext?.parentSpanId;
|
|
1077
1123
|
if (!parentSpanId) return;
|
|
1078
|
-
const
|
|
1079
|
-
|
|
1080
|
-
|
|
1124
|
+
const owner = trustedSpanAliasOwner(evt);
|
|
1125
|
+
const spanContext = (activeTrustedSpans.get(parentSpanId) ?? activeTrustedSpanAlias(parentSpanId, owner))?.spanContext() ?? retainedTrustedSpanContext(traceContext, parentSpanId, owner);
|
|
1126
|
+
if (!spanContext) return;
|
|
1127
|
+
return trace.setSpanContext(context.active(), spanContext);
|
|
1128
|
+
};
|
|
1129
|
+
const activeInternalOrTrustedContext = (evt, metadata) => {
|
|
1130
|
+
const traceContext = internalOrTrustedTraceContext(evt, metadata);
|
|
1131
|
+
if (!traceContext) return;
|
|
1132
|
+
const owner = trustedSpanAliasOwner(evt);
|
|
1133
|
+
const activeSpan = (traceContext.spanId ? activeTrustedSpans.get(traceContext.spanId) ?? activeTrustedSpanAlias(traceContext.spanId, owner) : void 0) ?? (traceContext.parentSpanId ? activeTrustedSpans.get(traceContext.parentSpanId) ?? activeTrustedSpanAlias(traceContext.parentSpanId, owner) : void 0);
|
|
1134
|
+
if (activeSpan) return trace.setSpanContext(context.active(), activeSpan.spanContext());
|
|
1135
|
+
const retainedSpanContext = retainedTrustedSpanContext(traceContext, traceContext.spanId, owner) ?? retainedTrustedSpanContext(traceContext, traceContext.parentSpanId, owner);
|
|
1136
|
+
if (retainedSpanContext) return trace.setSpanContext(context.active(), retainedSpanContext);
|
|
1137
|
+
return internalOrTrustedParentContext(evt, metadata);
|
|
1081
1138
|
};
|
|
1082
1139
|
const trackTrustedSpan = (evt, metadata, span) => {
|
|
1083
1140
|
const spanId = trustedTraceContext(evt, metadata)?.spanId;
|
|
1084
1141
|
if (spanId) activeTrustedSpans.set(spanId, span);
|
|
1085
1142
|
return span;
|
|
1086
1143
|
};
|
|
1144
|
+
const trackInternalOrTrustedSpan = (evt, metadata, span) => {
|
|
1145
|
+
const spanId = internalOrTrustedTraceContext(evt, metadata)?.spanId;
|
|
1146
|
+
if (spanId) activeTrustedSpans.set(spanId, span);
|
|
1147
|
+
return span;
|
|
1148
|
+
};
|
|
1087
1149
|
const takeTrackedTrustedSpan = (evt, metadata) => {
|
|
1088
1150
|
const spanId = trustedTraceContext(evt, metadata)?.spanId;
|
|
1089
1151
|
if (!spanId) return;
|
|
@@ -1091,19 +1153,72 @@ function createDiagnosticsOtelService() {
|
|
|
1091
1153
|
if (span) activeTrustedSpans.delete(spanId);
|
|
1092
1154
|
return span;
|
|
1093
1155
|
};
|
|
1156
|
+
const getTrackedInternalOrTrustedSpan = (evt, metadata) => {
|
|
1157
|
+
const spanId = internalOrTrustedTraceContext(evt, metadata)?.spanId;
|
|
1158
|
+
if (!spanId) return;
|
|
1159
|
+
return activeTrustedSpans.get(spanId);
|
|
1160
|
+
};
|
|
1094
1161
|
const setSpanAttrs = (span, attributes) => {
|
|
1095
1162
|
span.setAttributes?.(redactOtelAttributes(attributes));
|
|
1096
1163
|
};
|
|
1097
|
-
const
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
if (activeTrustedSpans.get(spanId) === span) activeTrustedSpans.delete(spanId);
|
|
1103
|
-
if (parentSpanId && activeTrustedSpanAliases.get(parentSpanId) === span) activeTrustedSpanAliases.delete(parentSpanId);
|
|
1104
|
-
span.end(endTimeMs);
|
|
1164
|
+
const retainTrustedSpanContext = (traceId, spanId, spanContext, token, owner) => {
|
|
1165
|
+
retainedTrustedSpanContexts.set(retainedTrustedSpanContextKey(traceId, spanId, owner), {
|
|
1166
|
+
spanContext,
|
|
1167
|
+
token,
|
|
1168
|
+
...owner ? { owner } : {}
|
|
1105
1169
|
});
|
|
1106
|
-
|
|
1170
|
+
while (retainedTrustedSpanContexts.size > MAX_RETAINED_TRUSTED_SPAN_CONTEXTS) {
|
|
1171
|
+
const oldestKey = retainedTrustedSpanContexts.keys().next().value;
|
|
1172
|
+
if (!oldestKey) break;
|
|
1173
|
+
retainedTrustedSpanContexts.delete(oldestKey);
|
|
1174
|
+
}
|
|
1175
|
+
};
|
|
1176
|
+
const scheduleRetainedTrustedSpanContextCleanup = (token) => {
|
|
1177
|
+
let drainHandle;
|
|
1178
|
+
let timeoutHandle;
|
|
1179
|
+
const cleanup = () => {
|
|
1180
|
+
if (drainHandle) {
|
|
1181
|
+
clearTimeout(drainHandle);
|
|
1182
|
+
retainedTrustedSpanContextCleanupTimers.delete(drainHandle);
|
|
1183
|
+
drainHandle = void 0;
|
|
1184
|
+
}
|
|
1185
|
+
if (timeoutHandle) {
|
|
1186
|
+
clearTimeout(timeoutHandle);
|
|
1187
|
+
retainedTrustedSpanContextCleanupTimers.delete(timeoutHandle);
|
|
1188
|
+
timeoutHandle = void 0;
|
|
1189
|
+
}
|
|
1190
|
+
for (const [key, retained] of retainedTrustedSpanContexts) if (retained.token === token) retainedTrustedSpanContexts.delete(key);
|
|
1191
|
+
};
|
|
1192
|
+
drainHandle = setTimeout(() => {
|
|
1193
|
+
if (drainHandle) {
|
|
1194
|
+
retainedTrustedSpanContextCleanupTimers.delete(drainHandle);
|
|
1195
|
+
drainHandle = void 0;
|
|
1196
|
+
}
|
|
1197
|
+
waitForDiagnosticEventsDrained().then(cleanup, cleanup);
|
|
1198
|
+
}, 0);
|
|
1199
|
+
drainHandle.unref?.();
|
|
1200
|
+
retainedTrustedSpanContextCleanupTimers.add(drainHandle);
|
|
1201
|
+
timeoutHandle = setTimeout(cleanup, RETAINED_TRUSTED_SPAN_CONTEXT_TIMEOUT_MS);
|
|
1202
|
+
timeoutHandle.unref?.();
|
|
1203
|
+
retainedTrustedSpanContextCleanupTimers.add(timeoutHandle);
|
|
1204
|
+
};
|
|
1205
|
+
const completeTrackedLifecycleSpan = (spanId, span, endTimeMs) => {
|
|
1206
|
+
const spanContext = span.spanContext();
|
|
1207
|
+
const retainedKeys = [{ spanId }];
|
|
1208
|
+
const retainedAliasKeys = [];
|
|
1209
|
+
for (const [aliasKey, alias] of activeTrustedSpanAliases) if (alias.span === span) {
|
|
1210
|
+
retainedKeys.push({
|
|
1211
|
+
spanId: alias.spanId,
|
|
1212
|
+
owner: alias.owner
|
|
1213
|
+
});
|
|
1214
|
+
retainedAliasKeys.push(aliasKey);
|
|
1215
|
+
}
|
|
1216
|
+
if (activeTrustedSpans.get(spanId) === span) activeTrustedSpans.delete(spanId);
|
|
1217
|
+
for (const aliasKey of retainedAliasKeys) if (activeTrustedSpanAliases.get(aliasKey)?.span === span) activeTrustedSpanAliases.delete(aliasKey);
|
|
1218
|
+
span.end(endTimeMs);
|
|
1219
|
+
const token = Symbol("retainedTrustedSpanContext");
|
|
1220
|
+
for (const retainedKey of retainedKeys) retainTrustedSpanContext(spanContext.traceId, retainedKey.spanId, spanContext, token, retainedKey.owner);
|
|
1221
|
+
scheduleRetainedTrustedSpanContextCleanup(token);
|
|
1107
1222
|
};
|
|
1108
1223
|
const addRunAttrs = (spanAttrs, evt) => {
|
|
1109
1224
|
if (evt.provider) spanAttrs["openclaw.provider"] = evt.provider;
|
|
@@ -1246,11 +1361,19 @@ function createDiagnosticsOtelService() {
|
|
|
1246
1361
|
"openclaw.source": lowCardinalityAttr(evt.source)
|
|
1247
1362
|
});
|
|
1248
1363
|
};
|
|
1249
|
-
const recordMessageDispatchStarted = (evt) => {
|
|
1250
|
-
|
|
1364
|
+
const recordMessageDispatchStarted = (evt, metadata) => {
|
|
1365
|
+
const attrs = {
|
|
1251
1366
|
"openclaw.channel": lowCardinalityAttr(evt.channel),
|
|
1252
1367
|
"openclaw.source": lowCardinalityAttr(evt.source)
|
|
1253
|
-
}
|
|
1368
|
+
};
|
|
1369
|
+
messageDispatchStartedCounter.add(1, attrs);
|
|
1370
|
+
if (!tracesEnabled) return;
|
|
1371
|
+
const traceContext = internalOrTrustedTraceContext(evt, metadata);
|
|
1372
|
+
if (!traceContext?.spanId || activeTrustedSpans.has(traceContext.spanId)) return;
|
|
1373
|
+
trackInternalOrTrustedSpan(evt, metadata, spanWithDuration("openclaw.message.processed", attrs, void 0, {
|
|
1374
|
+
parentContext: internalOrTrustedExplicitParentContext(evt, metadata),
|
|
1375
|
+
startTimeMs: evt.ts
|
|
1376
|
+
}));
|
|
1254
1377
|
};
|
|
1255
1378
|
const recordMessageDispatchCompleted = (evt) => {
|
|
1256
1379
|
const attrs = {
|
|
@@ -1262,7 +1385,7 @@ function createDiagnosticsOtelService() {
|
|
|
1262
1385
|
messageDispatchCompletedCounter.add(1, attrs);
|
|
1263
1386
|
messageDispatchDurationHistogram.record(evt.durationMs, attrs);
|
|
1264
1387
|
};
|
|
1265
|
-
const recordMessageProcessed = (evt) => {
|
|
1388
|
+
const recordMessageProcessed = (evt, metadata) => {
|
|
1266
1389
|
const attrs = {
|
|
1267
1390
|
"openclaw.channel": lowCardinalityAttr(evt.channel),
|
|
1268
1391
|
"openclaw.outcome": evt.outcome ?? "unknown"
|
|
@@ -1272,12 +1395,22 @@ function createDiagnosticsOtelService() {
|
|
|
1272
1395
|
if (!tracesEnabled) return;
|
|
1273
1396
|
const spanAttrs = { ...attrs };
|
|
1274
1397
|
if (evt.reason) spanAttrs["openclaw.reason"] = lowCardinalityAttr(evt.reason, "unknown");
|
|
1275
|
-
const
|
|
1398
|
+
const trackedSpan = getTrackedInternalOrTrustedSpan(evt, metadata);
|
|
1399
|
+
const span = trackedSpan ?? spanWithDuration("openclaw.message.processed", spanAttrs, evt.durationMs, {
|
|
1400
|
+
parentContext: internalOrTrustedExplicitParentContext(evt, metadata),
|
|
1401
|
+
endTimeMs: evt.ts
|
|
1402
|
+
});
|
|
1403
|
+
setSpanAttrs(span, spanAttrs);
|
|
1276
1404
|
if (evt.outcome === "error" && evt.error) span.setStatus({
|
|
1277
1405
|
code: SpanStatusCode.ERROR,
|
|
1278
1406
|
message: redactSensitiveText(evt.error)
|
|
1279
1407
|
});
|
|
1280
|
-
|
|
1408
|
+
const traceContext = internalOrTrustedTraceContext(evt, metadata);
|
|
1409
|
+
if (trackedSpan && traceContext?.spanId) {
|
|
1410
|
+
completeTrackedLifecycleSpan(traceContext.spanId, trackedSpan, evt.ts);
|
|
1411
|
+
return;
|
|
1412
|
+
}
|
|
1413
|
+
span.end(evt.ts);
|
|
1281
1414
|
};
|
|
1282
1415
|
const messageDeliveryAttrs = (evt) => ({
|
|
1283
1416
|
"openclaw.channel": lowCardinalityAttr(evt.channel),
|
|
@@ -1286,7 +1419,7 @@ function createDiagnosticsOtelService() {
|
|
|
1286
1419
|
const recordMessageDeliveryStarted = (evt) => {
|
|
1287
1420
|
messageDeliveryStartedCounter.add(1, messageDeliveryAttrs(evt));
|
|
1288
1421
|
};
|
|
1289
|
-
const recordMessageDeliveryCompleted = (evt) => {
|
|
1422
|
+
const recordMessageDeliveryCompleted = (evt, metadata) => {
|
|
1290
1423
|
const attrs = {
|
|
1291
1424
|
...messageDeliveryAttrs(evt),
|
|
1292
1425
|
"openclaw.outcome": "completed"
|
|
@@ -1296,9 +1429,12 @@ function createDiagnosticsOtelService() {
|
|
|
1296
1429
|
spanWithDuration("openclaw.message.delivery", {
|
|
1297
1430
|
...attrs,
|
|
1298
1431
|
"openclaw.delivery.result_count": evt.resultCount
|
|
1299
|
-
}, evt.durationMs, {
|
|
1432
|
+
}, evt.durationMs, {
|
|
1433
|
+
parentContext: activeInternalOrTrustedContext(evt, metadata),
|
|
1434
|
+
endTimeMs: evt.ts
|
|
1435
|
+
}).end(evt.ts);
|
|
1300
1436
|
};
|
|
1301
|
-
const recordMessageDeliveryError = (evt) => {
|
|
1437
|
+
const recordMessageDeliveryError = (evt, metadata) => {
|
|
1302
1438
|
const attrs = {
|
|
1303
1439
|
...messageDeliveryAttrs(evt),
|
|
1304
1440
|
"openclaw.outcome": "error",
|
|
@@ -1306,7 +1442,10 @@ function createDiagnosticsOtelService() {
|
|
|
1306
1442
|
};
|
|
1307
1443
|
messageDeliveryDurationHistogram.record(evt.durationMs, attrs);
|
|
1308
1444
|
if (!tracesEnabled) return;
|
|
1309
|
-
const span = spanWithDuration("openclaw.message.delivery", attrs, evt.durationMs, {
|
|
1445
|
+
const span = spanWithDuration("openclaw.message.delivery", attrs, evt.durationMs, {
|
|
1446
|
+
parentContext: activeInternalOrTrustedContext(evt, metadata),
|
|
1447
|
+
endTimeMs: evt.ts
|
|
1448
|
+
});
|
|
1310
1449
|
span.setStatus({
|
|
1311
1450
|
code: SpanStatusCode.ERROR,
|
|
1312
1451
|
message: redactSensitiveText(evt.errorCategory)
|
|
@@ -1322,7 +1461,17 @@ function createDiagnosticsOtelService() {
|
|
|
1322
1461
|
startTimeMs: evt.ts
|
|
1323
1462
|
}));
|
|
1324
1463
|
const parentSpanId = trustedTraceContext(evt, metadata)?.parentSpanId;
|
|
1325
|
-
if (parentSpanId && !activeTrustedSpans.has(parentSpanId))
|
|
1464
|
+
if (parentSpanId && !activeTrustedSpans.has(parentSpanId)) {
|
|
1465
|
+
const owner = {
|
|
1466
|
+
kind: "run",
|
|
1467
|
+
id: evt.runId
|
|
1468
|
+
};
|
|
1469
|
+
activeTrustedSpanAliases.set(trustedSpanAliasKey(parentSpanId, owner), {
|
|
1470
|
+
span,
|
|
1471
|
+
spanId: parentSpanId,
|
|
1472
|
+
owner
|
|
1473
|
+
});
|
|
1474
|
+
}
|
|
1326
1475
|
};
|
|
1327
1476
|
const recordLaneEnqueue = (evt) => {
|
|
1328
1477
|
const attrs = { "openclaw.lane": lowCardinalityQueueLaneAttr(evt.lane) };
|
|
@@ -1485,7 +1634,7 @@ function createDiagnosticsOtelService() {
|
|
|
1485
1634
|
...evt.errorCategory ? { message: redactSensitiveText(evt.errorCategory) } : {}
|
|
1486
1635
|
});
|
|
1487
1636
|
if (trackedSpan && trustedTrace?.spanId) {
|
|
1488
|
-
|
|
1637
|
+
completeTrackedLifecycleSpan(trustedTrace.spanId, trackedSpan, evt.ts);
|
|
1489
1638
|
return;
|
|
1490
1639
|
}
|
|
1491
1640
|
span.end(evt.ts);
|
|
@@ -1516,7 +1665,9 @@ function createDiagnosticsOtelService() {
|
|
|
1516
1665
|
spanAttrs["openclaw.harness.items.completed"] = evt.itemLifecycle.completedCount;
|
|
1517
1666
|
spanAttrs["openclaw.harness.items.active"] = evt.itemLifecycle.activeCount;
|
|
1518
1667
|
}
|
|
1519
|
-
const
|
|
1668
|
+
const trustedTrace = trustedTraceContext(evt, metadata);
|
|
1669
|
+
const trackedSpan = trustedTrace?.spanId ? activeTrustedSpans.get(trustedTrace.spanId) : void 0;
|
|
1670
|
+
const span = trackedSpan ?? spanWithDuration("openclaw.harness.run", spanAttrs, evt.durationMs, {
|
|
1520
1671
|
parentContext: activeTrustedParentContext(evt, metadata),
|
|
1521
1672
|
endTimeMs: evt.ts
|
|
1522
1673
|
});
|
|
@@ -1525,6 +1676,10 @@ function createDiagnosticsOtelService() {
|
|
|
1525
1676
|
code: SpanStatusCode.ERROR,
|
|
1526
1677
|
message: "error"
|
|
1527
1678
|
});
|
|
1679
|
+
if (trackedSpan && trustedTrace?.spanId) {
|
|
1680
|
+
completeTrackedLifecycleSpan(trustedTrace.spanId, trackedSpan, evt.ts);
|
|
1681
|
+
return;
|
|
1682
|
+
}
|
|
1528
1683
|
span.end(evt.ts);
|
|
1529
1684
|
};
|
|
1530
1685
|
const recordHarnessRunError = (evt, metadata) => {
|
|
@@ -1901,22 +2056,22 @@ function createDiagnosticsOtelService() {
|
|
|
1901
2056
|
recordMessageReceived(evt);
|
|
1902
2057
|
return;
|
|
1903
2058
|
case "message.dispatch.started":
|
|
1904
|
-
recordMessageDispatchStarted(evt);
|
|
2059
|
+
recordMessageDispatchStarted(evt, metadata);
|
|
1905
2060
|
return;
|
|
1906
2061
|
case "message.dispatch.completed":
|
|
1907
2062
|
recordMessageDispatchCompleted(evt);
|
|
1908
2063
|
return;
|
|
1909
2064
|
case "message.processed":
|
|
1910
|
-
recordMessageProcessed(evt);
|
|
2065
|
+
recordMessageProcessed(evt, metadata);
|
|
1911
2066
|
return;
|
|
1912
2067
|
case "message.delivery.started":
|
|
1913
2068
|
recordMessageDeliveryStarted(evt);
|
|
1914
2069
|
return;
|
|
1915
2070
|
case "message.delivery.completed":
|
|
1916
|
-
recordMessageDeliveryCompleted(evt);
|
|
2071
|
+
recordMessageDeliveryCompleted(evt, metadata);
|
|
1917
2072
|
return;
|
|
1918
2073
|
case "message.delivery.error":
|
|
1919
|
-
recordMessageDeliveryError(evt);
|
|
2074
|
+
recordMessageDeliveryError(evt, metadata);
|
|
1920
2075
|
return;
|
|
1921
2076
|
case "talk.event":
|
|
1922
2077
|
recordTalkEvent(evt, metadata);
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/diagnostics-otel",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.6.1-beta.2",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@openclaw/diagnostics-otel",
|
|
9
|
-
"version": "2026.
|
|
9
|
+
"version": "2026.6.1-beta.2",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@opentelemetry/api": "1.9.1",
|
|
12
12
|
"@opentelemetry/api-logs": "0.218.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/diagnostics-otel",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.6.1-beta.2",
|
|
4
4
|
"description": "OpenClaw diagnostics OpenTelemetry exporter for metrics and traces.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"minHostVersion": ">=2026.4.25"
|
|
32
32
|
},
|
|
33
33
|
"compat": {
|
|
34
|
-
"pluginApi": ">=2026.
|
|
34
|
+
"pluginApi": ">=2026.6.1-beta.2"
|
|
35
35
|
},
|
|
36
36
|
"build": {
|
|
37
|
-
"openclawVersion": "2026.
|
|
37
|
+
"openclawVersion": "2026.6.1-beta.2"
|
|
38
38
|
},
|
|
39
39
|
"release": {
|
|
40
40
|
"publishToClawHub": true,
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"README.md"
|
|
52
52
|
],
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"openclaw": ">=2026.
|
|
54
|
+
"openclaw": ">=2026.6.1-beta.2"
|
|
55
55
|
},
|
|
56
56
|
"peerDependenciesMeta": {
|
|
57
57
|
"openclaw": {
|