[reclient] Add hostname to invocation ids
This is already covered in the PDD for googlers. We are already gathering hostnames in cloud monitoring mertrics
Bug: b/294945709
Change-Id: Idfb5b8d3b7cf64edd60092f6bd49a3f9f1950d15
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4848094
Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
Commit-Queue: Ben Segall <bentekkie@google.com>
diff --git a/reclient_helper.py b/reclient_helper.py
index 0e38776..8551b92 100644
--- a/reclient_helper.py
+++ b/reclient_helper.py
@@ -10,6 +10,7 @@
import hashlib
import os
import shutil
+import socket
import subprocess
import sys
import time
@@ -114,6 +115,14 @@
return "missing", "UNSPECIFIED"
+def get_hostname():
+ hostname = socket.gethostname()
+ try:
+ return socket.gethostbyaddr(hostname)[0]
+ except socket.gaierror:
+ return hostname
+
+
def set_reproxy_metrics_flags(tool):
"""Helper to setup metrics collection flags for reproxy.
@@ -126,7 +135,8 @@
"""
autoninja_id = os.environ.get("AUTONINJA_BUILD_ID")
if autoninja_id is not None:
- os.environ.setdefault("RBE_invocation_id", autoninja_id)
+ os.environ.setdefault("RBE_invocation_id",
+ "%s/%s" % (get_hostname(), autoninja_id))
os.environ.setdefault("RBE_metrics_project", "chromium-reclient-metrics")
os.environ.setdefault("RBE_metrics_table", "rbe_metrics.builds")
labels = "source=developer,tool=" + tool