Skip to content

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

Open
AdaAibaby wants to merge 1 commit into
e2b-dev:mainfrom
AdaAibaby:feat/kill-event-requester-info
Open

feat(events): add requester_ip and requester_user_agent to sandbox.lifecycle.killed event#3465
AdaAibaby wants to merge 1 commit into
e2b-dev:mainfrom
AdaAibaby:feat/kill-event-requester-info

Conversation

@AdaAibaby

@AdaAibaby AdaAibaby commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Closes #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 RemoveSandboxremoveSandboxFromNodekillSandboxOnNode → 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 is IPv6 loopback — test requests were sent from localhost on the API server; production traffic will carry real client IPs.)

/cc @ben-fornefeld @jakubno @dobrac @ValentaTomas @arkamar @tvi Looking forward to your code review.

…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 force-pushed the feat/kill-event-requester-info branch from f487aaf to f726f0e Compare August 4, 2026 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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