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

推荐订阅源

V
V2EX
博客园 - 叶小钗
Last Week in AI
Last Week in AI
Google DeepMind News
Google DeepMind News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Microsoft Security Blog
Microsoft Security Blog
腾讯CDC
P
Proofpoint News Feed
大猫的无限游戏
大猫的无限游戏
The Cloudflare Blog
aimingoo的专栏
aimingoo的专栏
月光博客
月光博客
量子位
A
About on SuperTechFans
Engineering at Meta
Engineering at Meta
Apple Machine Learning Research
Apple Machine Learning Research
Jina AI
Jina AI
博客园 - Franky
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
人人都是产品经理
人人都是产品经理
D
DataBreaches.Net
博客园_首页
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Stack Overflow Blog
Stack Overflow Blog

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
fix(diagnostics): make otel service restart safe · opencl...
vincentkoc · 2026-04-24 · via Recent Commits to openclaw:main

@@ -166,12 +166,14 @@ function createTraceOnlyContext(endpoint: string): OpenClawPluginServiceContext

166166

type RegisteredLogTransport = (logObj: Record<string, unknown>) => void;

167167

function setupRegisteredTransports() {

168168

const registeredTransports: RegisteredLogTransport[] = [];

169-

const stopTransport = vi.fn();

169+

const stopTransports: ReturnType<typeof vi.fn>[] = [];

170170

registerLogTransportMock.mockImplementation((transport) => {

171171

registeredTransports.push(transport);

172+

const stopTransport = vi.fn();

173+

stopTransports.push(stopTransport);

172174

return stopTransport;

173175

});

174-

return { registeredTransports, stopTransport };

176+

return { registeredTransports, stopTransports };

175177

}

176178177179

async function emitAndCaptureLog(logObj: Record<string, unknown>) {

@@ -283,6 +285,73 @@ describe("diagnostics-otel service", () => {

283285

await service.stop?.(ctx);

284286

});

285287288+

test("restarts without retaining prior listeners or log transports", async () => {

289+

const { registeredTransports, stopTransports } = setupRegisteredTransports();

290+291+

const service = createDiagnosticsOtelService();

292+

const ctx = createOtelContext(OTEL_TEST_ENDPOINT, { traces: true, metrics: true, logs: true });

293+

await service.start(ctx);

294+

await service.start(ctx);

295+296+

expect(registerLogTransportMock).toHaveBeenCalledTimes(2);

297+

expect(registeredTransports).toHaveLength(2);

298+

expect(stopTransports[0]).toHaveBeenCalledTimes(1);

299+

expect(logShutdown).toHaveBeenCalledTimes(1);

300+

expect(sdkShutdown).toHaveBeenCalledTimes(1);

301+302+

telemetryState.tracer.startSpan.mockClear();

303+

emitDiagnosticEvent({

304+

type: "message.processed",

305+

channel: "telegram",

306+

outcome: "completed",

307+

durationMs: 10,

308+

});

309+

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

310+311+

await service.stop?.(ctx);

312+

expect(stopTransports[1]).toHaveBeenCalledTimes(1);

313+

expect(logShutdown).toHaveBeenCalledTimes(2);

314+

expect(sdkShutdown).toHaveBeenCalledTimes(2);

315+316+

telemetryState.tracer.startSpan.mockClear();

317+

emitDiagnosticEvent({

318+

type: "message.processed",

319+

channel: "telegram",

320+

outcome: "completed",

321+

durationMs: 10,

322+

});

323+

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

324+

});

325+326+

test("tears down active handles when restarted with diagnostics disabled", async () => {

327+

const { stopTransports } = setupRegisteredTransports();

328+329+

const service = createDiagnosticsOtelService();

330+

const enabledCtx = createOtelContext(OTEL_TEST_ENDPOINT, {

331+

traces: true,

332+

metrics: true,

333+

logs: true,

334+

});

335+

await service.start(enabledCtx);

336+

await service.start({

337+

...enabledCtx,

338+

config: { diagnostics: { enabled: false } },

339+

});

340+341+

expect(stopTransports[0]).toHaveBeenCalledTimes(1);

342+

expect(logShutdown).toHaveBeenCalledTimes(1);

343+

expect(sdkShutdown).toHaveBeenCalledTimes(1);

344+345+

telemetryState.tracer.startSpan.mockClear();

346+

emitDiagnosticEvent({

347+

type: "message.processed",

348+

channel: "telegram",

349+

outcome: "completed",

350+

durationMs: 10,

351+

});

352+

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

353+

});

354+286355

test("appends signal path when endpoint contains non-signal /v1 segment", async () => {

287356

const service = createDiagnosticsOtelService();

288357

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