Enable telemetry flags for Google corp machines only.

Bug: b/348530235
Change-Id: I4ac32c60b806f44920bd06e31ec6c3b86a6a6964
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7104218
Commit-Queue: Alex Ovsienko <ovsienko@google.com>
Reviewed-by: Junji Watanabe <jwata@google.com>
This commit is contained in:
Alex Ovsienko
2025-11-09 17:13:31 -08:00
committed by LUCI CQ
parent a8d3023ff0
commit 4e2be179a1
2 changed files with 29 additions and 5 deletions

21
siso.py
View File

@@ -14,7 +14,9 @@ import signal
import shlex
import shutil
import sys
from typing import Optional
import build_telemetry
import caffeinate
import gclient_paths
@@ -68,6 +70,18 @@ def apply_metrics_labels(args: list[str]) -> list[str]:
return args + ["--metrics_labels", ",".join(result)]
def apply_telemetry_flags(args: list[str]) -> list[str]:
telemetry_flags = [
"enable_cloud_monitoring", "enable_cloud_profiler",
"enable_cloud_trace", "enable_cloud_logging"
]
flag_to_add = []
for flag in telemetry_flags:
if f"-{flag}" not in args and f"--{flag}" not in args:
flag_to_add.append(f"--{flag}")
return args + flag_to_add
def load_sisorc(rcfile):
if not os.path.exists(rcfile):
return [], {}
@@ -106,11 +120,14 @@ def _is_google_corp_machine():
return shutil.which("gcert") is not None
def main(args):
def main(args, telemetry_cfg: Optional[build_telemetry.Config] = None):
# Do not raise KeyboardInterrupt on SIGINT so as to give siso time to run
# cleanup tasks. Siso will be terminated immediately after the second
# Ctrl-C.
original_sigint_handler = signal.getsignal(signal.SIGINT)
if not telemetry_cfg:
telemetry_cfg = build_telemetry.load_config()
should_collect_logs = telemetry_cfg.enabled()
def _ignore(signum, frame):
try:
@@ -223,6 +240,8 @@ def main(args):
print('depot_tools/siso.py: %s' % shlex.join(new_args),
file=sys.stderr)
new_args = apply_metrics_labels(new_args)
if should_collect_logs:
new_args = apply_telemetry_flags(new_args)
return caffeinate.run([siso_path] + new_args, env=env)
print(
'depot_tools/siso.py: Could not find siso in third_party/siso '