[A-1511] Add OTel spans for repo-checkout git operations with --trace-git-checkout flag#4098
[A-1511] Add OTel spans for repo-checkout git operations with --trace-git-checkout flag#4098isaacsu wants to merge 5 commits into
--trace-git-checkout flag#4098Conversation
1ba8dbb to
6578fd5
Compare
aff0469 to
c19c2e4
Compare
6578fd5 to
01e4b00
Compare
fa62ad8 to
2223a68
Compare
Add opt-in per-operation git.* child spans (and a handful of attributes) inside the default checkout so a trace shows a waterfall, making the slow step obvious. Gated behind --trace-git-checkout / BUILDKITE_TRACE_GIT_CHECKOUT (default off) so the added span volume is only paid by agents that ask for it. This is pure instrumentation — no git commands, retry policy, or checkout behaviour change. Adapted to the multi-file checkout refactor: spans live in the files owning each operation (checkout.go, checkout_fetch.go, checkout_mirror.go).
6c0a7d7 to
e7fdf5c
Compare
e7fdf5c to
6a85428
Compare
d45acc4 to
6999f72
Compare
6999f72 to
a7d8017
Compare
--trace-git-checkout flag
zhming0
left a comment
There was a problem hiding this comment.
More Otel span the better 🙌🏿 , but I wonder if we can make them less invasive in our code, perhaps we can start by thinking if the flag is worth it.
| TraceGitCheckoutFlag = cli.BoolFlag{ | ||
| Name: "trace-git-checkout", | ||
| Usage: "Emit per-operation git.* child spans inside the checkout phase so a trace shows a waterfall of the individual git operations. Only takes effect when tracing is enabled (default: false)", | ||
| EnvVar: "BUILDKITE_TRACE_GIT_CHECKOUT", | ||
| } |
There was a problem hiding this comment.
Just for my understanding, what is the rationale behind adding a CLI flag as the toggle? I think it's a matter of 10 spans per job?
There was a problem hiding this comment.
Once we add a CLI flag it becomes a product surface that we will to support forever.
There was a problem hiding this comment.
These abstractions aren't ideal. Nothing in traceGitOp is about git, they seem mostly do a feature flag check + typical Otel ceremony.
If this is sole place where we check the flag I think it'd be reasonable but I think we have various other places checking the flag, which makes these questionable.
There was a problem hiding this comment.
I didn't find a concrete defect in the latest revision. Making the git.* spans automatic for either tracing backend across the default checkout path is cross-cutting enough to warrant a human sanity-check.
Want to dig deeper?
Paste this into your agent to explore the findings from this review's Buildkite build:
Download the buildsworth logs from build 8013, then answer my questions about the findings.
Install the reading-buildsworth-logs skill to run this.
Description
New experimental feature that emits additional
git.*OpenTelemetry spans when the agent is started with--trace-git-checkout.This will allow customers to see what goes on behind the "Preparing working directory" /
repo-checkoutspan and figure out ways to speed up the checkout phase of their jobs.Spans added
git.*builds off its child contextgetOrUpdateMirrorDirclonelockgitCloneupdatelockgitFetchgitClonegitRepackifGitMirrorCheckoutModeis dissociategitClonegitCleanSubmodulesandgitCleangit lfs installfetchSourceverifyCommitsetupSparseCheckoutgitCheckoutupdateGitSubmodulesgetOrUpdateMirrorDir(see git.mirror.update above)git submodule updategitLFSFetchCheckoutgitCleanandgitCleanSubmodulesScreenshot
Changes
--trace-git-checkoutflag to CLItraceGit*helper functions to internal/job/tracing.goTesting
go test ./...). Buildkite employees may check this if the pipeline has run automatically.go tool gofumpt -extra -w .)Disclosures / Credits
While this PR was produced with the help of advanced automation tools, I take full credit and responsibility for it.