

























@@ -1400,33 +1400,22 @@ describe("diagnostics-otel service", () => {
14001400});
14011401await flushDiagnosticEvents();
140214021403-const failoverCall = telemetryState.tracer.startSpan.mock.calls.find(
1404-(call) => call[0] === "openclaw.model.failover",
1405-);
1406-expect(failoverCall?.[1]).toMatchObject({
1407-attributes: {
1408-"openclaw.provider": "anthropic",
1409-"openclaw.model": "claude-opus-4-6",
1410-"openclaw.failover.to_provider": "openai",
1411-"openclaw.failover.to_model": "gpt-5.4",
1412-"openclaw.failover.reason": "overloaded",
1413-"openclaw.failover.suspended": true,
1414-"openclaw.failover.cascade_depth": 1,
1415-"openclaw.lane": "main",
1416-},
1417-startTime: expect.any(Number),
1418-});
1419-expect(failoverCall?.[1]).toEqual({
1420-attributes: expect.not.objectContaining({
1421-"openclaw.sessionId": expect.anything(),
1422-"openclaw.sessionKey": expect.anything(),
1423-}),
1424-startTime: expect.any(Number),
1425-});
1403+const failoverOptions = startedSpanOptions("openclaw.model.failover");
1404+expect(failoverOptions?.attributes?.["openclaw.provider"]).toBe("anthropic");
1405+expect(failoverOptions?.attributes?.["openclaw.model"]).toBe("claude-opus-4-6");
1406+expect(failoverOptions?.attributes?.["openclaw.failover.to_provider"]).toBe("openai");
1407+expect(failoverOptions?.attributes?.["openclaw.failover.to_model"]).toBe("gpt-5.4");
1408+expect(failoverOptions?.attributes?.["openclaw.failover.reason"]).toBe("overloaded");
1409+expect(failoverOptions?.attributes?.["openclaw.failover.suspended"]).toBe(true);
1410+expect(failoverOptions?.attributes?.["openclaw.failover.cascade_depth"]).toBe(1);
1411+expect(failoverOptions?.attributes?.["openclaw.lane"]).toBe("main");
1412+expect(Object.hasOwn(failoverOptions?.attributes ?? {}, "openclaw.sessionId")).toBe(false);
1413+expect(Object.hasOwn(failoverOptions?.attributes ?? {}, "openclaw.sessionKey")).toBe(false);
1414+expect(failoverOptions?.startTime).toBeTypeOf("number");
14261415const span = telemetryState.spans.find(
14271416(candidate) => candidate.name === "openclaw.model.failover",
14281417);
1429-expect(span?.end).toHaveBeenCalledWith(expect.any(Number));
1418+expect(span?.end.mock.calls[0]?.[0]).toBeTypeOf("number");
14301419await service.stop?.(ctx);
14311420});
14321421@@ -1468,24 +1457,17 @@ describe("diagnostics-otel service", () => {
14681457const modelCallAttrs = telemetryState.tracer.startSpan.mock.calls
14691458.filter((call) => call[0] === "openclaw.model.call")
14701459.map((call) => (call[1] as { attributes?: Record<string, unknown> }).attributes);
1471-expect(modelCallAttrs).toEqual([
1472-expect.objectContaining({
1473-"gen_ai.system": "openai",
1474-"gen_ai.request.model": "gpt-5.4",
1475-"gen_ai.operation.name": "text_completion",
1476-}),
1477-expect.objectContaining({
1478-"gen_ai.system": "google",
1479-"gen_ai.request.model": "gemini-2.5-flash",
1480-"gen_ai.operation.name": "generate_content",
1481-}),
1482-expect.objectContaining({
1483-"gen_ai.system": "openai",
1484-"gen_ai.request.model": "gpt-5.4",
1485-"gen_ai.operation.name": "chat",
1486-"error.type": "TimeoutError",
1487-}),
1488-]);
1460+expect(modelCallAttrs).toHaveLength(3);
1461+expect(modelCallAttrs[0]?.["gen_ai.system"]).toBe("openai");
1462+expect(modelCallAttrs[0]?.["gen_ai.request.model"]).toBe("gpt-5.4");
1463+expect(modelCallAttrs[0]?.["gen_ai.operation.name"]).toBe("text_completion");
1464+expect(modelCallAttrs[1]?.["gen_ai.system"]).toBe("google");
1465+expect(modelCallAttrs[1]?.["gen_ai.request.model"]).toBe("gemini-2.5-flash");
1466+expect(modelCallAttrs[1]?.["gen_ai.operation.name"]).toBe("generate_content");
1467+expect(modelCallAttrs[2]?.["gen_ai.system"]).toBe("openai");
1468+expect(modelCallAttrs[2]?.["gen_ai.request.model"]).toBe("gpt-5.4");
1469+expect(modelCallAttrs[2]?.["gen_ai.operation.name"]).toBe("chat");
1470+expect(modelCallAttrs[2]?.["error.type"]).toBe("TimeoutError");
14891471await service.stop?.(ctx);
14901472});
14911473此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。