mirror of
https://github.com/kvcache-ai/AgentENV.git
synced 2026-11-05 01:17:36 +00:00
[GH-ISSUE #294] Add lifecycle-aware per-sandbox resource metrics collection #78
Labels
No labels
bug
documentation
enhancement
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/AgentENV#78
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @dushulin on GitHub (Sep 16, 2026).
Original GitHub issue: https://github.com/kvcache-ai/AgentENV/issues/294
Affected component
Observability
Problem statement
Operators need to identify which running sandbox is CPU-bound, short of guest memory, or running out of filesystem space, and distinguish those measurements from its resource allocation and host-side footprint. Node aggregates and API latency histograms cannot answer these questions for a particular sandbox.
#5 already records that the sandbox metrics collector is not implemented, while raw envd metrics are accessible. This request narrows that compatibility gap into a resource-collection feature with lifecycle and sampling requirements. It does not request the whole E2B API surface or a new monitoring database.
Use case
A multi-node deployment runs many sandboxes on each host. Sandboxes can pause, resume into a different Firecracker process, and share snapshot-backed memory or storage. Operators need periodic resource measurements keyed by sandbox ID without manually discovering each guest endpoint or treating a node's aggregate usage as the sandbox's usage.
Current behavior and workarounds
Reviewed upstream
ff148136aebb09705bd2a6a3a40b79368831a465:/metricsprovides guest CPU, memory and root filesystem measurements. #159 fixed gateway access to that endpoint; it explicitly did not add a collector or the E2B sandbox metrics APIs.Current workarounds are direct envd requests and manual host PID/device inspection. They leave users responsible for sampling, runtime identity, stale data, and counter continuity across pause/resume.
Desired behavior
Proposed approach
A node-local background collector can use the orchestrator's authoritative sandbox/runtime associations and reuse the existing metrics endpoint. Start with envd for guest CPU/memory/root filesystem data, and separately named host-process metrics where supported. Host PID statistics are distinct from Firecracker's native JSON metrics.
Keep only technical identity dimensions such as node, sandbox, runtime generation and drive where needed. A configurable, staggered interval in the 15–30 second range is a starting point for measurement, not an established overhead guarantee. More expensive PSS reads can have a separate cadence.
Firecracker-native block/network/error/latency metrics and per-drive I/O accounting can follow independently. They do not replace guest filesystem or memory measurements; physical storage attribution should follow the discussion in #47.
Compatibility and operational impact
API/config changes: additive, optional collector configuration and documented metrics; keep existing endpoints and authentication behavior. Full E2B metrics API compatibility can be a separate follow-up to #5.
Snapshot or storage format changes: none required for an initial collector. Runtime associations can remain node-local and be rebuilt with each runtime.
New host/runtime requirements: reuse existing envd connectivity and permitted read-only process statistics. Do not make a cgroup I/O worker redesign or Firecracker metrics configuration a prerequisite. Unavailable sources must be reported explicitly.
Upgrade and rollback considerations: support disabling collection without changing sandbox lifecycle behavior; ensure stale series and runtime resets are handled during restart/upgrade.
Alternatives considered
Non-goals
created-by, authors, projects or tenants; these are not generic collector fields or labels.Contribution
Design context and acceptance criteria are included here; implementation ownership is not committed. If a dedicated collector effort already exists beyond #5, please link it so this request can be aligned with that work.
Pre-submission checklist