Skip to content

Instrument fork admission timing#295

Open
sjmiller609 wants to merge 1 commit into
mainfrom
hypeship/fork-admission-tracing
Open

Instrument fork admission timing#295
sjmiller609 wants to merge 1 commit into
mainfrom
hypeship/fork-admission-tracing

Conversation

@sjmiller609

@sjmiller609 sjmiller609 commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds targeted tracing around fork admission so parallel fanout traces can show where time is spent before restore:

  • traces metadata exact-name scans with file/scanned counts and static caller labels
  • traces fork metadata save, lock wait, and lock hold time
  • traces snapshot memory readiness and guest directory clone work for fork/snapshot paths
  • applies the metadata name-exists tracing to snapshot fork name checks too

The spans intentionally avoid recording requested instance names.

Testing

  • go test ./lib/instances -run 'TestForkInstanceFromStandby|TestForkInstanceFromStopped|TestGetInstance|TestListInstances|TestSnapshot' -count=1\n- go test ./lib/instances -run 'TestSaveForkMetadataSerializesNameAdmission|TestForkInstanceRejectsDuplicateNameForNonNetworkedSource|TestForkInstanceFromStandbyCancelsCompressionJobAndCopiesRawMemory|TestForkSnapshotFromCompressedSourceCopiesRawMemory' -count=1\n- go test ./lib/network -count=1\n\nNote: I did not run the full go test ./lib/instances package to completion locally; it entered longer integration-style tests, so I used the focused fork/query coverage above for this instrumentation-only patch.

Note

Low Risk
Instrumentation-only: context propagation and tracing around existing fork admission logic with no intended behavior change.

Overview
Adds OpenTelemetry spans on fork admission paths so parallel fanout traces can show where time goes before restore, without recording requested instance names on spans.

Metadata name checks now take context and a static caller label (fork_precheck, fork_admission, snapshot_create). findInstanceMetadataByExactName and instanceNameExists emit spans with metadata file counts, files scanned, and match outcome.

saveForkMetadata is traced end-to-end: overall save, lock wait until forkMetadataMu is acquired, and lock hold while admission re-checks names and persists; work under the mutex uses the hold span’s context.

Fork/snapshot guest copy paths gain spans for prepareForkWithAliasReadLock, plus nested lifecycle steps for snapshot memory readiness and directory clone on instance fork and snapshot fork copy helpers.

Reviewed by Cursor Bugbot for commit 274c265. Bugbot is set up for automated code reviews on this repo. Configure here.

@sjmiller609 sjmiller609 marked this pull request as ready for review June 25, 2026 17:53
@sjmiller609 sjmiller609 requested a review from hiroTamada June 25, 2026 17:53
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.

1 participant