feat(observability): browser_metrics — process-global scraping metrics (B4) - #38
Merged
Merged
Conversation
…etrics (B4) New browser_metrics tool exposes a process-global snapshot: probes ok/failed, avg/min/max probe duration, circuit-breaker/queue/budget rejects, live probe- queue depth (running/admitted/waiting), RSS and uptime. reset:true zeroes the counters after reading (job-scoped). Zero-dependency in-memory counters bumped in BrowserAgent (browser path only — the HTTP fast-path is not counted); reject errors are counted distinctly and never as probe failures. Note: browser recycling is N/A here — the probe model is already ephemeral (a fresh browser is opened and torn down per probe), so there is no cross-probe Chromium memory growth to bound. 30th MCP tool. Closes #28
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.
What
B4 — a
browser_metricstool (30th) exposing a process-global scraping snapshot for mass-scraping observability.src/net/metrics.ts— zero-dep in-memory counters.recordProbeOk/Failed(ms),recordBreaker/Queue/BudgetReject(),metricsSnapshot(),resetMetrics().src/agent/browser-agent.ts—runBrowserProbe()times the browser path and records the outcome: success →probesOk;CircuitOpenError/QueueFullError/BudgetExhaustedError→ the matching reject counter (neverprobesFailed); any other throw →probesFailed. Always rethrows.src/net/probe-queue.ts— addedqueueStats()→{ running, admitted, waiting }.src/server/tools/metrics.ts—browser_metrics({ reset? }): snapshot first, then zero ifreset:true.Snapshot:
uptimeMs,probesOk,probesFailed,avgDurationMs,minDurationMs,maxDurationMs,breakerRejects,queueRejects,budgetRejects,queue,rssBytes.Scope note — recycling is N/A
B4 originally paired "browser recycle + metrics". The probe model is already ephemeral —
runProbeopens and tears down a fresh browser per probe (teardownOpenedinfinally), so there is no cross-probe Chromium memory growth to bound; recycling would only apply to long-lived sessions, which are interactive and already covered by B1 crash recovery. Confirmed with the user → metrics only.Validation
Sniper: no bugs (reject vs failure exclusivity, no Infinity leak on empty min, snapshot-before-reset all verified). Docs: new browser_metrics section in docs/mcp-tools.md + tool count 29→30 across README/docs.
Closes #28