




























@@ -246,7 +246,7 @@ async function emitAndCaptureLog(
246246});
247247await flushDiagnosticEvents();
248248expect(logEmit).toHaveBeenCalled();
249-const emitCall = logEmit.mock.calls[0]?.[0];
249+const emitCall = logEmit.mock.calls.at(0)?.[0];
250250await service.stop?.(ctx);
251251return emitCall;
252252}
@@ -753,7 +753,7 @@ describe("diagnostics-otel service", () => {
753753const ctx = createTraceOnlyContext("https://www.comet.com/opik/api/v1/private/otel");
754754await service.start(ctx);
755755756-const options = traceExporterCtor.mock.calls[0]?.[0] as { url?: string } | undefined;
756+const options = traceExporterCtor.mock.calls.at(0)?.[0] as { url?: string } | undefined;
757757expect(options?.url).toBe("https://www.comet.com/opik/api/v1/private/otel/v1/traces");
758758await service.stop?.(ctx);
759759});
@@ -763,7 +763,7 @@ describe("diagnostics-otel service", () => {
763763const ctx = createTraceOnlyContext("https://collector.example.com/v1/traces");
764764await service.start(ctx);
765765766-const options = traceExporterCtor.mock.calls[0]?.[0] as { url?: string } | undefined;
766+const options = traceExporterCtor.mock.calls.at(0)?.[0] as { url?: string } | undefined;
767767expect(options?.url).toBe("https://collector.example.com/v1/traces");
768768await service.stop?.(ctx);
769769});
@@ -773,7 +773,7 @@ describe("diagnostics-otel service", () => {
773773const ctx = createTraceOnlyContext("https://collector.example.com/v1/traces?timeout=30s");
774774await service.start(ctx);
775775776-const options = traceExporterCtor.mock.calls[0]?.[0] as { url?: string } | undefined;
776+const options = traceExporterCtor.mock.calls.at(0)?.[0] as { url?: string } | undefined;
777777expect(options?.url).toBe("https://collector.example.com/v1/traces?timeout=30s");
778778await service.stop?.(ctx);
779779});
@@ -783,7 +783,7 @@ describe("diagnostics-otel service", () => {
783783const ctx = createTraceOnlyContext("https://collector.example.com/v1/Traces");
784784await service.start(ctx);
785785786-const options = traceExporterCtor.mock.calls[0]?.[0] as { url?: string } | undefined;
786+const options = traceExporterCtor.mock.calls.at(0)?.[0] as { url?: string } | undefined;
787787expect(options?.url).toBe("https://collector.example.com/v1/Traces");
788788await service.stop?.(ctx);
789789});
@@ -801,9 +801,9 @@ describe("diagnostics-otel service", () => {
801801802802await service.start(ctx);
803803804-const traceOptions = traceExporterCtor.mock.calls[0]?.[0] as { url?: string } | undefined;
805-const metricOptions = metricExporterCtor.mock.calls[0]?.[0] as { url?: string } | undefined;
806-const logOptions = logExporterCtor.mock.calls[0]?.[0] as { url?: string } | undefined;
804+const traceOptions = traceExporterCtor.mock.calls.at(0)?.[0] as { url?: string } | undefined;
805+const metricOptions = metricExporterCtor.mock.calls.at(0)?.[0] as { url?: string } | undefined;
806+const logOptions = logExporterCtor.mock.calls.at(0)?.[0] as { url?: string } | undefined;
807807expect(traceOptions?.url).toBe("https://trace.example.com/otlp/v1/traces");
808808expect(metricOptions?.url).toBe("https://metric.example.com/v1/metrics");
809809expect(logOptions?.url).toBe("https://log.example.com/otlp/v1/logs");
@@ -823,9 +823,9 @@ describe("diagnostics-otel service", () => {
823823});
824824await service.start(ctx);
825825826-const traceOptions = traceExporterCtor.mock.calls[0]?.[0] as { url?: string } | undefined;
827-const metricOptions = metricExporterCtor.mock.calls[0]?.[0] as { url?: string } | undefined;
828-const logOptions = logExporterCtor.mock.calls[0]?.[0] as { url?: string } | undefined;
826+const traceOptions = traceExporterCtor.mock.calls.at(0)?.[0] as { url?: string } | undefined;
827+const metricOptions = metricExporterCtor.mock.calls.at(0)?.[0] as { url?: string } | undefined;
828+const logOptions = logExporterCtor.mock.calls.at(0)?.[0] as { url?: string } | undefined;
829829expect(traceOptions?.url).toBe("https://trace-env.example.com/v1/traces");
830830expect(metricOptions?.url).toBe("https://metric-env.example.com/otlp/v1/metrics");
831831expect(logOptions?.url).toBe("https://log-env.example.com/otlp/v1/logs");
@@ -895,7 +895,7 @@ describe("diagnostics-otel service", () => {
895895);
896896897897expect(telemetryState.tracer.setSpanContext).toHaveBeenCalledTimes(1);
898-const trustedSpanContext = telemetryState.tracer.setSpanContext.mock.calls[0]?.[1] as
898+const trustedSpanContext = telemetryState.tracer.setSpanContext.mock.calls.at(0)?.[1] as
899899| Record<string, unknown>
900900| undefined;
901901expect(trustedSpanContext?.traceId).toBe(TRACE_ID);
@@ -935,7 +935,7 @@ describe("diagnostics-otel service", () => {
935935} as Parameters<typeof emitDiagnosticEvent>[0]);
936936await flushDiagnosticEvents();
937937938-const emitCall = logEmit.mock.calls[0]?.[0];
938+const emitCall = logEmit.mock.calls.at(0)?.[0];
939939expect(emitCall?.body.length).toBeLessThanOrEqual(4200);
940940expect(String(emitCall?.attributes?.["openclaw.good"])).toMatch(/^y+/);
941941expect(emitCall?.attributes?.["code.lineno"]).toBe(42);
@@ -1385,7 +1385,7 @@ describe("diagnostics-otel service", () => {
13851385expect(timeToFirstByte?.[1]?.["openclaw.provider"]).toBe("openai");
13861386expect(timeToFirstByte?.[1]?.["openclaw.model"]).toBe("gpt-5.4");
13871387const modelCallSpan = telemetryState.spans.find((span) => span.name === "openclaw.model.call");
1388-const modelSpanAttributes = modelCallSpan?.setAttributes.mock.calls[0]?.[0] as
1388+const modelSpanAttributes = modelCallSpan?.setAttributes.mock.calls.at(0)?.[0] as
13891389| Record<string, unknown>
13901390| undefined;
13911391expect(modelSpanAttributes?.["openclaw.model_call.request_bytes"]).toBe(1234);
@@ -1411,7 +1411,7 @@ describe("diagnostics-otel service", () => {
14111411code: 2,
14121412message: "TypeError",
14131413});
1414-expect(toolSpan?.end.mock.calls[0]?.[0]).toBeTypeOf("number");
1414+expect(toolSpan?.end.mock.calls.at(0)?.[0]).toBeTypeOf("number");
14151415expect(telemetryState.tracer.setSpanContext).not.toHaveBeenCalled();
14161416await service.stop?.(ctx);
14171417});
@@ -1450,7 +1450,7 @@ describe("diagnostics-otel service", () => {
14501450const span = telemetryState.spans.find(
14511451(candidate) => candidate.name === "openclaw.model.failover",
14521452);
1453-expect(span?.end.mock.calls[0]?.[0]).toBeTypeOf("number");
1453+expect(span?.end.mock.calls.at(0)?.[0]).toBeTypeOf("number");
14541454await service.stop?.(ctx);
14551455});
14561456@@ -1648,7 +1648,7 @@ describe("diagnostics-otel service", () => {
16481648expect(contextOptions?.startTime).toBeTypeOf("number");
16491649expect(JSON.stringify(contextCall)).not.toContain("session-key");
16501650expect(JSON.stringify(contextCall)).not.toContain("prompt text");
1651-const linkedSpanContext = telemetryState.tracer.setSpanContext.mock.calls[0]?.[1] as
1651+const linkedSpanContext = telemetryState.tracer.setSpanContext.mock.calls.at(0)?.[1] as
16521652| Record<string, unknown>
16531653| undefined;
16541654expect(linkedSpanContext?.traceId).toBe(TRACE_ID);
@@ -1942,7 +1942,7 @@ describe("diagnostics-otel service", () => {
19421942(call) => call[0] === "openclaw.model.usage",
19431943);
194419441945-const linkedSpanContext = telemetryState.tracer.setSpanContext.mock.calls[0]?.[1] as
1945+const linkedSpanContext = telemetryState.tracer.setSpanContext.mock.calls.at(0)?.[1] as
19461946| Record<string, unknown>
19471947| undefined;
19481948expect(linkedSpanContext?.traceId).toBe(TRACE_ID);
@@ -1951,7 +1951,7 @@ describe("diagnostics-otel service", () => {
19511951(modelUsageCall?.[2] as { spanContext?: { spanId?: string } } | undefined)?.spanContext
19521952?.spanId,
19531953).toBe(runSpanId);
1954-expect(runSpan?.end.mock.calls[0]?.[0]).toBeTypeOf("number");
1954+expect(runSpan?.end.mock.calls.at(0)?.[0]).toBeTypeOf("number");
19551955await service.stop?.(ctx);
19561956});
19571957@@ -2229,7 +2229,7 @@ describe("diagnostics-otel service", () => {
22292229code: 2,
22302230message: "runtime-error",
22312231});
2232-expect(execSpan?.end.mock.calls[0]?.[0]).toBeTypeOf("number");
2232+expect(execSpan?.end.mock.calls.at(0)?.[0]).toBeTypeOf("number");
22332233await service.stop?.(ctx);
22342234});
22352235@@ -2400,14 +2400,16 @@ describe("diagnostics-otel service", () => {
24002400});
24012401await flushDiagnosticEvents();
240224022403-const recoveryRequestedCall = telemetryState.counters.get("openclaw.session.recovery.requested")
2404-?.add.mock.calls[0];
2403+const recoveryRequestedCall = telemetryState.counters
2404+.get("openclaw.session.recovery.requested")
2405+?.add.mock.calls.at(0);
24052406expect(recoveryRequestedCall?.[0]).toBe(1);
24062407expect(recoveryRequestedCall?.[1]?.["openclaw.state"]).toBe("processing");
24072408expect(recoveryRequestedCall?.[1]?.["openclaw.action"]).toBe("abort");
24082409expect(recoveryRequestedCall?.[1]?.["openclaw.active_work_kind"]).toBe("tool_call");
2409-const recoveryCompletedCall = telemetryState.counters.get("openclaw.session.recovery.completed")
2410-?.add.mock.calls[0];
2410+const recoveryCompletedCall = telemetryState.counters
2411+.get("openclaw.session.recovery.completed")
2412+?.add.mock.calls.at(0);
24112413expect(recoveryCompletedCall?.[0]).toBe(1);
24122414expect(recoveryCompletedCall?.[1]?.["openclaw.state"]).toBe("processing");
24132415expect(recoveryCompletedCall?.[1]?.["openclaw.status"]).toBe("released");
@@ -2597,8 +2599,8 @@ describe("diagnostics-otel service", () => {
25972599});
2598260025992601const sessionCounter = telemetryState.counters.get("openclaw.session.state");
2600-const attrs = sessionCounter?.add.mock.calls[0]?.[1] as Record<string, unknown> | undefined;
2601-expect(sessionCounter?.add.mock.calls[0]?.[0]).toBe(1);
2602+const attrs = sessionCounter?.add.mock.calls.at(0)?.[1] as Record<string, unknown> | undefined;
2603+expect(sessionCounter?.add.mock.calls.at(0)?.[0]).toBe(1);
26022604expect(String(attrs?.["openclaw.reason"])).toContain("…");
26032605expect(typeof attrs?.["openclaw.reason"]).toBe("string");
26042606expect(String(attrs?.["openclaw.reason"])).not.toContain(
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。