feat(web): add deployment system stats to service ping#1424
Merged
brendan-kellam merged 5 commits intoJul 6, 2026
Conversation
Collects a best-effort snapshot of the deployment's host/container resources (CPU cores + cgroup CPU quota, host + cgroup memory, disk for the data volume, load average, platform) and includes it as an optional `systemInfo` object on the service ping payload. This surfaces resource facts in the `lh_ping` PostHog event so we can quickly diagnose resource issues (e.g. a customer running out of RAM) and point them towards scaling. Container-aware cgroup limits/usage are read because os.totalmem()/os.cpus() report the host, not the container's limits. The `systemInfo` field is optional for back-compat with Lighthouse deployments that predate it, and every collected value is best-effort (reported as null when unreadable) so it can never break the ping. Fixes SOU-1488 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
WalkthroughAdds a ChangesSystem resource stats in service ping
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Report the systemInfo memory and disk fields in whole MiB (binary, 1024-based units) instead of raw bytes, so the values are directly human-readable when diagnosing resource issues (e.g. a 16Gi container limit reads as 16384). Converts at the collection boundary via a bytesToMiB helper and updates the mirrored docs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Drops the host/node-level readings from the systemInfo snapshot (cpuCores, loadAverage1m, totalMemoryMiB, freeMemoryMiB). These reported the underlying machine rather than the deployment's own allocation, which leaked node sizing (especially in k8s) and added noise without aiding the "is this deployment resource-constrained?" diagnosis. What remains is purely container/volume-scoped: cpuQuota (cgroup CPU limit), memoryLimitMiB/memoryUsedMiB (cgroup), and diskTotalMiB/ diskFreeMiB (statfs on the data volume). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Fixes SOU-1488
What
Collects a best-effort snapshot of the deployment's host/container resources and sends it as an optional
systemInfoobject on the daily service ping. Lighthouse forwards it into thelh_pingPostHog event, giving us a quick list of resource facts per deployment so we can diagnose issues (e.g. "this customer doesn't have enough RAM") and point them towards scaling.How
New
packages/web/src/features/billing/systemInfo.tsgathers:platform,arch,cpuCores,loadAverage1mostotalMemoryBytes,freeMemoryBytesos.totalmem()/os.freemem()cpuQuotacpu.max/ v1cpu.cfs_quota_us+cpu.cfs_period_usmemoryLimitBytes,memoryUsedBytesmemory.max/memory.current, v1memory.limit_in_bytes/memory.usage_in_bytesdiskTotalBytes,diskFreeBytesfs.statfs(DATA_CACHE_DIR)Why cgroups? Sourcebot ships as a container (Docker/Kubernetes).
os.totalmem()/os.cpus()report the host, not the container's limits, so the cgroup-derived limits/usage are what actually tell us whether a deployment is resource-constrained. Both cgroup v1 and v2 layouts are handled.Safety / back-compat
systemInfofield is.optional()onservicePingRequestSchema(mirrored in Lighthouse), so it stays backwards compatible in both directions.statfsfailure) is reported asnull, and the whole collection is wrapped so a failure can never block the ping.ServicePingEvent.payload.Updated the Service Ping docs (
docs/docs/misc/service-ping.mdx) with the new field table + example payload.Paired PR
Lighthouse side (validates + captures
systemInfo): sourcebot-dev/lighthouse#26🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation
Chores