






















@@ -769,7 +769,7 @@ describe("diagnostics-otel service", () => {
769769expect(modelUsageCall?.[1]).toMatchObject({
770770attributes: {
771771"gen_ai.operation.name": "chat",
772-"gen_ai.provider.name": "anthropic",
772+"gen_ai.system": "anthropic",
773773"gen_ai.request.model": "claude-sonnet-4.6",
774774"gen_ai.usage.input_tokens": 150,
775775"gen_ai.usage.output_tokens": 40,
@@ -781,6 +781,7 @@ describe("diagnostics-otel service", () => {
781781attributes: expect.not.objectContaining({
782782"openclaw.sessionKey": expect.anything(),
783783"openclaw.sessionId": expect.anything(),
784+"gen_ai.provider.name": expect.anything(),
784785"gen_ai.input.messages": expect.anything(),
785786"gen_ai.output.messages": expect.anything(),
786787}),
@@ -1082,6 +1083,13 @@ describe("diagnostics-otel service", () => {
10821083api: "openai-completions",
10831084durationMs: 80,
10841085});
1086+emitDiagnosticEvent({
1087+type: "model.usage",
1088+provider: "openai",
1089+model: "gpt-5.4",
1090+usage: { input: 3, output: 2 },
1091+durationMs: 10,
1092+});
10851093await flushDiagnosticEvents();
1086109410871095const modelCall = telemetryState.tracer.startSpan.mock.calls.find(
@@ -1100,6 +1108,22 @@ describe("diagnostics-otel service", () => {
11001108}),
11011109startTime: expect.any(Number),
11021110});
1111+const modelUsage = telemetryState.tracer.startSpan.mock.calls.find(
1112+(call) => call[0] === "openclaw.model.usage",
1113+);
1114+expect(modelUsage?.[1]).toMatchObject({
1115+attributes: {
1116+"gen_ai.provider.name": "openai",
1117+"gen_ai.request.model": "gpt-5.4",
1118+"gen_ai.operation.name": "chat",
1119+},
1120+});
1121+expect(modelUsage?.[1]).toEqual({
1122+attributes: expect.not.objectContaining({
1123+"gen_ai.system": expect.anything(),
1124+}),
1125+startTime: expect.any(Number),
1126+});
11031127await service.stop?.(ctx);
11041128});
11051129此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。