






























@@ -1449,6 +1449,65 @@ describe("diagnostics-otel service", () => {
14491449await service.stop?.(ctx);
14501450});
145114511452+test("does not parent untrusted diagnostic lifecycle spans from injected trace ids", async () => {
1453+const service = createDiagnosticsOtelService();
1454+const ctx = createOtelContext(OTEL_TEST_ENDPOINT, { traces: true, metrics: true });
1455+await service.start(ctx);
1456+1457+emitDiagnosticEvent({
1458+type: "run.completed",
1459+runId: "run-1",
1460+provider: "openai",
1461+model: "gpt-5.4",
1462+outcome: "completed",
1463+durationMs: 100,
1464+trace: {
1465+traceId: TRACE_ID,
1466+spanId: CHILD_SPAN_ID,
1467+parentSpanId: SPAN_ID,
1468+traceFlags: "01",
1469+},
1470+});
1471+emitDiagnosticEvent({
1472+type: "model.call.completed",
1473+runId: "run-1",
1474+callId: "call-1",
1475+provider: "openai",
1476+model: "gpt-5.4",
1477+durationMs: 80,
1478+trace: {
1479+traceId: TRACE_ID,
1480+spanId: GRANDCHILD_SPAN_ID,
1481+parentSpanId: CHILD_SPAN_ID,
1482+traceFlags: "01",
1483+},
1484+});
1485+emitDiagnosticEvent({
1486+type: "tool.execution.completed",
1487+runId: "run-1",
1488+toolName: "read",
1489+durationMs: 20,
1490+trace: {
1491+traceId: TRACE_ID,
1492+spanId: TOOL_SPAN_ID,
1493+parentSpanId: GRANDCHILD_SPAN_ID,
1494+traceFlags: "01",
1495+},
1496+});
1497+await flushDiagnosticEvents();
1498+1499+expect(telemetryState.tracer.setSpanContext).not.toHaveBeenCalled();
1500+const parentBySpanName = Object.fromEntries(
1501+telemetryState.tracer.startSpan.mock.calls.map((call) => [call[0], call[2]]),
1502+);
1503+expect(parentBySpanName).toMatchObject({
1504+"openclaw.run": undefined,
1505+"openclaw.model.call": undefined,
1506+"openclaw.tool.execution": undefined,
1507+});
1508+await service.stop?.(ctx);
1509+});
1510+14521511test("exports exec process spans without command text", async () => {
14531512const service = createDiagnosticsOtelService();
14541513const ctx = createOtelContext(OTEL_TEST_ENDPOINT, { traces: true, metrics: true });
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。