Skip to content

e2b: getMetrics defaults to one hour instead of sandbox lifetime #84

Description

@sweetcornna

What happened

The official E2B JavaScript and Python SDK contracts say that omitting metrics start defaults to the start of the sandbox. Dormice instead applies the shared history resolver with a fixed one-hour default span, so getMetrics() drops retained samples older than one hour.

Focused reproduction:

  1. Create a sandbox row whose createdAt is two hours ago.
  2. Insert retained metrics samples from 90 minutes ago and 10 minutes ago.
  3. Call the official SDK's getMetrics() without start.
  4. Call it again with the sandbox creation time explicitly supplied as start.

Expected: The default call returns both samples, from sandbox creation through now.

Actual: The default call returns only the 10-minute sample. Supplying start explicitly returns both, confirming that the older data exists and was filtered only by the undocumented one-hour default.

Impact: Monitoring, accounting, and diagnostics integrations silently receive incomplete histories for long-lived sandboxes unless they override what the SDK documents as the correct default.

Relevant code and contract:

  • packages/server/src/e2b/control.ts:463-479 calls resolveWindow(..., 3600_000, now) rather than using row.createdAt when start is absent.
  • packages/server/src/db/metrics.ts:238-258 turns an omitted start into endMs - defaultSpanMs.
  • e2b 2.31.0 SandboxMetricsOpts.start documents “defaults to the start of the sandbox”; Python 2.31.0 documents the same behavior for get_metrics.

dor doctor output

Not applicable — this is an E2B control-plane query default and can be reproduced with a focused database/route test.

Environment

  • Dormice commit: 4417ae14938273f5d937c476cf7cdc57e22e53a5
  • SDKs checked: e2b JavaScript and Python 2.31.0
  • Executor: independent of executor
  • Verification: route/database trace with retained samples on both sides of the one-hour cutoff

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions