Add lifecycle tracing spans to instance delete path#299
Merged
Conversation
The delete path runs the same teardown sequence as stop (graceful guest shutdown, hypervisor kill, network release, data removal) but emitted no step spans, so slow deletes showed up in traces as one opaque server span. Wrap each blocking phase in the existing lifecycle step helpers, mirroring the instrumentation already present in stop.go. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
yummybomb
approved these changes
Jul 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DELETE /instances/{id}shows a heavy latency tail in production (p50 ~300ms, p95 ~3.4s), but its trace spans are opaque: the delete path inlib/instances/delete.goruns the same teardown sequence as stop (graceful guest shutdown, hypervisor kill, network release, data removal) without any of the lifecycle step spans thatstop.goalready emits, so the slow phase is invisible in traces.This wraps each blocking phase of
deleteInstancein the existingstartLifecycleSpan/startLifecycleStephelpers, mirroringstop.go:instances.deletespan withhypervisorandinstance_stateattributescancel_compression_jobgraceful_guest_shutdown(marked as error on timeout, same as stop)force_kill_hypervisorrelease_networkdelete_instance_dataNo behavior changes — instrumentation only.
Test plan
go build ./lib/instances/andgo vet ./lib/instances/go test ./lib/instances/ -run TestDeleteInstancepasseslib/instancessuite not run to completion locally: Firecracker VM lifecycle tests require real hypervisor binaries/network and fail identically on unmodified main in this environment/instances/{id}DELETE traces🤖 Generated with Claude Code
Note
Low Risk
Observability-only changes around existing delete flow; no logic or API changes.
Overview
Adds OpenTelemetry lifecycle instrumentation to
deleteInstanceso DELETE latency can be broken down in traces, matching the pattern already used on stop/create.A top-level
instances.deletespan recordsinstance_id,hypervisor, andinstance_stateviaenrichInstancesTrace, with the function signature updated to namedretErrsofinishInstancesSpanruns on exit. Child step spans wrap the blocking teardown phases:cancel_compression_job,graceful_guest_shutdown(failed attempts end the step witherrGracefulShutdownFailed, same as stop),force_kill_hypervisor,release_network, anddelete_instance_data.Teardown logic, timeouts, and error handling are unchanged—only tracing hooks around existing calls.
Reviewed by Cursor Bugbot for commit 38dea8a. Bugbot is set up for automated code reviews on this repo. Configure here.