惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
Simon Willison's Weblog
Simon Willison's Weblog
K
Kaspersky official blog
P
Palo Alto Networks Blog
Google DeepMind News
Google DeepMind News
www.infosecurity-magazine.com
www.infosecurity-magazine.com
AI
AI
G
GRAHAM CLULEY
O
OpenAI News
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Help Net Security
Help Net Security
L
LINUX DO - 热门话题
S
Schneier on Security
P
Privacy International News Feed
L
Lohrmann on Cybersecurity
SecWiki News
SecWiki News
C
Cybersecurity and Infrastructure Security Agency CISA
T
Threatpost
C
Cyber Attacks, Cyber Crime and Cyber Security
A
Arctic Wolf
C
Cisco Blogs
V2EX - 技术
V2EX - 技术
有赞技术团队
有赞技术团队
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
Latest news
Latest news
人人都是产品经理
人人都是产品经理
Schneier on Security
Schneier on Security
Last Week in AI
Last Week in AI
Webroot Blog
Webroot Blog
美团技术团队
N
News and Events Feed by Topic
大猫的无限游戏
大猫的无限游戏
Security Archives - TechRepublic
Security Archives - TechRepublic
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 三生石上(FineUI控件)
The Cloudflare Blog
Project Zero
Project Zero
博客园_首页
Cloudbric
Cloudbric
IT之家
IT之家
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
雷峰网
雷峰网
罗磊的独立博客
Hacker News: Ask HN
Hacker News: Ask HN
The Last Watchdog
The Last Watchdog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Tenable Blog
Scott Helme
Scott Helme

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4 test: trim doctor command hotspots · openclaw/openclaw@c66f16a test: isolate agent auth and spawn hotspots · openclaw/openclaw@9285935 test: stabilize MCP startup disposal race · openclaw/openclaw@dd9d2eb test: merge browser contract server suites · openclaw/openclaw@5817a76 test: narrow ollama provider discovery setup · openclaw/openclaw@a0d9598 build: declare qa-lab aimock runtime dependency · openclaw/openclaw@24431e5 test: speed up safe-bins exec harness · openclaw/openclaw@ee856ab test: preserve tool helpers in embedded runner mocks · openclaw/openclaw@acd86a0 refactor: move memory embeddings into provider plugins · openclaw/openclaw@77e6e4c test: reuse system-run temp fixtures · openclaw/openclaw@7e9ff0f test: trim hotspot wait overhead · openclaw/openclaw@12a59b0 Check: avoid duplicate boundary prep · openclaw/openclaw@baf11b8 test: reduce hotspot fixture overhead · openclaw/openclaw@3a59edd feat(ui): overhaul settings and slash command UX (#67819) thanks @Bun… · openclaw/openclaw@2cfb660 QA Matrix: exit cleanly on failure · openclaw/openclaw@42805d2 QA Matrix: isolate scenario coverage · openclaw/openclaw@7e659e1 Matrix: refresh crypto bootstrap state · openclaw/openclaw@94081d8 QA Lab: add provider registry · openclaw/openclaw@bb7e982 Matrix: add plugin changelog · openclaw/openclaw@4acab55 test: trim more hotspot overhead · openclaw/openclaw@f485311 test: trim remaining hotspot tests · openclaw/openclaw@6ba8626 test: narrow hotspot mocks · openclaw/openclaw@dbc8179 test: isolate gemini embedding request helpers · openclaw/openclaw@cd330f5 test: trim memory and mcp hotspots · openclaw/openclaw@fd48dfa test: slim provider registry mocks · openclaw/openclaw@2e08c77 test: harden Parallels update smoke · openclaw/openclaw@1a98090 feat: default Anthropic to Opus 4.7 · openclaw/openclaw@628b454 fix: harden node-host shell payload mutability checks · openclaw/openclaw@75c551e fix: land node-host approval binding for native binaries (#66731) (th… · openclaw/openclaw@29919bb CI: add daily schedule to CodeQL workflow (#67645) · openclaw/openclaw@69d25f5 fix(gateway): capture config hash after plugin auto-enable to prevent… · openclaw/openclaw@8c11210 fix: repair sanitized replay tool results before send (#67620) (thank… · openclaw/openclaw@c3c7a99 fix: restrict HTML timeout short-circuit to transient statuses · openclaw/openclaw@de129a6 fix: keep TUI watchdog bound to active run (#67401) (thanks @xantorres) · openclaw/openclaw@3525273 Gateway/skills: dedupe skills prefix-match + drop dead fallback on log · openclaw/openclaw@d7f489f Extensions/lmstudio: back off inference preload after consecutive fai… · openclaw/openclaw@b555214 TUI/streaming: add watchdog that resets the activity indicator after … · openclaw/openclaw@f44ab20 Agents/tool-loop: enable unknown-tool stream guard by default · openclaw/openclaw@36ed367 Gateway/skills: invalidate session skills snapshot on config write · openclaw/openclaw@b23d59a fix: classify HTML provider error pages correctly (#67642) (thanks @s… · openclaw/openclaw@e588e90 fix(skills): remove unused model-usage import (#67641) · openclaw/openclaw@55f05df docs(changelog): credit codex fix superseded PRs · openclaw/openclaw@e485f24 fix(openai-codex): normalize stale transport metadata in resolution a… · openclaw/openclaw@90801ba CI: pin Docker-related GitHub Actions (#67632) · openclaw/openclaw@f697b01 Android: modernize WebView and discovery API usage (#67627) · openclaw/openclaw@44a6e50 fix(deps): bump hono to 4.12.14 and @hono/node-server to 1.19.14 (GHS… · openclaw/openclaw@fbccc18 fix(deps): bump dompurify to 3.4.0 (#67614) · openclaw/openclaw@2c2dc00 CI: add explicit permissions to all workflow jobs (fixes code-scannin… · openclaw/openclaw@01b7516 fix: register bundled TTS providers and route overrides correctly (#6… · openclaw/openclaw@6ea3cdd fix: align host tilde paths with OS home (#62804) (thanks @stainlu) · openclaw/openclaw@ecfaf64 fix: flush creds queue before reconnect socket open (#67464) (thanks … · openclaw/openclaw@405c63f fix: strip standalone <function> tool call tags from visible text (#6… · openclaw/openclaw@78df859 fix(agents): preserve cli session metadata before transcript persist … · openclaw/openclaw@898fd04 docs(changelog): move cli transcript entry · openclaw/openclaw@c1817c6 fix(agents): normalize cli transcript api field · openclaw/openclaw@3a3fae0 docs(changelog): note cli transcript persistence · openclaw/openclaw@6c343f1 fix(agents): persist cli transcript turns · openclaw/openclaw@b8ef507 fix(msteams): harden security-sensitive flows (#65841) · openclaw/openclaw@c56b56e [Dashboard] Fix exec approval modal overflow for long command content… · openclaw/openclaw@053c5b0 Docs: remove QA changelog entry · openclaw/openclaw@7fd5771 QA: fix private runtime source loading (#67428) · openclaw/openclaw@d5933af docs(gateway): correct protocol.md schema path, hello-ok example, aut… · openclaw/openclaw@489404d CI: pin Node 22 runners to 22.18.0 · openclaw/openclaw@4ffa621 models.authStatus: normalize provider ids + tighten env-backed escape… · openclaw/openclaw@f2fdb9d Update CHANGELOG.md · openclaw/openclaw@7694a92 test(parallels): clean up npm update guard jobs · openclaw/openclaw@045ea7b Plugins: prefer scanDir override paths · openclaw/openclaw@b2974da fix(dreaming): default storage.mode to "separate" so phase blocks sto… · openclaw/openclaw@8c392f0 fix(memory-core): skip dreaming transcript ingestion via session stor… · openclaw/openclaw@a1b01f0 fix: dedupe replayed exec.finished node events (#67281) · openclaw/openclaw@5dcf526
test: dedupe diagnostics otel mock calls · openclaw/openclaw@a8bc83e
steipete · 2026-05-13 · via Recent Commits to openclaw:main

@@ -216,6 +216,50 @@ function startedSpanOptions(name: string) {

216216

return startedSpanCall(name)?.[1];

217217

}

218218219+

function mockCall(mock: { mock: { calls: unknown[][] } }, callIndex = 0): unknown[] {

220+

const call = mock.mock.calls.at(callIndex);

221+

if (!call) {

222+

throw new Error(`Expected mock call at index ${callIndex}`);

223+

}

224+

return call;

225+

}

226+227+

function mockCallArg(mock: { mock: { calls: unknown[][] } }, argIndex: number, callIndex = 0) {

228+

return mockCall(mock, callIndex)[argIndex];

229+

}

230+231+

function firstExporterOptions(mock: { mock: { calls: unknown[][] } }): { url?: string } {

232+

return mockCallArg(mock, 0) as { url?: string };

233+

}

234+235+

function firstSetSpanContext(): Record<string, unknown> {

236+

return mockCallArg(telemetryState.tracer.setSpanContext, 1) as Record<string, unknown>;

237+

}

238+239+

function spanByName(name: string): (typeof telemetryState.spans)[number] {

240+

const span = telemetryState.spans.find((candidate) => candidate.name === name);

241+

if (!span) {

242+

throw new Error(`Expected span ${name}`);

243+

}

244+

return span;

245+

}

246+247+

function firstSpanAttributes(name: string): Record<string, unknown> {

248+

return mockCallArg(spanByName(name).setAttributes, 0) as Record<string, unknown>;

249+

}

250+251+

function firstSpanEndTime(name: string): unknown {

252+

return mockCallArg(spanByName(name).end, 0);

253+

}

254+255+

function firstCounterAddCall(name: string): [unknown, Record<string, unknown>?] {

256+

const counter = telemetryState.counters.get(name);

257+

if (!counter) {

258+

throw new Error(`Expected counter ${name}`);

259+

}

260+

return mockCall(counter.add) as [unknown, Record<string, unknown>?];

261+

}

262+219263

function lastHistogramRecord(name: string) {

220264

return telemetryState.histograms.get(name)?.record.mock.calls.at(-1) as

221265

| [unknown, Record<string, unknown>?]

@@ -246,7 +290,11 @@ async function emitAndCaptureLog(

246290

});

247291

await flushDiagnosticEvents();

248292

expect(logEmit).toHaveBeenCalled();

249-

const emitCall = logEmit.mock.calls.at(0)?.[0];

293+

const emitCall = mockCallArg(logEmit, 0) as {

294+

attributes?: Record<string, unknown>;

295+

body?: string;

296+

context?: unknown;

297+

};

250298

await service.stop?.(ctx);

251299

return emitCall;

252300

}

@@ -753,8 +801,8 @@ describe("diagnostics-otel service", () => {

753801

const ctx = createTraceOnlyContext("https://www.comet.com/opik/api/v1/private/otel");

754802

await service.start(ctx);

755803756-

const options = traceExporterCtor.mock.calls.at(0)?.[0] as { url?: string } | undefined;

757-

expect(options?.url).toBe("https://www.comet.com/opik/api/v1/private/otel/v1/traces");

804+

const options = firstExporterOptions(traceExporterCtor);

805+

expect(options.url).toBe("https://www.comet.com/opik/api/v1/private/otel/v1/traces");

758806

await service.stop?.(ctx);

759807

});

760808

@@ -763,8 +811,8 @@ describe("diagnostics-otel service", () => {

763811

const ctx = createTraceOnlyContext("https://collector.example.com/v1/traces");

764812

await service.start(ctx);

765813766-

const options = traceExporterCtor.mock.calls.at(0)?.[0] as { url?: string } | undefined;

767-

expect(options?.url).toBe("https://collector.example.com/v1/traces");

814+

const options = firstExporterOptions(traceExporterCtor);

815+

expect(options.url).toBe("https://collector.example.com/v1/traces");

768816

await service.stop?.(ctx);

769817

});

770818

@@ -773,8 +821,8 @@ describe("diagnostics-otel service", () => {

773821

const ctx = createTraceOnlyContext("https://collector.example.com/v1/traces?timeout=30s");

774822

await service.start(ctx);

775823776-

const options = traceExporterCtor.mock.calls.at(0)?.[0] as { url?: string } | undefined;

777-

expect(options?.url).toBe("https://collector.example.com/v1/traces?timeout=30s");

824+

const options = firstExporterOptions(traceExporterCtor);

825+

expect(options.url).toBe("https://collector.example.com/v1/traces?timeout=30s");

778826

await service.stop?.(ctx);

779827

});

780828

@@ -783,8 +831,8 @@ describe("diagnostics-otel service", () => {

783831

const ctx = createTraceOnlyContext("https://collector.example.com/v1/Traces");

784832

await service.start(ctx);

785833786-

const options = traceExporterCtor.mock.calls.at(0)?.[0] as { url?: string } | undefined;

787-

expect(options?.url).toBe("https://collector.example.com/v1/Traces");

834+

const options = firstExporterOptions(traceExporterCtor);

835+

expect(options.url).toBe("https://collector.example.com/v1/Traces");

788836

await service.stop?.(ctx);

789837

});

790838

@@ -801,12 +849,12 @@ describe("diagnostics-otel service", () => {

801849802850

await service.start(ctx);

803851804-

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;

807-

expect(traceOptions?.url).toBe("https://trace.example.com/otlp/v1/traces");

808-

expect(metricOptions?.url).toBe("https://metric.example.com/v1/metrics");

809-

expect(logOptions?.url).toBe("https://log.example.com/otlp/v1/logs");

852+

const traceOptions = firstExporterOptions(traceExporterCtor);

853+

const metricOptions = firstExporterOptions(metricExporterCtor);

854+

const logOptions = firstExporterOptions(logExporterCtor);

855+

expect(traceOptions.url).toBe("https://trace.example.com/otlp/v1/traces");

856+

expect(metricOptions.url).toBe("https://metric.example.com/v1/metrics");

857+

expect(logOptions.url).toBe("https://log.example.com/otlp/v1/logs");

810858

await service.stop?.(ctx);

811859

});

812860

@@ -823,12 +871,12 @@ describe("diagnostics-otel service", () => {

823871

});

824872

await service.start(ctx);

825873826-

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;

829-

expect(traceOptions?.url).toBe("https://trace-env.example.com/v1/traces");

830-

expect(metricOptions?.url).toBe("https://metric-env.example.com/otlp/v1/metrics");

831-

expect(logOptions?.url).toBe("https://log-env.example.com/otlp/v1/logs");

874+

const traceOptions = firstExporterOptions(traceExporterCtor);

875+

const metricOptions = firstExporterOptions(metricExporterCtor);

876+

const logOptions = firstExporterOptions(logExporterCtor);

877+

expect(traceOptions.url).toBe("https://trace-env.example.com/v1/traces");

878+

expect(metricOptions.url).toBe("https://metric-env.example.com/otlp/v1/metrics");

879+

expect(logOptions.url).toBe("https://log-env.example.com/otlp/v1/logs");

832880

await service.stop?.(ctx);

833881

});

834882

@@ -895,13 +943,11 @@ describe("diagnostics-otel service", () => {

895943

);

896944897945

expect(telemetryState.tracer.setSpanContext).toHaveBeenCalledTimes(1);

898-

const trustedSpanContext = telemetryState.tracer.setSpanContext.mock.calls.at(0)?.[1] as

899-

| Record<string, unknown>

900-

| undefined;

901-

expect(trustedSpanContext?.traceId).toBe(TRACE_ID);

902-

expect(trustedSpanContext?.spanId).toBe(SPAN_ID);

903-

expect(trustedSpanContext?.traceFlags).toBe(1);

904-

expect(trustedSpanContext?.isRemote).toBe(true);

946+

const trustedSpanContext = firstSetSpanContext();

947+

expect(trustedSpanContext.traceId).toBe(TRACE_ID);

948+

expect(trustedSpanContext.spanId).toBe(SPAN_ID);

949+

expect(trustedSpanContext.traceFlags).toBe(1);

950+

expect(trustedSpanContext.isRemote).toBe(true);

905951

const emitContext = emitCall?.context as { spanContext?: Record<string, unknown> } | undefined;

906952

const emitSpanContext = emitContext?.spanContext;

907953

expect(emitSpanContext?.traceId).toBe(TRACE_ID);

@@ -935,24 +981,27 @@ describe("diagnostics-otel service", () => {

935981

} as Parameters<typeof emitDiagnosticEvent>[0]);

936982

await flushDiagnosticEvents();

937983938-

const emitCall = logEmit.mock.calls.at(0)?.[0];

939-

expect(emitCall?.body.length).toBeLessThanOrEqual(4200);

940-

expect(String(emitCall?.attributes?.["openclaw.good"])).toMatch(/^y+/);

941-

expect(emitCall?.attributes?.["code.lineno"]).toBe(42);

942-

expect(emitCall?.attributes?.["code.function"]).toBe("handler");

943-

expect(String(emitCall?.attributes?.["openclaw.good"]).length).toBeLessThanOrEqual(4200);

944-

expect(Object.hasOwn(emitCall?.attributes ?? {}, `openclaw.${PROTO_KEY}`)).toBe(false);

945-

expect(Object.hasOwn(emitCall?.attributes ?? {}, "openclaw.constructor")).toBe(false);

946-

expect(Object.hasOwn(emitCall?.attributes ?? {}, "openclaw.prototype")).toBe(false);

984+

const emitCall = mockCallArg(logEmit, 0) as {

985+

attributes: Record<string, unknown>;

986+

body: string;

987+

};

988+

expect(emitCall.body.length).toBeLessThanOrEqual(4200);

989+

expect(String(emitCall.attributes["openclaw.good"])).toMatch(/^y+/);

990+

expect(emitCall.attributes["code.lineno"]).toBe(42);

991+

expect(emitCall.attributes["code.function"]).toBe("handler");

992+

expect(String(emitCall.attributes["openclaw.good"]).length).toBeLessThanOrEqual(4200);

993+

expect(Object.hasOwn(emitCall.attributes, `openclaw.${PROTO_KEY}`)).toBe(false);

994+

expect(Object.hasOwn(emitCall.attributes, "openclaw.constructor")).toBe(false);

995+

expect(Object.hasOwn(emitCall.attributes, "openclaw.prototype")).toBe(false);

947996

expect(

948997

Object.hasOwn(

949-

emitCall?.attributes ?? {},

998+

emitCall.attributes,

950999

"openclaw.sk-1234567890abcdef1234567890abcdef", // pragma: allowlist secret

9511000

),

9521001

).toBe(false);

953-

expect(Object.hasOwn(emitCall?.attributes ?? {}, "openclaw.bad key")).toBe(false);

954-

expect(Object.hasOwn(emitCall?.attributes ?? {}, "code.filepath")).toBe(false);

955-

expect(Object.hasOwn(emitCall?.attributes ?? {}, "openclaw.code.location")).toBe(false);

1002+

expect(Object.hasOwn(emitCall.attributes, "openclaw.bad key")).toBe(false);

1003+

expect(Object.hasOwn(emitCall.attributes, "code.filepath")).toBe(false);

1004+

expect(Object.hasOwn(emitCall.attributes, "openclaw.code.location")).toBe(false);

9561005

await service.stop?.(ctx);

9571006

});

9581007

@@ -1384,13 +1433,10 @@ describe("diagnostics-otel service", () => {

13841433

expect(timeToFirstByte?.[0]).toBe(45);

13851434

expect(timeToFirstByte?.[1]?.["openclaw.provider"]).toBe("openai");

13861435

expect(timeToFirstByte?.[1]?.["openclaw.model"]).toBe("gpt-5.4");

1387-

const modelCallSpan = telemetryState.spans.find((span) => span.name === "openclaw.model.call");

1388-

const modelSpanAttributes = modelCallSpan?.setAttributes.mock.calls.at(0)?.[0] as

1389-

| Record<string, unknown>

1390-

| undefined;

1391-

expect(modelSpanAttributes?.["openclaw.model_call.request_bytes"]).toBe(1234);

1392-

expect(modelSpanAttributes?.["openclaw.model_call.response_bytes"]).toBe(567);

1393-

expect(modelSpanAttributes?.["openclaw.model_call.time_to_first_byte_ms"]).toBe(45);

1436+

const modelSpanAttributes = firstSpanAttributes("openclaw.model.call");

1437+

expect(modelSpanAttributes["openclaw.model_call.request_bytes"]).toBe(1234);

1438+

expect(modelSpanAttributes["openclaw.model_call.response_bytes"]).toBe(567);

1439+

expect(modelSpanAttributes["openclaw.model_call.time_to_first_byte_ms"]).toBe(45);

13941440

const runDuration = lastHistogramRecord("openclaw.run.duration_ms");

13951441

expect(runDuration?.[0]).toBe(100);

13961442

expect(Object.hasOwn(runDuration?.[1] ?? {}, "openclaw.runId")).toBe(false);

@@ -1406,12 +1452,12 @@ describe("diagnostics-otel service", () => {

14061452

expect(Object.hasOwn(toolDuration?.[1] ?? {}, "openclaw.errorCode")).toBe(false);

14071453

expect(Object.hasOwn(toolDuration?.[1] ?? {}, "openclaw.runId")).toBe(false);

140814541409-

const toolSpan = telemetryState.spans.find((span) => span.name === "openclaw.tool.execution");

1455+

const toolSpan = spanByName("openclaw.tool.execution");

14101456

expect(toolSpan?.setStatus).toHaveBeenCalledWith({

14111457

code: 2,

14121458

message: "TypeError",

14131459

});

1414-

expect(toolSpan?.end.mock.calls.at(0)?.[0]).toBeTypeOf("number");

1460+

expect(firstSpanEndTime("openclaw.tool.execution")).toBeTypeOf("number");

14151461

expect(telemetryState.tracer.setSpanContext).not.toHaveBeenCalled();

14161462

await service.stop?.(ctx);

14171463

});

@@ -1447,10 +1493,7 @@ describe("diagnostics-otel service", () => {

14471493

expect(Object.hasOwn(failoverOptions?.attributes ?? {}, "openclaw.sessionId")).toBe(false);

14481494

expect(Object.hasOwn(failoverOptions?.attributes ?? {}, "openclaw.sessionKey")).toBe(false);

14491495

expect(failoverOptions?.startTime).toBeTypeOf("number");

1450-

const span = telemetryState.spans.find(

1451-

(candidate) => candidate.name === "openclaw.model.failover",

1452-

);

1453-

expect(span?.end.mock.calls.at(0)?.[0]).toBeTypeOf("number");

1496+

expect(firstSpanEndTime("openclaw.model.failover")).toBeTypeOf("number");

14541497

await service.stop?.(ctx);

14551498

});

14561499

@@ -1648,11 +1691,9 @@ describe("diagnostics-otel service", () => {

16481691

expect(contextOptions?.startTime).toBeTypeOf("number");

16491692

expect(JSON.stringify(contextCall)).not.toContain("session-key");

16501693

expect(JSON.stringify(contextCall)).not.toContain("prompt text");

1651-

const linkedSpanContext = telemetryState.tracer.setSpanContext.mock.calls.at(0)?.[1] as

1652-

| Record<string, unknown>

1653-

| undefined;

1654-

expect(linkedSpanContext?.traceId).toBe(TRACE_ID);

1655-

expect(linkedSpanContext?.spanId).toBe(runSpanId);

1694+

const linkedSpanContext = firstSetSpanContext();

1695+

expect(linkedSpanContext.traceId).toBe(TRACE_ID);

1696+

expect(linkedSpanContext.spanId).toBe(runSpanId);

16561697

expect(

16571698

(contextCall?.[2] as { spanContext?: { spanId?: string } } | undefined)?.spanContext?.spanId,

16581699

).toBe(runSpanId);

@@ -1942,16 +1983,14 @@ describe("diagnostics-otel service", () => {

19421983

(call) => call[0] === "openclaw.model.usage",

19431984

);

194419851945-

const linkedSpanContext = telemetryState.tracer.setSpanContext.mock.calls.at(0)?.[1] as

1946-

| Record<string, unknown>

1947-

| undefined;

1948-

expect(linkedSpanContext?.traceId).toBe(TRACE_ID);

1949-

expect(linkedSpanContext?.spanId).toBe(runSpanId);

1986+

const linkedSpanContext = firstSetSpanContext();

1987+

expect(linkedSpanContext.traceId).toBe(TRACE_ID);

1988+

expect(linkedSpanContext.spanId).toBe(runSpanId);

19501989

expect(

19511990

(modelUsageCall?.[2] as { spanContext?: { spanId?: string } } | undefined)?.spanContext

19521991

?.spanId,

19531992

).toBe(runSpanId);

1954-

expect(runSpan?.end.mock.calls.at(0)?.[0]).toBeTypeOf("number");

1993+

expect(firstSpanEndTime("openclaw.run")).toBeTypeOf("number");

19551994

await service.stop?.(ctx);

19561995

});

19571996

@@ -2224,12 +2263,12 @@ describe("diagnostics-otel service", () => {

22242263

expect(Object.hasOwn(execOptions?.attributes ?? {}, "openclaw.sessionKey")).toBe(false);

22252264

expect(execOptions?.startTime).toBeTypeOf("number");

222622652227-

const execSpan = telemetryState.spans.find((span) => span.name === "openclaw.exec");

2266+

const execSpan = spanByName("openclaw.exec");

22282267

expect(execSpan?.setStatus).toHaveBeenCalledWith({

22292268

code: 2,

22302269

message: "runtime-error",

22312270

});

2232-

expect(execSpan?.end.mock.calls.at(0)?.[0]).toBeTypeOf("number");

2271+

expect(firstSpanEndTime("openclaw.exec")).toBeTypeOf("number");

22332272

await service.stop?.(ctx);

22342273

});

22352274

@@ -2400,20 +2439,16 @@ describe("diagnostics-otel service", () => {

24002439

});

24012440

await flushDiagnosticEvents();

240224412403-

const recoveryRequestedCall = telemetryState.counters

2404-

.get("openclaw.session.recovery.requested")

2405-

?.add.mock.calls.at(0);

2406-

expect(recoveryRequestedCall?.[0]).toBe(1);

2407-

expect(recoveryRequestedCall?.[1]?.["openclaw.state"]).toBe("processing");

2408-

expect(recoveryRequestedCall?.[1]?.["openclaw.action"]).toBe("abort");

2409-

expect(recoveryRequestedCall?.[1]?.["openclaw.active_work_kind"]).toBe("tool_call");

2410-

const recoveryCompletedCall = telemetryState.counters

2411-

.get("openclaw.session.recovery.completed")

2412-

?.add.mock.calls.at(0);

2413-

expect(recoveryCompletedCall?.[0]).toBe(1);

2414-

expect(recoveryCompletedCall?.[1]?.["openclaw.state"]).toBe("processing");

2415-

expect(recoveryCompletedCall?.[1]?.["openclaw.status"]).toBe("released");

2416-

expect(recoveryCompletedCall?.[1]?.["openclaw.action"]).toBe("abort-active-run");

2442+

const recoveryRequestedCall = firstCounterAddCall("openclaw.session.recovery.requested");

2443+

expect(recoveryRequestedCall[0]).toBe(1);

2444+

expect(recoveryRequestedCall[1]?.["openclaw.state"]).toBe("processing");

2445+

expect(recoveryRequestedCall[1]?.["openclaw.action"]).toBe("abort");

2446+

expect(recoveryRequestedCall[1]?.["openclaw.active_work_kind"]).toBe("tool_call");

2447+

const recoveryCompletedCall = firstCounterAddCall("openclaw.session.recovery.completed");

2448+

expect(recoveryCompletedCall[0]).toBe(1);

2449+

expect(recoveryCompletedCall[1]?.["openclaw.state"]).toBe("processing");

2450+

expect(recoveryCompletedCall[1]?.["openclaw.status"]).toBe("released");

2451+

expect(recoveryCompletedCall[1]?.["openclaw.action"]).toBe("abort-active-run");

24172452

const recoveryAgeRecord = lastHistogramRecord("openclaw.session.recovery.age_ms");

24182453

expect(recoveryAgeRecord?.[0]).toBe(13_000);

24192454

expect(recoveryAgeRecord?.[1]?.["openclaw.status"]).toBe("released");

@@ -2598,9 +2633,9 @@ describe("diagnostics-otel service", () => {

25982633

reason: "token=ghp_abcdefghijklmnopqrstuvwxyz123456", // pragma: allowlist secret

25992634

});

260026352601-

const sessionCounter = telemetryState.counters.get("openclaw.session.state");

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);

2636+

const sessionStateCall = firstCounterAddCall("openclaw.session.state");

2637+

const attrs = sessionStateCall[1];

2638+

expect(sessionStateCall[0]).toBe(1);

26042639

expect(String(attrs?.["openclaw.reason"])).toContain("…");

26052640

expect(typeof attrs?.["openclaw.reason"]).toBe("string");

26062641

expect(String(attrs?.["openclaw.reason"])).not.toContain(