autoninja: Replace ninjalog_uploader_wrapper.py and reclient_metrics.py with build_telemetry.py

This CL unifies the opt-in/opt-out handling for build telemetry collections about Reclient and Ninjalog.

The user consent message will be displayed only once at the beginning of a build.

```
❯ autoninja -C out/deterministic-andorid-dbg base
*** NOTICE ***
Google-internal telemetry (including build logs, username, and hostname) is collected on corp machines to diagnose performance and fix build issues. This reminder will be shown 9 more times. See http://go/chrome-build-telemetry for details. Hide this notice or opt out by running: build_telemetry [opt-in] [opt-out]
*** END NOTICE ***

Proxy started successfully.
...
```

Bug: 345113094
Change-Id: Ie5886287c4bd20262be0ff247508ac3869441eb1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5669094
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Reviewed-by: Michael Savigny <msavigny@google.com>
Commit-Queue: Junji Watanabe <jwata@google.com>
Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
This commit is contained in:
Junji Watanabe
2024-07-22 01:32:29 +00:00
committed by LUCI CQ
parent 397bf12548
commit b12257963c
16 changed files with 66 additions and 794 deletions

View File

@@ -20,7 +20,6 @@ import uuid
import gclient_paths
import ninja
import reclient_metrics
import siso
THIS_DIR = os.path.dirname(__file__)
@@ -313,7 +312,7 @@ def reclient_setup_docs_url():
@contextlib.contextmanager
def build_context(argv, tool):
def build_context(argv, tool, should_collect_logs):
# If use_remoteexec is set, but the reclient binaries or configs don't
# exist, display an error message and stop. Otherwise, the build will
# attempt to run with rewrapper wrapping actions, but will fail with
@@ -339,7 +338,7 @@ def build_context(argv, tool):
yield 1
return
if reclient_metrics.check_status(ninja_out):
if should_collect_logs:
set_reproxy_metrics_flags(tool)
if os.environ.get('RBE_instance', None):
@@ -384,10 +383,11 @@ Ensure you have completed the reproxy setup instructions:
print('%1.3fs to stop reproxy' % elapsed)
def run_ninja(ninja_cmd):
def run_ninja(ninja_cmd, should_collect_logs=False):
"""Runs Ninja in build_context()."""
# TODO: crbug.com/345113094 - rename the `tool` label to `ninja`.
with build_context(ninja_cmd, "ninja_reclient") as ret_code:
with build_context(ninja_cmd, "ninja_reclient",
should_collect_logs) as ret_code:
if ret_code:
return ret_code
try:
@@ -397,10 +397,10 @@ def run_ninja(ninja_cmd):
return 1
def run_siso(siso_cmd):
def run_siso(siso_cmd, should_collect_logs=False):
"""Runs Siso in build_context()."""
# TODO: crbug.com/345113094 - rename the `autosiso` label to `siso`.
with build_context(siso_cmd, "autosiso") as ret_code:
with build_context(siso_cmd, "autosiso", should_collect_logs) as ret_code:
if ret_code:
return ret_code
try: