convert_to_chrome_trace

Function convert_to_chrome_trace 

Source
pub fn convert_to_chrome_trace<I>(
    nextest_version: &Version,
    events: I,
    group_by: ChromeTraceGroupBy,
    message_format: ChromeTraceMessageFormat,
) -> Result<Vec<u8>, ChromeTraceError>
Expand description

Converts an iterator of recorded events to Chrome Trace Event Format JSON.

The output is a JSON object with "traceEvents" and "displayTimeUnit" fields, suitable for loading into Chrome’s tracing viewer or Perfetto UI.

§Chrome trace dimension mapping

  • pid: For the binary grouping mode, a synthetic ID issued per RustBinaryId. For the slot grouping mode, a single pid across all tests. In both situations, run lifecycle events use pid 0, and setup scripts use pid 1.
  • tid: The global slot number plus TID_OFFSET. Setup scripts use their script index plus TID_OFFSET.
  • name: the test name or script ID.
  • cat: "test", "setup-script", "run", or "stress".
  • ts: event timestamps derived from ExecuteStatus.start_time. B/E pairs are used instead of X events.
  • args: relevant test metadata.

§Pause handling

We use B/E duration events instead of X events. This allows the converter to split events around pause/resume boundaries: when RunPaused is seen, an E event is emitted for every open span, and when RunContinued is seen, a matching B event re-opens them. The result is a visible gap in the timeline during pauses.

Run lifecycle events are also emitted:

  • RunStarted/RunFinished produce a B/E pair spanning the entire run.
  • RunBeginCancel, RunPaused, RunContinued produce process-scoped instant events on the run lifecycle process.