PER-10496 feat: emit machine identity for slow-build diagnostics - #2384
Open
Shivanshu-07 wants to merge 3 commits into
Open
PER-10496 feat: emit machine identity for slow-build diagnostics#2384Shivanshu-07 wants to merge 3 commits into
Shivanshu-07 wants to merge 3 commits into
Conversation
New env.machine getter (hostname-based id with CI node-index suffix, per-provider run URL) sent as build-create attributes plus an X-Percy-Machine-Id header on snapshot/finalize calls so percy-api can track per-machine liveness on parallel builds and name the dead machine when one stops sending. The getter is excluded from env debug logging (those logs are uploaded with build logs) and the header is attached per-call, never in headers(), so it cannot reach off-domain requests. percy-api validates everything server-side; old CLIs degrade gracefully.
@percy/env enforces 100% line and branch coverage; the new machine getter left the buildkite/gitlab cases, the hostname failure path and the optional-var fallbacks uncovered.
@percy/client also enforces 100% branch coverage; the build-attribute spread and machineHeaders() fallbacks (old CLI / no resolvable hostname) were untested.
Contributor
Author
|
CI is green (30/30). For the record on the two reds seen along the way:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
CLI side of Build-processing diagnostics (slow builds) — PER-10496. Pairs with percy-api https://github.com/percy/percy-api/pull/6715, which validates and consumes everything sent here for per-machine liveness on parallel builds (naming the dead CI machine when one stops sending snapshots).
env.machinegetter (@percy/env):{ id, hostname, runUrl }— sanitized-hostname id suffixed with the CI node index where the provider exposes one (CIRCLE_NODE_INDEX,BUILDKITE_PARALLEL_JOB), and the CI run URL for circle/buildkite/github/gitlab. Deliberately excluded from the env getter debug logging (liketoken) — those debug logs are uploaded with build logs, and hostnames should not ride along.@percy/client):machine-id/machine-hostname/machine-ci-run-urlattributes (only when an id exists).X-Percy-Machine-Idheader on snapshot-create and build-finalize calls, attached per-call viamachineHeaders()— never inheaders(), so it cannot leak to off-domain requests (validateDomain).Server-side: percy-api enforces charset/length limits and an https + CI-host allowlist on the URL, and treats all of it as advisory. Old CLI versions degrade gracefully (the feature falls back to non-machine-specific messaging).
Testing
@percy/env: 5 new specs (sanitized id, node-index suffix + run URL on circle, composed GitHub Actions run URL, null run URL fallback, debug-logging exclusion). Suite green (128/128).@percy/client: header specs for snapshot + finalize, machine attributes on build create; existing exact-payload expectations updated. Suite green under node 14 except one pre-existing environmental failure (proxy getProxy should return undefined if no proxy is set) that also fails on a clean checkout on this machine (local proxy present) — unrelated to this change.Post-Deploy Monitoring & Validation
"machine identity ingest skipped"(should stay ≈0); Redis key growthpercy:api:build-machines:*(bounded by active builds, 25h TTL).slow-build-diagnosticsflag ON → build show JSON carries machine facts indiagnosis; kill one shard → machine named in the receiving-state alert.🤖 Generated with Claude Code