mirror of
https://github.com/kvcache-ai/AgentENV.git
synced 2026-11-05 01:17:36 +00:00
[PR #311] [MERGED] feat: add sandbox metrics collection APIs #340
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#340
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?
📋 Pull Request Information
Original PR: https://github.com/kvcache-ai/AgentENV/pull/311
Author: @zlzGithub-0801
Created: 9/22/2026
Status: ✅ Merged
Merged: 9/24/2026
Merged by: @yingdi-shan
Base:
main← Head:feat/metrics📝 Commits (1)
c09b28efeat: add sandbox metrics collection APIs📊 Changes
25 files changed (+2209 additions, -13 deletions)
View changed files
📝
config/default.toml(+4 -0)📝
docs/src/concepts/sandboxes/working.md(+51 -0)📝
docs/src/configuration/reference.md(+2 -0)➕
services/gateway/internal/sandbox_metrics.go(+183 -0)➕
services/gateway/internal/sandbox_metrics_test.go(+118 -0)📝
services/gateway/internal/server.go(+7 -0)📝
src/api/generated/src/apis/sandboxes.rs(+57 -0)📝
src/api/generated/src/models.rs(+445 -0)📝
src/api/generated/src/server/mod.rs(+325 -0)📝
src/api/impls/sandbox.rs(+144 -0)📝
src/api/openapi.yml(+134 -0)📝
src/api/proxy.rs(+72 -0)📝
src/cfg.rs(+5 -0)➕
src/orchestrator/sandbox_metrics.rs(+266 -0)📝
src/orchestrator/service.rs(+8 -1)📝
src/orchestrator/tests.rs(+224 -2)📝
src/sandbox/backend.rs(+8 -0)📝
src/sandbox/envd.rs(+36 -0)📝
src/sandbox/firecracker/sandbox.rs(+7 -0)➕
src/sandbox/metrics.rs(+80 -0)...and 5 more files
📄 Description
What
Add E2B-compatible sandbox metrics collection and query APIs:
GET /sandboxes/{sandboxID}/metricsGET /sandboxes/metricsMetrics are collected from envd and retained in node-local memory.
Why
AgentENV exposed envd metrics but did not collect, retain, or serve them through its E2B-compatible control-plane API.
Related issue
Closes #294
#5
Scope and non-goals
Includes envd metric collection, in-memory retention, gateway aggregation, OpenAPI definitions, generated API code, tests, configuration, and user documentation.
Design and behavior changes
The orchestrator collects metrics from all running sandboxes every
metrics_interval_secsand retains them formetrics_retention_secs. The defaults are 15 seconds and 3600 seconds, respectively, and both can be configured indefault.toml.Metrics collection is triggered either by sandbox lifecycle changes or by the periodic timer. The orchestrator retrieves each sample through the envd metrics API and stores the retained history in an in-memory HashMap.
For
GET /sandboxes/{sandboxID}/metrics, the gateway routes the request to the node hosting that sandbox. ForGET /sandboxes/metrics, the gateway groups the requested sandbox IDs by node, sends one request to each node, and combines the node responses.Compatibility and operations
SandboxMetricresponse model.metrics_interval_secs = 15andmetrics_retention_secs = 3600under[orchestrator].Validation
make fmtmake clippymake test-unitmake -C services test(required whenservices/changes)maketargetManual deployment validation covered history and batch queries, time filtering, CPU and disk load, pause/resume behavior, and invalid requests.
Skipped checks and reasons:
Full repository and service test suites were not run. No benchmarks were added because collection is bounded and runs asynchronously.
Risks and reviewer notes
Metrics are node-local and non-durable. A node restart clears retained history. Collection depends on envd availability; failed or timed-out samples are skipped rather than stored as zero values.
The main review areas are the orchestrator collection lifecycle, runtime-generation validation, gateway batch aggregation, and OpenAPI contract.
Checklist
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.