Skip to content

feat(sdk,server): report resume/pause/kill latency via metrics events#1324

Open
FAUST-BENCHOU wants to merge 1 commit into
opensandbox-group:mainfrom
FAUST-BENCHOU:feat/sdk-lifecycle-metrics
Open

feat(sdk,server): report resume/pause/kill latency via metrics events#1324
FAUST-BENCHOU wants to merge 1 commit into
opensandbox-group:mainfrom
FAUST-BENCHOU:feat/sdk-lifecycle-metrics

Conversation

@FAUST-BENCHOU

@FAUST-BENCHOU FAUST-BENCHOU commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

e2e test

Language Test Name Purpose
Python test_server_accepts_lifecycle_metrics_events Parameterized smoke test posting resume/pause/kill events directly to /v1/metrics/events, asserting the server returns 204
Python test_sandbox_lifecycle_operations_report_metrics Runs pause/resume/kill through the SDK and verifies each operation auto-reports a metrics event with durationMs
Go TestLifecycleMetrics_EndpointAcceptsLifecycleEvents Smoke test sending the three new event types to the metrics endpoint, asserting the server accepts them
Go TestSandbox_LifecycleOpsReportMetrics Runs the full pause/resume/kill flow via the Go SDK, intercepting and validating the three reported metrics events
JavaScript lifecycle metrics endpoint accepts durationMs-based events Smoke test verifying the server accepts the three new event types using the durationMs field
JavaScript pause/resume/kill report lifecycle metrics to lifecycle server Runs pause/resume/kill via the JS SDK and verifies each step reports the correct event type and duration

test result

2026-07-17 13:37:39 [INFO] opensandbox.adapters.sandboxes_adapter - Successfully created sandbox: 627a4750-22a9-44ca-985d-e12d14fd9ebc
2026-07-17 13:37:39 [INFO] httpx - HTTP Request: GET http://127.0.0.1:8080/v1/sandboxes/627a4750-22a9-44ca-985d-e12d14fd9ebc/endpoints/44772?use_server_proxy=false "HTTP/1.1 200 OK"
2026-07-17 13:37:39 [INFO] httpx - HTTP Request: GET http://127.0.0.1:8080/v1/sandboxes/627a4750-22a9-44ca-985d-e12d14fd9ebc/endpoints/18080?use_server_proxy=false "HTTP/1.1 200 OK"
2026-07-17 13:37:39 [INFO] opensandbox.sandbox - Waiting for sandbox 627a4750-22a9-44ca-985d-e12d14fd9ebc to pass health check (timeout: 60.0s)
2026-07-17 13:37:39 [INFO] httpx - HTTP Request: GET http://127.0.0.1:43159/proxy/44772/ping "HTTP/1.1 200 OK"
2026-07-17 13:37:39 [INFO] opensandbox.sandbox - Sandbox 627a4750-22a9-44ca-985d-e12d14fd9ebc passed health check after 1 attempts
2026-07-17 13:37:39 [INFO] opensandbox.sandbox - Sandbox 627a4750-22a9-44ca-985d-e12d14fd9ebc is ready
2026-07-17 13:37:39 [INFO] opensandbox.sandbox - Killing sandbox: 627a4750-22a9-44ca-985d-e12d14fd9ebc
2026-07-17 13:37:39 [INFO] opensandbox.adapters.sandboxes_adapter - Terminating sandbox: 627a4750-22a9-44ca-985d-e12d14fd9ebc
2026-07-17 13:37:39 [INFO] httpx - HTTP Request: DELETE http://127.0.0.1:8080/v1/sandboxes/627a4750-22a9-44ca-985d-e12d14fd9ebc "HTTP/1.1 204 No Content"
2026-07-17 13:37:40 [INFO] opensandbox.adapters.sandboxes_adapter - Successfully terminated sandbox: 627a4750-22a9-44ca-985d-e12d14fd9ebc
PASSED
tests/test_lifecycle_metrics_e2e.py::test_sandbox_sync_create_reports_lifecycle_metrics 
-------------------------------- live log call ---------------------------------
2026-07-17 13:37:40 [INFO] opensandbox.sync.sandbox - Creating sandbox with startup source: opensandbox/code-interpreter:latest (timeout: 300.0s)
2026-07-17 13:37:40 [INFO] opensandbox.sync.adapters.sandboxes_adapter - Creating sandbox with startup source: opensandbox/code-interpreter:latest
2026-07-17 13:37:40 [INFO] httpx - HTTP Request: POST http://127.0.0.1:8080/v1/sandboxes "HTTP/1.1 202 Accepted"
2026-07-17 13:37:40 [INFO] httpx - HTTP Request: GET http://127.0.0.1:8080/v1/sandboxes/b9309ae1-a26d-4ea2-b62b-a44588e26e03/endpoints/44772?use_server_proxy=false "HTTP/1.1 200 OK"
2026-07-17 13:37:40 [INFO] httpx - HTTP Request: GET http://127.0.0.1:8080/v1/sandboxes/b9309ae1-a26d-4ea2-b62b-a44588e26e03/endpoints/18080?use_server_proxy=false "HTTP/1.1 200 OK"
2026-07-17 13:37:40 [INFO] opensandbox.sync.sandbox - Waiting for sandbox b9309ae1-a26d-4ea2-b62b-a44588e26e03 to pass health check (timeout: 60.0s)
2026-07-17 13:37:40 [INFO] httpx - HTTP Request: GET http://127.0.0.1:48923/proxy/44772/ping "HTTP/1.1 200 OK"
2026-07-17 13:37:40 [INFO] opensandbox.sync.sandbox - Sandbox b9309ae1-a26d-4ea2-b62b-a44588e26e03 passed health check after 1 attempts
2026-07-17 13:37:40 [INFO] opensandbox.sync.sandbox - Sandbox b9309ae1-a26d-4ea2-b62b-a44588e26e03 is ready
2026-07-17 13:37:40 [INFO] opensandbox.sync.sandbox - Killing sandbox: b9309ae1-a26d-4ea2-b62b-a44588e26e03
2026-07-17 13:37:40 [INFO] httpx - HTTP Request: POST http://127.0.0.1:8080/v1/metrics/events "HTTP/1.1 204 No Content"
2026-07-17 13:37:41 [INFO] httpx - HTTP Request: DELETE http://127.0.0.1:8080/v1/sandboxes/b9309ae1-a26d-4ea2-b62b-a44588e26e03 "HTTP/1.1 204 No Content"
2026-07-17 13:37:41 [INFO] tests.test_lifecycle_metrics_e2e - sandbox.create metrics (sync) durationMs=941 ms sandboxId=b9309ae1-a26d-4ea2-b62b-a44588e26e03
PASSED

============================== 8 passed in 53.94s ==============================
== RUN   TestLifecycleMetrics_EndpointAcceptsEvent
--- PASS: TestLifecycleMetrics_EndpointAcceptsEvent (0.01s)
=== RUN   TestLifecycleMetrics_EndpointAcceptsLifecycleEvents
--- PASS: TestLifecycleMetrics_EndpointAcceptsLifecycleEvents (0.00s)
=== RUN   TestSandbox_CreateReportsLifecycleMetrics
    lifecycle_metrics_e2e_test.go:158: sandbox.create metrics durationMs=16515ms sandboxId=23e528f1-80ba-467a-ab7d-836deeab5f5b
--- PASS: TestSandbox_CreateReportsLifecycleMetrics (16.71s)
=== RUN   TestSandbox_LifecycleOpsReportMetrics
    lifecycle_metrics_e2e_test.go:252: sandbox.pause metrics durationMs=42ms sandboxId=3ba6d986-55c4-4f47-aa2b-ac54ee4da6e1
    lifecycle_metrics_e2e_test.go:252: sandbox.resume metrics durationMs=48ms sandboxId=3ba6d986-55c4-4f47-aa2b-ac54ee4da6e1
    lifecycle_metrics_e2e_test.go:252: sandbox.kill metrics durationMs=94ms sandboxId=3ba6d986-55c4-4f47-aa2b-ac54ee4da6e1
--- PASS: TestSandbox_LifecycleOpsReportMetrics (1.50s)
PASS
ok  	github.com/alibaba/OpenSandbox/tests/go	18.629s
npm warn Unknown env config "devdir". This will stop working in the next major version of npm. See `npm help npmrc` for supported config options.

 RUN  v4.1.0 /Users/zhoujinyu/CursorProject/OpenSandbox/tests/javascript


 Test Files  1 passed (1)
      Tests  4 passed (4)
   Start at  13:38:28
   Duration  2.29s (transform 64ms, setup 0ms, import 76ms, tests 2.10s, environment 0ms)

npm notice
npm notice New major version of npm available! 11.13.0 -> 12.0.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v12.0.1
npm notice To update run: npm install -g npm@12.0.1
npm notice

Testing

  • Not run (explain why)
  • Unit tests
  • Integration tests
  • e2e / manual verification

Breaking Changes

  • None
  • Yes (describe impact and migration path)

Checklist

  • Linked Issue or clearly described motivation
  • Added/updated docs (if needed)
  • Added/updated tests (if needed)
  • Security impact considered
  • Backward compatibility considered

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3bcc7f39d4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread server/opensandbox_server/api/schema.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant