Skip to content

Commit 8954776

Browse files
authored
feature: sandbox extraction event (#13544)
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
1 parent ca26c81 commit 8954776

File tree

5 files changed

+14
-3
lines changed

5 files changed

+14
-3
lines changed

doc/changes/added/13544.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Add sandbox extraction trace event (#13544, @rgrinberg)

src/dune_engine/sandbox.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ let move_targets_to_build_dir t ~should_be_skipped ~(targets : Targets.Validated
274274
: unit Fiber.t
275275
=
276276
let open Fiber.O in
277-
let+ _start, _finish, _queued =
277+
let+ start, stop, queued =
278278
maybe_async (fun () ->
279279
Option.iter t.snapshot ~f:(fun old_snapshot ->
280280
register_snapshot_promotion t targets ~old_snapshot);
@@ -308,7 +308,8 @@ let move_targets_to_build_dir t ~should_be_skipped ~(targets : Targets.Validated
308308
if Path.Untracked.exists (Path.build src_dir)
309309
then Unix.rename (Path.Build.to_string src_dir) (Path.Build.to_string target)))
310310
in
311-
()
311+
Dune_trace.emit ~buffered:true Sandbox (fun () ->
312+
Dune_trace.Event.sandbox `Extract ~start ~stop ~queued t.loc ~dir:t.dir)
312313
;;
313314

314315
let failed_to_delete_sandbox dir reason =

src/dune_trace/dune_trace.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module Event : sig
3838
type t
3939

4040
val sandbox
41-
: [ `Create | `Snapshot | `Destroy ]
41+
: [ `Create | `Snapshot | `Destroy | `Extract ]
4242
-> start:Time.t
4343
-> stop:Time.t
4444
-> queued:Time.Span.t option

src/dune_trace/event.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,7 @@ let sandbox name ~start ~stop ~queued loc ~dir =
761761
| `Destroy -> "destroy"
762762
| `Snapshot -> "snapshot"
763763
| `Create -> "create"
764+
| `Extract -> "extract"
764765
in
765766
Event.complete ~args ~name ~start ~dur Sandbox
766767
;;

test/blackbox-tests/test-cases/sandbox/sandbox-events.t

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ Demonstrate sandbox events:
2525
"dir": "_build/.sandbox/$DIGEST"
2626
}
2727
}
28+
{
29+
"cat": "sandbox",
30+
"name": "extract",
31+
"args": {
32+
"loc": "dune:1",
33+
"dir": "_build/.sandbox/$DIGEST"
34+
}
35+
}
2836
{
2937
"cat": "sandbox",
3038
"name": "destroy",

0 commit comments

Comments
 (0)