feat(orchestrator): add allocated resource metrics for sandboxes#2943
Conversation
Add observable gauges for CPU, memory, and disk allocated to running sandboxes on the orchestrator node, under the orchestrator.sandbox.* prefix. Computed from a single Sandboxes.Items() iteration.
PR SummaryLow Risk Overview The allocation callback does not skip nil sandbox entries unlike Reviewed by Cursor Bugbot for commit 1c6567b. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Code Review
The callback registered in the orchestrator server accesses nested pointers on server.sandboxFactory and the sandbox items without checking for nil, which can lead to a nil pointer dereference panic during metric collection.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
❌ 2 Tests Failed:
View the full list of 5 ❄️ flaky test(s)
To view more test analytics, go to the Test Analytics Dashboard |
There was a problem hiding this comment.
LGTM — straightforward observability addition following the existing gauge registration pattern.
Extended reasoning...
Overview
The PR adds three OpenTelemetry observable gauges (orchestrator.sandbox.cpu.allocated, .memory.allocated, .disk.allocated) registered via a single meter.RegisterCallback in packages/orchestrator/pkg/server/main.go. The callback iterates Sandboxes.Items() once and sums each sandbox's Config.Vcpu, Config.RamMB, and Config.TotalDiskSizeMB (converting MB to bytes). Corresponding name/description/unit entries are added to packages/shared/pkg/telemetry/meters.go.
Security risks
None. This is read-only telemetry registration on startup. No new inputs are accepted, no auth/crypto paths are touched, and no data is exposed beyond aggregate node-level resource totals.
Level of scrutiny
Low — this is purely additive observability code in a hot-path-adjacent but non-mutating callback. The metric registration, units, and descriptions follow the existing conventions in the same file, and the callback mirrors the structure of the statusGauge callback registered immediately above it.
Other factors
The Cursor/Gemini bots flagged the absence of nil checks on item.Config. The inline comment was already marked resolved, and the existing callback for statusGauge (just above) dereferences server.info without nil checks too — so this follows the project's established pattern that these structures are non-nil once New returns. The 0% patch coverage from codecov is expected for telemetry registration, which is integration-tested rather than unit-tested.
Add observable gauges for CPU, memory, and disk allocated to running sandboxes on the orchestrator node, under the orchestrator.sandbox.* prefix. Computed from a single Sandboxes.Items() iteration.