diff options
| author | bors <bors@rust-lang.org> | 2025-03-05 15:09:49 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-03-05 15:09:49 +0000 |
| commit | 07b5eeebc948743eaadb32a83d23931fd8854fe8 (patch) | |
| tree | 7a4f9749a2a3cb7d327d693d5a0e9e7d0141dfda /src/ci/scripts/upload-build-metrics.py | |
| parent | 4559163ccb500affc424fb9228dae5003672ffc7 (diff) | |
| parent | fe4c0850fe1ddfd1054d2c92cb832bb59edde2ea (diff) | |
| download | rust-07b5eeebc948743eaadb32a83d23931fd8854fe8.tar.gz rust-07b5eeebc948743eaadb32a83d23931fd8854fe8.zip | |
Auto merge of #138058 - jieyouxu:rollup-skdt0oz, r=jieyouxu
Rollup of 20 pull requests Successful merges: - #134063 (dec2flt: Clean up float parsing modules) - #136581 (Retire the legacy `Makefile`-based `run-make` test infra) - #136662 (Count char width at most once in `Formatter::pad`) - #136764 (Make `ptr_cast_add_auto_to_object` lint into hard error) - #136798 (Added documentation for flushing per #74348) - #136865 (Perform deeper compiletest path normalization for `$TEST_BUILD_DIR` to account for compare-mode/debugger cases, and normalize long type file filename hashes) - #136975 (Look for `python3` first on MacOS, not `py`) - #136977 (Upload Datadog metrics with citool) - #137240 (Slightly reformat `std::fs::remove_dir_all` error docs) - #137298 (Check signature WF when lowering MIR body) - #137463 ([illumos] attempt to use posix_spawn to spawn processes) - #137477 (uefi: Add Service Binding Protocol abstraction) - #137569 (Stabilize `string_extend_from_within`) - #137633 (Only use implied bounds hack if bevy, and use deeply normalize in implied bounds hack) - #137679 (Various coretests improvements) - #137723 (Make `rust.description` more general-purpose and pass `CFG_VER_DESCRIPTION`) - #137728 (Remove unsizing coercions for tuples) - #137731 (Resume one waiter at once in deadlock handler) - #137875 (mir_build: Integrate "simplification" steps into match-pair-tree creation) - #138028 (compiler: add `ExternAbi::is_rustic_abi`) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src/ci/scripts/upload-build-metrics.py')
| -rw-r--r-- | src/ci/scripts/upload-build-metrics.py | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/src/ci/scripts/upload-build-metrics.py b/src/ci/scripts/upload-build-metrics.py deleted file mode 100644 index 915ba953984..00000000000 --- a/src/ci/scripts/upload-build-metrics.py +++ /dev/null @@ -1,86 +0,0 @@ -""" -This script postprocesses data gathered during a CI run, computes certain metrics -from them, and uploads these metrics to DataDog. - -This script is expected to be executed from within a GitHub Actions job. - -It expects the following environment variables: -- DATADOG_SITE: path to the DataDog API endpoint -- DATADOG_API_KEY: DataDog API token -- DD_GITHUB_JOB_NAME: Name of the current GitHub Actions job - -It expects the presence of a binary called `datadog-ci` inside `node_modules`. -It can be installed with `npm ci` at `src/ci`. - -Usage: -```bash -$ python3 upload-build-metrics.py <path-to-CPU-usage-CSV> -``` - -`path-to-CPU-usage-CSV` is a path to a CSV generated by the `src/ci/cpu-usage-over-time.py` script. -""" - -import argparse -import csv -import os -import subprocess -import sys -from pathlib import Path -from typing import List - - -def load_cpu_usage(path: Path) -> List[float]: - usage = [] - with open(path) as f: - reader = csv.reader(f, delimiter=",") - for row in reader: - # The log might contain incomplete rows or some Python exception - if len(row) == 2: - try: - idle = float(row[1]) - usage.append(100.0 - idle) - except ValueError: - pass - return usage - - -def upload_datadog_measure(name: str, value: float): - """ - Uploads a single numeric metric for the current GitHub Actions job to DataDog. - """ - print(f"Metric {name}: {value:.4f}") - - cmd = "npx" - if os.getenv("GITHUB_ACTIONS") is not None and sys.platform.lower().startswith( - "win" - ): - # Due to weird interaction of MSYS2 and Python, we need to use an absolute path, - # and also specify the ".cmd" at the end. See https://github.com/rust-lang/rust/pull/125771. - cmd = "C:\\Program Files\\nodejs\\npx.cmd" - - subprocess.run( - [ - cmd, - "datadog-ci", - "measure", - "--level", - "job", - "--measures", - f"{name}:{value}", - ], - check=False, - ) - - -if __name__ == "__main__": - parser = argparse.ArgumentParser(prog="DataDog metric uploader") - parser.add_argument("cpu-usage-history-csv") - args = parser.parse_args() - - build_usage_csv = vars(args)["cpu-usage-history-csv"] - usage_timeseries = load_cpu_usage(Path(build_usage_csv)) - if len(usage_timeseries) > 0: - avg_cpu_usage = sum(usage_timeseries) / len(usage_timeseries) - else: - avg_cpu_usage = 0 - upload_datadog_measure("avg-cpu-usage", avg_cpu_usage) |
