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

@@ -29,6 +29,8 @@ import sys
import time
import urllib.request
import build_telemetry
# These build configs affect build performance.
ALLOWLISTED_CONFIGS = (
"android_static_analysis",
@@ -51,26 +53,6 @@ ALLOWLISTED_CONFIGS = (
)
def IsGoogler():
"""Check whether this user is Googler or not."""
p = subprocess.run(
"cipd auth-info",
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
shell=True,
)
if p.returncode != 0:
return False
lines = p.stdout.splitlines()
if len(lines) == 0:
return False
l = lines[0]
# |l| will be like 'Logged in as <user>@google.com.' for googler using
# reclient.
return l.startswith("Logged in as ") and l.endswith("@google.com.")
def ParseGNArgs(gn_args):
"""Parse gn_args as json and return config dictionary."""
configs = json.loads(gn_args)
@@ -226,8 +208,10 @@ def main():
# Disable logging.
logging.disable(logging.CRITICAL)
if not IsGoogler():
return 0
cfg = build_telemetry.load_config()
if not cfg.is_googler:
logging.warning("Not Googler. Only Googlers can upload ninjalog.")
return 1
ninjalog = args.ninjalog or GetNinjalog(args.cmdline)
if not os.path.isfile(ninjalog):