[SDCI-1994] Use RUNNER_TEMP to retrieve job name in measure command #2027
+47
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix GitHub (GHES / self-hosted) job name extraction for
measure --level jobProblem
Users running
datadog-ci measure --level jobon GitHub Enterprise Server / self-hosted runners can see:could not find GitHub diagnostic log filesThis prevents the command from automatically determining the job display name (the UI name), which is used for correlation when
GITHUB_JOBis not the display name (e.g. jobname:overrides, matrix jobs).Root cause
For GitHub Actions job-level metrics, we attempt to infer the real job display name by reading the runner diagnostic logs and extracting the
"jobDisplayName"field.The previous implementation only searched a small list of hardcoded
_diagpaths (primarily GitHub SaaS defaults like/home/runner/actions-runner/.../_diag). On GHES/self-hosted runners, the runner installation directory is frequently different, so the code never seesWorker_*.logand emits the warning.Solution (what changed)
RUNNER_TEMP:RUNNER_TEMPtypically points to<runnerRoot>/_work/_temp, so we can derive<runnerRoot>/_diag(and<runnerRoot>/cached/_diag) without assuming a fixed install path.RUNNER_TEMP-derived_diagpath.Testing
RUNNER_TEMPto a non-standard runner root and verifiesWorker_*.logis discovered via the derived_diagpath.Note: I wasn’t able to execute the full Jest suite locally in this environment due to missing Yarn install state / dependencies, but the change is isolated and covered by targeted unit tests.
Why this matters / expected impact
This improves GitHub job-level metric correlation for:
/home/runner/...or/opt/...It does not change behavior when:
DD_GITHUB_JOB_NAMEis already set (we skip inference)Sources used
Internal code (this repo)
packages/datadog-ci/src/commands/measure/measure.ts(wheregetGithubJobNameFromLogs()is invoked for--level job)packages/base/src/helpers/ci.ts:getGithubJobNameFromLogs()(diagnostic log discovery + parsing)githubWellKnownDiagnosticDirsUnix/githubWellKnownDiagnosticDirsWinshouldGetGithubJobDisplayName()packages/base/src/helpers/__tests__/ci.test.ts(existing tests + new test forRUNNER_TEMPderivation)External documentation
https://docs.github.com/en/actions/how-tos/hosting-your-own-runners/managing-self-hosted-runners/monitoring-and-troubleshooting-self-hosted-runners?learn=hosting_your_own_runners&learnProduct=actions&platform=windowsReview checklist