fix: gate diagnostics timeline by flag · openclaw/openclaw@d001c34
shakkernerd
·
2026-04-30
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -112,7 +112,7 @@ Inline `--password` can be exposed in local process listings. Prefer `--password
|
112 | 112 | ### Startup profiling |
113 | 113 | |
114 | 114 | - Set `OPENCLAW_GATEWAY_STARTUP_TRACE=1` to log phase timings during Gateway startup, including per-phase `eventLoopMax` delay and plugin lookup-table timings for installed-index, manifest registry, startup planning, and owner-map work. |
115 | | -- Set `OPENCLAW_DIAGNOSTICS=1` with `OPENCLAW_DIAGNOSTICS_TIMELINE_PATH=<path>` to write a best-effort JSONL startup diagnostics timeline for external QA harnesses. Add `OPENCLAW_DIAGNOSTICS_EVENT_LOOP=1` to include event-loop samples. |
| 115 | +- Set `OPENCLAW_DIAGNOSTICS=timeline` with `OPENCLAW_DIAGNOSTICS_TIMELINE_PATH=<path>` to write a best-effort JSONL startup diagnostics timeline for external QA harnesses. Add `OPENCLAW_DIAGNOSTICS_EVENT_LOOP=1` to include event-loop samples. |
116 | 116 | - Run `pnpm test:startup:gateway -- --runs 5 --warmup 1` to benchmark Gateway startup. The benchmark records first process output, `/healthz`, `/readyz`, startup trace timings, event-loop delay, and plugin lookup-table timing details. |
117 | 117 | |
118 | 118 | ## Query a running Gateway |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -50,6 +50,28 @@ Disable all flags:
|
50 | 50 | OPENCLAW_DIAGNOSTICS=0 |
51 | 51 | ``` |
52 | 52 | |
| 53 | +## Timeline artifacts |
| 54 | + |
| 55 | +The `timeline` flag writes structured startup and runtime timing events for |
| 56 | +external QA harnesses: |
| 57 | + |
| 58 | +```bash |
| 59 | +OPENCLAW_DIAGNOSTICS=timeline \ |
| 60 | +OPENCLAW_DIAGNOSTICS_TIMELINE_PATH=/tmp/openclaw-timeline.jsonl \ |
| 61 | +openclaw gateway run |
| 62 | +``` |
| 63 | + |
| 64 | +`OPENCLAW_DIAGNOSTICS=1`, `OPENCLAW_DIAGNOSTICS=all`, and |
| 65 | +`OPENCLAW_DIAGNOSTICS=*` also enable the timeline because they enable every |
| 66 | +diagnostics flag. Prefer `timeline` when you only want the JSONL timing |
| 67 | +artifact. |
| 68 | + |
| 69 | +Timeline records use the `openclaw.diagnostics.v1` envelope. Events can include |
| 70 | +process ids, phase names, span names, durations, plugin ids, dependency counts, |
| 71 | +event-loop delay samples, provider operation names, child-process exit state, |
| 72 | +and startup error names/messages. Treat timeline files as local diagnostics |
| 73 | +artifacts; review them before sharing outside your machine. |
| 74 | + |
53 | 75 | ## Where logs go |
54 | 76 | |
55 | 77 | Flags emit logs into the standard diagnostics log file. By default: |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -17,7 +17,7 @@ async function createTimelineEnv() {
|
17 | 17 | tempDirs.push(dir); |
18 | 18 | return { |
19 | 19 | env: { |
20 | | -OPENCLAW_DIAGNOSTICS: "1", |
| 20 | +OPENCLAW_DIAGNOSTICS: "timeline", |
21 | 21 | OPENCLAW_DIAGNOSTICS_RUN_ID: "run-1", |
22 | 22 | OPENCLAW_DIAGNOSTICS_ENV: "env-1", |
23 | 23 | OPENCLAW_DIAGNOSTICS_TIMELINE_PATH: join(dir, "nested", "timeline.jsonl"), |
@@ -43,6 +43,15 @@ describe("diagnostics timeline", () => {
|
43 | 43 | const { env } = await createTimelineEnv(); |
44 | 44 | |
45 | 45 | expect(isDiagnosticsTimelineEnabled(env)).toBe(true); |
| 46 | +expect(isDiagnosticsTimelineEnabled({ ...env, OPENCLAW_DIAGNOSTICS: "1" })).toBe(true); |
| 47 | +expect(isDiagnosticsTimelineEnabled({ ...env, OPENCLAW_DIAGNOSTICS: "all" })).toBe(true); |
| 48 | +expect(isDiagnosticsTimelineEnabled({ ...env, OPENCLAW_DIAGNOSTICS: "*" })).toBe(true); |
| 49 | +expect( |
| 50 | +isDiagnosticsTimelineEnabled({ ...env, OPENCLAW_DIAGNOSTICS: "diagnostics.timeline" }), |
| 51 | +).toBe(true); |
| 52 | +expect(isDiagnosticsTimelineEnabled({ ...env, OPENCLAW_DIAGNOSTICS: "telegram.http" })).toBe( |
| 53 | +false, |
| 54 | +); |
46 | 55 | expect(isDiagnosticsTimelineEnabled({ ...env, OPENCLAW_DIAGNOSTICS: "0" })).toBe(false); |
47 | 56 | expect(isDiagnosticsTimelineEnabled({ ...env, OPENCLAW_DIAGNOSTICS_TIMELINE_PATH: "" })).toBe( |
48 | 57 | false, |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -2,7 +2,7 @@ import { randomUUID } from "node:crypto";
|
2 | 2 | import { appendFileSync, mkdirSync } from "node:fs"; |
3 | 3 | import { dirname } from "node:path"; |
4 | 4 | import { performance } from "node:perf_hooks"; |
5 | | -import { isTruthyEnvValue } from "./env.js"; |
| 5 | +import { isDiagnosticFlagEnabled } from "./diagnostic-flags.js"; |
6 | 6 | |
7 | 7 | export const OPENCLAW_DIAGNOSTICS_TIMELINE_SCHEMA_VERSION = "openclaw.diagnostics.v1"; |
8 | 8 | |
@@ -56,7 +56,8 @@ const createdTimelineDirs = new Set<string>();
|
56 | 56 | |
57 | 57 | export function isDiagnosticsTimelineEnabled(env: NodeJS.ProcessEnv = process.env): boolean { |
58 | 58 | return ( |
59 | | -isTruthyEnvValue(env.OPENCLAW_DIAGNOSTICS) && |
| 59 | +(isDiagnosticFlagEnabled("timeline", undefined, env) || |
| 60 | +isDiagnosticFlagEnabled("diagnostics.timeline", undefined, env)) && |
60 | 61 | typeof env.OPENCLAW_DIAGNOSTICS_TIMELINE_PATH === "string" && |
61 | 62 | env.OPENCLAW_DIAGNOSTICS_TIMELINE_PATH.trim().length > 0 |
62 | 63 | ); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。