Skip to content

Observation sessions

Observation sessions restrict and associate process resource collection with a specific command or execution window. Use daemonitor-cli observe when you want a process resource summary scoped to a particular invocation.

Running an observed build

Pass the build command after --:

daemonitor-cli observe -- ./gradlew test

Xcode example:

daemonitor-cli observe -- xcodebuild -workspace MyApp.xcworkspace -scheme MyApp build

What happens during observe:

  1. daemonitor-cli spawns the command with inherited stdin, stdout, and stderr so build output streams normally.
  2. It opens an explicit session via POST /v1/sessions with the redacted command line, anchor PID/start time, inferred ecosystem (xcode for xcodebuild/swift/swiftc, gradle for gradlew/gradle, otherwise generic), and project path (extracted from xcodebuild flags or current working directory).
  3. daemonitor-cored immediately wakes its poll loop and accelerates polling to 1 second while the session is active.
  4. When the child command exits, daemonitor-cli closes the session via POST /v1/sessions/{id}/close, prints the session summary to stderr, and exits with the child command's exact exit code (127 if the command could not start, 130 on interrupt).

Saving a JSON summary

Write a copy of the JSON session summary to disk (mode 0600) while keeping build stdout clean:

daemonitor-cli observe --format json --output build-session.json -- ./gradlew assembleDebug

Override ecosystem or project detection explicitly if needed:

daemonitor-cli observe --ecosystem gradle --project my-service -- ./scripts/build.sh

Listing and inspecting past sessions

List persisted observation sessions (default --limit 50):

daemonitor-cli sessions
daemonitor-cli sessions --ecosystem xcode --json

Inspect a single session with per-role rollups and attributed processes:

daemonitor-cli sessions <session-id>
daemonitor-cli sessions <session-id> --json

Attribution and peak aggregation

In session summaries:

  • Processes are attributed as confirmed (anchor process, descendant within depth 8, or matching -derivedDataPath / project path), inferred, or ambiguous (when concurrent overlapping Xcode builds share no distinct -derivedDataPath).
  • total_peak_rss_mb, total_peak_footprint_bytes, and max_parallelism are computed per sample timestamp (taking the maximum simultaneous sum across ticks) rather than summing individual process peaks across non-overlapping jobs.
  • Cumulative CPU seconds and disk I/O bytes are computed as per-incarnation deltas (last - first for pre-existing daemons, last for processes started after session open).

See Build history & observation sessions for how explicit and passive sessions work under the hood.