From 8ba1c37ae0ddf7e8fae443feb86bd02b24dd7d6c Mon Sep 17 00:00:00 2001 From: Jia Chen Date: Wed, 19 Jul 2023 19:24:34 -0700 Subject: [PATCH] Log invocation UUID for each Buck event Reviewed By: kinto0 Differential Revision: D47579485 fbshipit-source-id: 0177d31bedd9b0c51f29948f386fa10bb63893cc --- source/server/buildSystem.ml | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/source/server/buildSystem.ml b/source/server/buildSystem.ml index 4979b35339c..631ae6d21c6 100644 --- a/source/server/buildSystem.ml +++ b/source/server/buildSystem.ml @@ -81,9 +81,10 @@ module BuckBuildSystem = struct >>= fun Buck.Interface. { WithMetadata.data = { BuildResult.targets = normalized_targets; build_map }; - metadata = _; + metadata; } -> - Lwt.return (create ~targets ~builder ~normalized_targets ~build_map ()) + Lwt.return + (create ~targets ~builder ~normalized_targets ~build_map () |> WithMetadata.create ?metadata) let create_from_saved_state ~builder ~targets ~normalized_targets ~build_map () = @@ -97,7 +98,8 @@ module BuckBuildSystem = struct process another incremental update request to bring everything up-to-date again. If that incremental update is correctly handled, the dead links will be properly cleaned up. *) ClassicBuckBuilder.restore builder ~build_map - >>= fun () -> Lwt.return (create ~targets ~builder ~normalized_targets ~build_map ()) + >>= fun () -> + Lwt.return (create ~targets ~builder ~normalized_targets ~build_map () |> WithMetadata.create) end (* This module defines how `State.t` will be preserved in the saved state. *) @@ -132,12 +134,17 @@ module BuckBuildSystem = struct (fun () -> let start_timestamp = Core_unix.time () |> Int.of_float in f () - >>= fun result -> + >>= fun { WithMetadata.data = result; metadata } -> let millisecond = Timer.stop_in_ms timer in let normals = ("version", Version.version ()) :: normals () in let integers = ("start time", start_timestamp) :: ("runtime", millisecond) :: integers result in + let normals = + match metadata with + | None -> normals + | Some build_id -> ("buck uuid", build_id) :: normals + in Statistics.buck_event ~normals ~integers (); Lwt.return result) (fun exn -> @@ -153,7 +160,7 @@ module BuckBuildSystem = struct module IncrementalBuilder = struct type t = { name: string; - run: unit -> ArtifactPath.Event.t list Lwt.t; + run: unit -> (ArtifactPath.Event.t list, string) WithMetadata.t Lwt.t; } end @@ -187,10 +194,10 @@ module BuckBuildSystem = struct build_map; changed_artifacts; }; - metadata = _; + metadata; } -> State.update ~normalized_targets ~build_map state; - Lwt.return changed_artifacts + Lwt.return (WithMetadata.create ?metadata changed_artifacts) in if should_renormalize source_path_events then { @@ -212,7 +219,10 @@ module BuckBuildSystem = struct List.partition_map source_path_events ~f:categorize in if List.is_empty removed_paths && not (should_reconstruct_build_map changed_paths) then - { IncrementalBuilder.name = "skip_rebuild"; run = (fun () -> Lwt.return []) } + { + IncrementalBuilder.name = "skip_rebuild"; + run = (fun () -> Lwt.return (WithMetadata.create [])); + } else { IncrementalBuilder.name = "skip_renormalize_optimized";