Repository navigation
feat(telemetry): send startup events directly from the server process - #3511
Merged
yulunz merged 1 commit intoNov 18, 2026
Conversation
yulunz
force-pushed
the
feat/telemetry-direct-startup-events
branch
from
November 17, 2026 20:13
d11dac9 to
3111d0e
Compare
yulunz
changed the base branch from
refactor/telemetry-send-batch
to
refactor/telemetry-session-id-in-logger
November 17, 2026 21:46
`server_start` and `daily_active` are now sent with `sendToClearcut()` from the server process instead of through the watchdog. They carry the same `LoggingAttrs` as the watchdog's events, so `session_id` matches.
yulunz
force-pushed
the
feat/telemetry-direct-startup-events
branch
from
November 17, 2026 21:59
3111d0e to
6960f8e
Compare
OrKoN
approved these changes
Nov 18, 2026
daedal-ping Bot
pushed a commit
to DaedalGames/chrome-devtools-mcp
that referenced
this pull request
Nov 18, 2026
…eeds it (ChromeDevTools#3513) Refs ChromeDevTools#3427 Part 4 of 4, stacked on ChromeDevTools#3511. ## Summary `ClearcutLogger` no longer spawns the telemetry watchdog in its constructor. A private `#getWatchdog()` creates it once, the first time an event that still uses the watchdog is logged: `logToolInvocation()` (and the `tool_active` event it can trigger) or `logServerError()`. Since the previous change, `server_start` and `daily_active` are sent from the server process, so an idle server (no tool call) runs no watchdog. Addresses the idle cost reported in ChromeDevTools#3427: each idle MCP server spawned an extra Node process. `ClearcutLoggerOptions.watchdogClient?: WatchdogClient` is replaced by `createWatchdogClient?: () => WatchdogClient`. By default it builds the real `WatchdogClient` from `#loggingAttrs` and the other options, the same arguments as before. Production code never passed `watchdogClient`; only tests did, and they now pass a factory. The option stays optional because it is test-only. ## User-visible behavior changes - With usage statistics on, an idle server is one process instead of two. The watchdog starts on the first tool call, or on the first `logServerError()` (for example when the telemetry state file is corrupt at startup). - Sessions that never call a tool no longer send `server_shutdown`, because no watchdog is running to send it. This is accepted (see ChromeDevTools#3427). - `npm run profile:footprint`: the `default` configuration description now says the watchdog starts on the first tool call. Its private-memory budget goes down from 120 MiB to 112 MiB, because the idle tree no longer includes the watchdog. ## Memory (idle server, `npm run profile:footprint`) "Before" is the parent change (`feat(telemetry): send startup events directly from the server process`) and "after" is this change. Both ran back to back on the same machine, 5 launches per configuration. Values are medians of the whole process tree. The runs used the previous revision of this stack (d11dac9 and 8170701). The rework since then renames functions and moves the session id into `ClearcutLogger`; it does not change which processes run, so the numbers still apply. | Configuration | Build | Processes | RSS | PSS | Private | | ------------------- | ------ | --------- | ---------- | ---------- | ---------- | | default | before | 2 | 219.46 MiB | 121.30 MiB | 115.61 MiB | | default | after | 1 | 163.21 MiB | 106.77 MiB | 103.09 MiB | | no-usage-statistics | before | 1 | 160.61 MiB | 105.16 MiB | 101.57 MiB | | no-usage-statistics | after | 1 | 160.66 MiB | 105.21 MiB | 101.61 MiB | For `default`, the idle tree saves 56.3 MiB RSS, 14.5 MiB PSS, and 12.5 MiB private memory. The watchdog that this removes measured RSS 56.3 MiB, PSS 14.8 MiB, and private 12.7 MiB per process in the "before" runs. The same process starts after the first tool call; the new e2e test checks this. `no-usage-statistics` does not change, which shows the run-to-run noise is small. Commands: ```sh git checkout feat/telemetry-direct-startup-events # before npm run profile:footprint -- --iterations=5 --ignore-budgets --output-dir=/tmp/footprint-before git checkout perf/telemetry-lazy-watchdog # after npm run profile:footprint -- --iterations=5 --ignore-budgets --output-dir=/tmp/footprint-after ``` Machine: Linux 7.1.6 x64 (AMD EPYC 7B13, 64 vCPUs, 117 GiB RAM), Node v25.8.0, release build (`build:release`, `is_debug=false`). CI (`test-memory-leaks.yml`, 3 launches) measured the `default` median at private 102.32 MiB with 2 processes before this change, and 93.06 MiB with 1 process after it. The 112 MiB budget comes from the local numbers above plus about 3%; whether to tighten it is still open. ## Trade-offs - Idle sessions no longer send `server_shutdown`. This is accepted. - The first tool call now also spawns the watchdog. The spawn is asynchronous (`child_process.spawn`) and adds no wait to the tool call. ## Test plan - `tests/telemetry/ClearcutLogger.test.ts`: new `lazy watchdog` tests. `logServerStart()` and `logDailyActiveIfNeeded()` do not call the factory. The first `logToolInvocation()` calls it exactly once, and a second call reuses the watchdog (factory still called once). The existing tests, plus `persistence.test.ts` and `ToolHandler.test.ts`, use the factory option. - `tests/e2e/telemetry.test.ts`: - The SIGKILL, SIGTERM, and process-group SIGTERM tests now complete the MCP handshake and call `list_pages` first. They wait for `tool_invocation` from the watchdog (with `X-Watchdog-Pid`), check that the watchdog is alive, kill the server, and wait for `server_shutdown` (same `session_id`) and for the watchdog to exit. The server starts with `--browserUrl=http://127.0.0.1:1`, so the tool call fails fast without launching Chrome. This avoids leaking Chrome after SIGKILL. A failed tool call still logs `tool_invocation`. - New test (Linux/macOS): after `initialize` and `tools/list`, the server has no `watchdog/main.js` child (`pgrep -P <pid> -f`). After one tool call, the watchdog child exists. - Full `npm run test` on this commit: 1997 tests, 1995 pass, 2 skipped (Windows-only), 0 fail. `npm run format` is clean.
mijanurecon452-tech
pushed a commit
to mijanurecon452-tech/chrome-devtools-mcp
that referenced
this pull request
Nov 24, 2026
🤖 I have created a release *beep* *boop* --- ## [1.14.0](ChromeDevTools/chrome-devtools-mcp@chrome-devtools-mcp-v1.13.0...chrome-devtools-mcp-v1.14.0) (2026-11-24) ### 🎉 Features * add --backgroundNewPages to keep new_page tabs in the background ([ChromeDevTools#3539](ChromeDevTools#3539)) ([7a39d6d](ChromeDevTools@7a39d6d)) * add abort and allow-origin network mocks ([ChromeDevTools#3421](ChromeDevTools#3421)) ([eb4b53d](ChromeDevTools@eb4b53d)) * add inspect-in-devtools skill and claude plugin command ([ChromeDevTools#2696](ChromeDevTools#2696)) ([aa977a6](ChromeDevTools@aa977a6)) * add network requests from service workers ([ChromeDevTools#3554](ChromeDevTools#3554)) ([11162da](ChromeDevTools@11162da)) * add service workers to get_console_message ([ChromeDevTools#3537](ChromeDevTools#3537)) ([2e247a4](ChromeDevTools@2e247a4)) * include computed styles in get_css_styles ([ChromeDevTools#3538](ChromeDevTools#3538)) ([cf98d8b](ChromeDevTools@cf98d8b)) * list errors a page raises while a tool runs ([ChromeDevTools#3431](ChromeDevTools#3431)) ([d5d30bd](ChromeDevTools@d5d30bd)) * resolve CSS custom variable values inline in `get_css_styles` ([ChromeDevTools#3481](ChromeDevTools#3481)) ([8ba2ac9](ChromeDevTools@8ba2ac9)) * support transparent screenshots ([ChromeDevTools#3457](ChromeDevTools#3457)) ([045fb8c](ChromeDevTools@045fb8c)) * **telemetry:** send startup events directly from the server process ([ChromeDevTools#3511](ChromeDevTools#3511)) ([b14eb81](ChromeDevTools@b14eb81)) ### 🛠️ Fixes * accept POSIX root URIs from WSL2 clients on a Windows server ([ChromeDevTools#3380](ChromeDevTools#3380)) ([4b9acc9](ChromeDevTools@4b9acc9)) * align root plugin.json name with marketplace entry ([ChromeDevTools#3474](ChromeDevTools#3474)) ([1424980](ChromeDevTools@1424980)) * **cli:** enable off by default categories in CLI except PWA ([ChromeDevTools#3595](ChromeDevTools#3595)) ([0ff265d](ChromeDevTools@0ff265d)) * **cli:** handle array of strings correctly ([ChromeDevTools#3593](ChromeDevTools#3593)) ([d197b28](ChromeDevTools@d197b28)) * **cli:** match yargs-parser when detecting negative numbers ([ChromeDevTools#3548](ChromeDevTools#3548)) ([eb9b030](ChromeDevTools@eb9b030)) * **cli:** pass option values starting with `-` through to tools ([ChromeDevTools#3501](ChromeDevTools#3501)) ([ec0abfc](ChromeDevTools@ec0abfc)) * **cli:** preserve daemon PID when SIGKILL fails ([ChromeDevTools#3485](ChromeDevTools#3485)) ([0788697](ChromeDevTools@0788697)) * **cli:** reuse live daemons after EPERM ([ChromeDevTools#3452](ChromeDevTools#3452)) ([1417f93](ChromeDevTools@1417f93)) * **cli:** strip terminal escape sequences from tool output and errors ([ChromeDevTools#3536](ChromeDevTools#3536)) ([ec2fb15](ChromeDevTools@ec2fb15)) * **config:** reject --browserUrl values without an http(s) scheme ([ChromeDevTools#3437](ChromeDevTools#3437)) ([e40cef6](ChromeDevTools@e40cef6)) * **config:** reject --viewport values with more than two parts ([ChromeDevTools#3577](ChromeDevTools#3577)) ([ab911a6](ChromeDevTools@ab911a6)) * **console:** keep stack traces of messages from earlier navigations ([ChromeDevTools#3397](ChromeDevTools#3397)) ([e8798d6](ChromeDevTools@e8798d6)) * **console:** resolve Error arguments on the session of their handle ([ChromeDevTools#3408](ChromeDevTools#3408)) ([4c6c767](ChromeDevTools@4c6c767)) * dedicated worker can now build a stack trace ([ChromeDevTools#3572](ChromeDevTools#3572)) ([9762165](ChromeDevTools@9762165)), closes [ChromeDevTools#2962](ChromeDevTools#2962) * do not queue unknown page ids ([ChromeDevTools#3599](ChromeDevTools#3599)) ([4dc8cbc](ChromeDevTools@4dc8cbc)) * **emulation:** reject non-string extraHttpHeaders values ([ChromeDevTools#3484](ChromeDevTools#3484)) ([64d4726](ChromeDevTools@64d4726)) * explain DevToolsActivePort permission errors during autoConnect ([ChromeDevTools#3487](ChromeDevTools#3487)) ([0e49c59](ChromeDevTools@0e49c59)) * **extensions:** preserve list_extensions fields in JSON output ([ChromeDevTools#3592](ChromeDevTools#3592)) ([02b146b](ChromeDevTools@02b146b)) * **input:** allow multi-file upload_file through chooser-opening elements ([ChromeDevTools#3436](ChromeDevTools#3436)) ([ef680a3](ChromeDevTools@ef680a3)) * **input:** return when click_at, type_text, drag or press_key opens a dialog ([ChromeDevTools#3576](ChromeDevTools#3576)) ([7bcb86d](ChromeDevTools@7bcb86d)) * keep temp files under the temp dir ([ChromeDevTools#3372](ChromeDevTools#3372)) ([d666acf](ChromeDevTools@d666acf)) * remove commands from claude plugin ([ChromeDevTools#3469](ChromeDevTools#3469)) ([e2f08b4](ChromeDevTools@e2f08b4)) * respect tool timeouts in CLI daemon responses ([ChromeDevTools#3443](ChromeDevTools#3443)) ([86a1c23](ChromeDevTools@86a1c23)) * **snapshot:** keep extra element UIDs reusable ([ChromeDevTools#3493](ChromeDevTools#3493)) ([4559cd5](ChromeDevTools@4559cd5)) * treat local host name and interface addresses as local browser endpoints ([ChromeDevTools#3463](ChromeDevTools#3463)) ([cf587b4](ChromeDevTools@cf587b4)) * use exception events instead of Runtime.exceptionThrown ([ChromeDevTools#3553](ChromeDevTools#3553)) ([437f394](ChromeDevTools@437f394)) * validate heap snapshot className regex ([ChromeDevTools#3030](ChromeDevTools#3030)) ([343e6b1](ChromeDevTools@343e6b1)) * validate install_pwa and launch_pwa URLs against navigation policy ([ChromeDevTools#3464](ChromeDevTools#3464)) ([057a6aa](ChromeDevTools@057a6aa)) * wait for parsed scripts before reporting an unknown logpoint URL ([ChromeDevTools#3461](ChromeDevTools#3461)) ([404f331](ChromeDevTools@404f331)) ### 📄 Documentation * clarify that Chrome may clamp resize_page dimensions ([ChromeDevTools#3583](ChromeDevTools#3583)) ([b5a41e0](ChromeDevTools@b5a41e0)), closes [ChromeDevTools#2998](ChromeDevTools#2998) * explain the light and browser third-party bundles in AGENTS.md ([ChromeDevTools#3529](ChromeDevTools#3529)) ([835c09a](ChromeDevTools@835c09a)) * fix typos in comments, tests and skill docs ([ChromeDevTools#3489](ChromeDevTools#3489)) ([f312b72](ChromeDevTools@f312b72)) ### ⚡ Performance * **telemetry:** start the watchdog process on the first event that needs it ([ChromeDevTools#3513](ChromeDevTools#3513)) ([a4c550d](ChromeDevTools@a4c550d)) ### 🏗️ Refactor * **build:** split Puppeteer and DevTools into a separate bundle ([ChromeDevTools#3510](ChromeDevTools#3510)) ([1067857](ChromeDevTools@1067857)) * **config:** import ConfigWatcher without the browser bundle ([ChromeDevTools#3520](ChromeDevTools#3520)) ([24dba69](ChromeDevTools@24dba69)) * create BrowserManager without the browser bundle ([ChromeDevTools#3563](ChromeDevTools#3563)) ([e8763f9](ChromeDevTools@e8763f9)) * **formatters:** rename MAX_NAME_LENGTH to HEAP_SNAPSHOT_MAX_NAME_LENGTH ([ChromeDevTools#3591](ChromeDevTools#3591)) ([92250bc](ChromeDevTools@92250bc)) * load DevTools in HeapSnapshotManager on first use ([ChromeDevTools#3564](ChromeDevTools#3564)) ([d8035c6](ChromeDevTools@d8035c6)) * load McpResponse when ToolHandler builds a response ([ChromeDevTools#3565](ChromeDevTools#3565)) ([e4669b3](ChromeDevTools@e4669b3)) * **telemetry:** extract sending to Clearcut into sendToClearcut() ([ChromeDevTools#3509](ChromeDevTools#3509)) ([7354c59](ChromeDevTools@7354c59)) * **telemetry:** generate the session id in ClearcutLogger ([ChromeDevTools#3516](ChromeDevTools#3516)) ([ea19ce7](ChromeDevTools@ea19ce7)) * **telemetry:** import flagUtils without the browser bundle ([ChromeDevTools#3518](ChromeDevTools#3518)) ([ab046de](ChromeDevTools@ab046de)) * **third_party:** re-export Mutex from the light bundle ([ChromeDevTools#3566](ChromeDevTools#3566)) ([48466c4](ChromeDevTools@48466c4)) * **tools:** import emulation without the browser bundle ([ChromeDevTools#3521](ChromeDevTools#3521)) ([c5d5d7f](ChromeDevTools@c5d5d7f)) * **tools:** import input without the browser bundle ([ChromeDevTools#3522](ChromeDevTools#3522)) ([bdecb63](ChromeDevTools@bdecb63)) * **tools:** import logpoints without the browser bundle ([ChromeDevTools#3525](ChromeDevTools#3525)) ([71098b0](ChromeDevTools@71098b0)) * **tools:** import memory without the browser bundle ([ChromeDevTools#3526](ChromeDevTools#3526)) ([ebb27f9](ChromeDevTools@ebb27f9)) * **tools:** import performance without the browser bundle ([ChromeDevTools#3524](ChromeDevTools#3524)) ([ba76587](ChromeDevTools@ba76587)) * **tools:** import snapshot without the browser bundle ([ChromeDevTools#3523](ChromeDevTools#3523)) ([110d7f3](ChromeDevTools@110d7f3)) * **utils:** import text utilities without the browser bundle ([ChromeDevTools#3519](ChromeDevTools#3519)) ([8029df8](ChromeDevTools@8029df8)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #3427
Part 3 of 4, stacked on #3516.
Summary
ClearcutLogger.logServerStart()andClearcutLogger.logDailyActiveIfNeeded()now send their event with
sendToClearcut()from the server process, insteadof through the watchdog. Tool invocation, tool active, and server error events
still go through the watchdog.
After this change the watchdog has nothing to do at startup, so part 4 can
start it on demand.
Event shape
A direct event carries the same fields as a watchdog event, taken from
#loggingAttrs(part 2):session_id,app_version,os_type, plusmcp_client(andraw_mcp_client_info). Itsevent_time_msis the sendtime. It is sent to
#loggingAttrs.clearcutEndpointwithincludePidHeader: false.Failure handling
Direct sends never throw and never block startup; callers already use
void. Failures are logged withlogger.logDailyActiveIfNeeded()startsthe send, saves
lastActiveright away as before, then waits for the send.New option
ClearcutLoggerOptions.sendToClearcut?: typeof sendToClearcutlets testsinject the send function. It is optional because production never passes it.
User-visible behavior changes
server_startanddaily_activeleave the server process right away.Before, they waited in the watchdog's buffer until its first flush, up to
15 minutes later.
requests to Clearcut at startup.
X-Watchdog-Pidtest header, because thewatchdog does not send them.
and logs it; the watchdog retries transient errors. A send can stay pending
for up to the 30 s request timeout.
chrome-devtoolsCLI) sends the same two events directly whenit starts, with
mcp_client = MCP_CLIENT_DT_MCP_CLI.Trade-offs
also lost them when the server exited before the watchdog flushed and the
final flush failed.
next_request_wait_millis. Only the watchdog'sbatches honor it.
Test plan
tests/telemetry/ClearcutLogger.test.ts:logServerStart()andlogDailyActiveIfNeeded()call the injectedsendToClearcutwith the exact event (session_id,app_version,os_type,mcp_client, timestamp) and the exact options(
{clearcutEndpoint, includePidHeader: false}). They do not callwatchdog.send.clearcutEndpoint, the send goes toDEFAULT_CLEARCUT_ENDPOINT.logToolInvocation()still uses the watchdog and does not callsendToClearcut.fails.
tests/e2e/telemetry.test.ts:server_startarrives before any request withX-Watchdog-Pid.server_shutdownhas the samesession_idasserver_start.waits for the watchdog to exit.
npm run test, andnpm run formatis clean.