What Gets Captured
traceroot.git.repo and traceroot.git.ref are set at the trace level. The traceroot.git.source_* attributes are set per span automatically by @observe.
Configuration
TraceRoot resolves the repository and ref independently, filling each unset value in this order:- Explicit initialization arguments.
TRACEROOT_GIT_REPO/TRACEROOT_GIT_REFenvironment variables.- GitHub Actions variables (
GITHUB_REPOSITORY/GITHUB_SHA). - Files in
<current working directory>/.git(configandHEAD). This step does not need thegitbinary and does not search parent directories. - A
gitsubprocess (git remote get-url originandgit rev-parse HEAD). This step needs the binary but works when the process starts in a repository subdirectory.
github.com remotes. For GitLab, Bitbucket, or self-hosted remotes, set TRACEROOT_GIT_REPO explicitly.
Because the repository and ref resolve independently, one may be present while the other is missing. In that case the SDK logs git context incomplete; set the missing value explicitly so source correlation has both fields.
Local .git auto-detection is a development convenience only. Production containers usually ship without a .git directory or the git binary, so auto-detection silently finds nothing and the AI agent cannot correlate traces to source. In production, always inject git context explicitly (see below).
Set them explicitly via environment variables:
Git context in production
Use build-time injection: inject the repo (static) and commit SHA (per-build) as environment variables at build time. The SDK reads them automatically — no code change required.Dockerfile
.github/workflows/deploy.yml
GITHUB_REPOSITORY and GITHUB_SHA automatically — no Dockerfile change needed. On other CI/platform providers, use the build-time injection above.
Apply this to every traced service, including background workers and cron/queue consumers — not just your API server. Each process resolves git context independently.
For setups that reuse one image across commits, set TRACEROOT_GIT_REPO / TRACEROOT_GIT_REF in the Kubernetes pod spec or ECS task definition at deploy time instead.