[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>
This commit is contained in:
Ben Segall
2023-09-07 15:11:31 +00:00
committed by LUCI CQ
parent 29282b581b
commit b64ee7f525
3 changed files with 22 additions and 4 deletions

View File

@@ -10,6 +10,7 @@ import contextlib
import hashlib
import os
import shutil
import socket
import subprocess
import sys
import time
@@ -114,6 +115,14 @@ def auth_cache_status():
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 @@ def set_reproxy_metrics_flags(tool):
"""
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