Load collect-metrics script (#2581)

This will fix the collect metrics [load
error](https://buildkite.com/bazel/bazel-bazel/builds/35400#019dce5b-a255-4012-8704-119afc083ccd/L2868).
diff --git a/buildkite/bazel-bench/bazel_bench.py b/buildkite/bazel-bench/bazel_bench.py
index ef7b670..9e47c64 100644
--- a/buildkite/bazel-bench/bazel_bench.py
+++ b/buildkite/bazel-bench/bazel_bench.py
@@ -276,7 +276,7 @@
     )
 
     commands = (
-        [bazelci.fetch_bazelcipy_command()]
+        [bazelci.fetch_ci_scripts_command()]
         + _bazel_bench_env_setup_command(platform, ",".join(bazel_commits))
         + [bazel_bench_command, upload_output_files_storage_command, upload_to_big_query_command]
     )
diff --git a/buildkite/bazel-central-registry/bcr_compatibility.py b/buildkite/bazel-central-registry/bcr_compatibility.py
index aa8d33a..5a089dc 100644
--- a/buildkite/bazel-central-registry/bcr_compatibility.py
+++ b/buildkite/bazel-central-registry/bcr_compatibility.py
@@ -100,7 +100,7 @@
         bazelci.create_step(
             label="Aggregate incompatible flags test result",
             commands=[
-                bazelci.fetch_bazelcipy_command(),
+                bazelci.fetch_ci_scripts_command(),
                 bazelci.fetch_aggregate_incompatible_flags_test_result_command(),
                 " ".join(parts),
             ],
@@ -119,7 +119,7 @@
         bazelci.create_step(
             label="Generate report in markdown",
             commands=[
-                bazelci.fetch_bazelcipy_command(),
+                bazelci.fetch_ci_scripts_command(),
                 bcr_presubmit.fetch_bcr_presubmit_py_command(),
                 fetch_generate_report_py_command(),
                 " ".join(parts),
diff --git a/buildkite/bazel-central-registry/bcr_presubmit.py b/buildkite/bazel-central-registry/bcr_presubmit.py
index 9c57af8..377a3b4 100755
--- a/buildkite/bazel-central-registry/bcr_presubmit.py
+++ b/buildkite/bazel-central-registry/bcr_presubmit.py
@@ -172,7 +172,7 @@
                 "--overwrite_bazel_version=%s" % overwrite_bazel_version if overwrite_bazel_version else ""
             )
         )
-        commands = [bazelci.fetch_bazelcipy_command(), fetch_bcr_presubmit_py_command(), command]
+        commands = [bazelci.fetch_ci_scripts_command(), fetch_bcr_presubmit_py_command(), command]
         queue = bazelci.PLATFORMS[platform_name].get("queue", "default")
         if CI_RESOURCE_PERCENTAGE == -1:
             concurrency = concurrency_group = None
diff --git a/buildkite/bazelci.py b/buildkite/bazelci.py
index fde5fe9..5d81fda 100755
--- a/buildkite/bazelci.py
+++ b/buildkite/bazelci.py
@@ -63,6 +63,10 @@
     GITHUB_BRANCH
 )
 
+METRICS_SCRIPT_URL = "https://raw.githubusercontent.com/bazelbuild/continuous-integration/{}/buildkite/collect_metrics.py".format(
+    GITHUB_BRANCH
+)
+
 AGGREGATE_INCOMPATIBLE_TEST_RESULT_URL = "https://raw.githubusercontent.com/bazelbuild/continuous-integration/{}/buildkite/aggregate_incompatible_flags_test_result.py?{}".format(
     GITHUB_BRANCH, int(time.time())
 )
@@ -3255,7 +3259,7 @@
             create_step(
                 label="Try Update Last Green Commit",
                 commands=[
-                    fetch_bazelcipy_command(),
+                    fetch_ci_scripts_command(),
                     PLATFORMS[DEFAULT_PLATFORM]["python"]
                     + " bazelci.py try_update_last_green_commit",
                 ],
@@ -3280,7 +3284,7 @@
             create_step(
                 label="Print Test Summary for Shards",
                 commands=[
-                    fetch_bazelcipy_command(),
+                    fetch_ci_scripts_command(),
                     PLATFORMS[DEFAULT_PLATFORM]["python"] + " bazelci.py print_shard_summary",
                 ],
                 platform=DEFAULT_PLATFORM,
@@ -3399,7 +3403,7 @@
         create_step(
             label=":cop: Validate {}".format(f),
             commands=[
-                fetch_bazelcipy_command(),
+                fetch_ci_scripts_command(),
                 "{} bazelci.py project_pipeline --file_config={}".format(
                     PLATFORMS[DEFAULT_PLATFORM]["python"], f
                 ),
@@ -3504,7 +3508,7 @@
     if use_but:
         command += " --use_but"
     label = create_label(platform, project_name, task_name=task_name)
-    commands = [fetch_bazelcipy_command(), command]
+    commands = [fetch_ci_scripts_command(), command]
     if "macos" in platform:
         commands = [f"which {py}", f"{py} -V"] + commands
     return create_step(
@@ -3516,8 +3520,10 @@
     )
 
 
-def fetch_bazelcipy_command():
-    return "curl -q --noproxy '*' -sS {0}?{1} -o bazelci.py".format(SCRIPT_URL, int(time.time()))
+def fetch_ci_scripts_command():
+    command = "curl -q --noproxy '*' -sS {0}?{1} -o bazelci.py".format(SCRIPT_URL, int(time.time()))
+    command += " && curl -q --noproxy '*' -sS {0}?{1} -o collect_metrics.py".format(METRICS_SCRIPT_URL, int(time.time()))
+    return command
 
 
 def fetch_aggregate_incompatible_flags_test_result_command():
@@ -3539,7 +3545,7 @@
 
     return create_step(
         label="Setup {0}".format(project_name),
-        commands=[fetch_bazelcipy_command(), pipeline_command],
+        commands=[fetch_ci_scripts_command(), pipeline_command],
         platform=DEFAULT_PLATFORM,
     )
 
@@ -3595,7 +3601,7 @@
 
     step = create_step(
         label=create_label(platform, project_name, build_only, test_only),
-        commands=[fetch_bazelcipy_command(), pipeline_command],
+        commands=[fetch_ci_scripts_command(), pipeline_command],
         platform=platform,
     )
     # Always try to automatically retry the bazel build step, this will make
@@ -3717,7 +3723,7 @@
         create_step(
             label="Publish Bazel Binaries",
             commands=[
-                fetch_bazelcipy_command(),
+                fetch_ci_scripts_command(),
                 PLATFORMS[DEFAULT_PLATFORM]["python"] + " bazelci.py publish_binaries",
             ],
             platform=DEFAULT_PLATFORM,
@@ -3731,7 +3737,7 @@
             create_step(
                 label="Update last green commit for Bazel",
                 commands=[
-                    fetch_bazelcipy_command(),
+                    fetch_ci_scripts_command(),
                     PLATFORMS[DEFAULT_PLATFORM]["python"]
                     + " bazelci.py try_update_last_green_commit",
                 ],
@@ -3902,7 +3908,7 @@
             create_step(
                 label="Try Update Last Green Downstream Commit",
                 commands=[
-                    fetch_bazelcipy_command(),
+                    fetch_ci_scripts_command(),
                     PLATFORMS[DEFAULT_PLATFORM]["python"]
                     + " bazelci.py try_update_last_green_downstream_commit",
                 ],
@@ -3926,7 +3932,7 @@
         create_step(
             label="Aggregate incompatible flags test result",
             commands=[
-                fetch_bazelcipy_command(),
+                fetch_ci_scripts_command(),
                 fetch_aggregate_incompatible_flags_test_result_command(),
                 " ".join(parts),
             ],
diff --git a/buildkite/culprit_finder.py b/buildkite/culprit_finder.py
index fe50b2d..779a196 100755
--- a/buildkite/culprit_finder.py
+++ b/buildkite/culprit_finder.py
@@ -202,7 +202,7 @@
                 ("--project_commit=" + project_commit) if project_commit else "",
             )
         )
-        commands = [bazelci.fetch_bazelcipy_command(), fetch_culprit_finder_py_command(), command]
+        commands = [bazelci.fetch_ci_scripts_command(), fetch_culprit_finder_py_command(), command]
         pipeline_steps.append(bazelci.create_step(label, commands, platform_name))
     print(yaml.dump({"steps": pipeline_steps}))