Skip to content

feat(events): add requester_ip and requester_user_agent to sandbox.lifecycle.killed event - #4

Closed
AdaAibaby wants to merge 1 commit into
mainfrom
feat/kill-event-requester-info
Closed

AdaAibaby wants to merge 1 commit into
mainfrom
feat/kill-event-requester-info

Conversation

@AdaAibaby

Copy link
Copy Markdown
Owner

Closes e2b-dev#3461

What

When a sandbox is explicitly killed via DELETE /sandboxes/{id}, the sandbox.lifecycle.killed ClickHouse event now includes two additional fields in event_data:

  • requester_ip — the client IP as resolved by Gin (c.ClientIP())
  • requester_user_agent — the User-Agent header from the HTTP request

These fields are only populated for kill_reason: request kills. Timeout, eviction, and orchestrator-internal kills leave both fields absent.

Why

Operators currently cannot tell from ClickHouse which IP or which SDK version initiated an explicit sandbox kill. This change makes that traceable without any external logging.

Changes

  • sandboxtypes/states.go: add RequesterIP, UserAgent to RemoveOpts
  • handlers/sandbox_kill.go: populate both fields from the incoming HTTP request
  • orchestrator.proto: add optional string requester_ip and optional string requester_user_agent to SandboxDeleteRequest
  • shared/pkg/grpc/orchestrator/: regenerated protobuf Go bindings
  • orchestrator/delete_instance.go: thread the two fields through RemoveSandbox → removeSandboxFromNode → killSandboxOnNode → gRPC request
  • orchestrator/pkg/server/sandboxes.go: write fields into eventData before publishing

Verification

Deployed to dev. Created 3 sandboxes, killed each with a distinct User-Agent (python-sdk/1.2.3, js-sdk/0.9.1, curl/7.88.0). ClickHouse confirms:

sandbox_id             | requester_ip | user_agent        | kill_reason
i0d3mg5k0s1u9q0ezko15 | ::1          | curl/7.88.0       | request
izvu61942cei1m7qumj18 | ::1          | js-sdk/0.9.1      | request
i6huvni7ffltf803mnlp1 | ::1          | python-sdk/1.2.3  | request

(::1 because the test requests were sent from localhost on the API server; production traffic will carry real client IPs.)

…fecycle.killed event

When kill_reason is "request" (explicit API DELETE), thread the HTTP client
IP and User-Agent from the gin handler through RemoveOpts → gRPC
SandboxDeleteRequest → orchestrator Delete handler → ClickHouse event_data.

System-initiated kills (orphan, base-template-missing, unknown) pass empty
strings and produce no extra fields in the event.

Closes e2b-dev#3461
@AdaAibaby AdaAibaby closed this Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(events): add requester IP and user-agent to sandbox.lifecycle.killed event

2 participants