Label sandbox git execs with git_op tracing spans

Sandbox exec logs previously required command_len fingerprinting to tell a
push from a credential refresh or a checkpoint commit. The shared git
helpers now instrument their futures with a git_op span, so Daytona's and
Docker's `exec_command: entered` lines inherit the operation label and the
log renders as `git_op{op=push}: exec_command: entered timeout_ms=...`.

Ops: push (git_push_via_exec), refresh-credentials (both providers'
refresh_push_credentials), checkpoint-commit (checked_git_checkpoint),
fetch (fetch_source_run_ref), and metadata-push (the run-metadata snapshot
write). Spans are attached with #[tracing::instrument] — attached to the
future, never an entered() guard held across an await — so they follow the
task across worker threads. No trait or signature changes.

Plan: .ai/plans/git-push-token-resilience.md (PR 3: item 10).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Bryan Helmkamp 2026-08-20 10:19:27 -04:00
parent 1688cd5b91
commit 8ee54783c8
No known key found for this signature in database
5 changed files with 10 additions and 0 deletions

View file

@ -1554,6 +1554,7 @@ impl Sandbox for DaytonaSandbox {
Ok(Some((preview.url, headers)))
}
#[tracing::instrument(name = "git_op", skip_all, fields(op = "refresh-credentials"))]
async fn refresh_push_credentials(&self) -> crate::Result<RefreshOutcome> {
if !self.repo_cloned() {
return Ok(RefreshOutcome::none());

View file

@ -2216,6 +2216,7 @@ impl Sandbox for DockerSandbox {
self.origin_url.get().map(String::as_str)
}
#[tracing::instrument(name = "git_op", skip_all, fields(op = "refresh-credentials"))]
async fn refresh_push_credentials(&self) -> crate::Result<RefreshOutcome> {
if !self.repo_cloned() {
return Ok(RefreshOutcome::none());

View file

@ -1513,6 +1513,7 @@ pub async fn setup_git_via_exec(
})
}
#[tracing::instrument(name = "git_op", skip_all, fields(op = "fetch"))]
pub(crate) async fn fetch_source_run_ref(
sandbox: &dyn Sandbox,
source_run_id: &str,
@ -1643,6 +1644,11 @@ fn push_failure_looks_auth_shaped(error: &crate::Error) -> bool {
/// operation. `credentials` is the provider's push-credential state plus the
/// origin URL; `None` pushes with whatever the remote already carries (the
/// local sandbox, or a workspace without managed credentials).
// Async-safe by construction: the span is attached to the future, so it
// follows the task across worker threads, and the providers' `exec_command:
// entered` lines inherit it — the log renders as
// `git_op{op=push}: exec_command: entered ...`.
#[tracing::instrument(name = "git_op", skip_all, fields(op = "push"))]
pub(crate) async fn git_push_via_exec(
sandbox: &dyn Sandbox,
credentials: Option<(&PushCredentialState, &str)>,

View file

@ -225,6 +225,7 @@ impl RunMetadataWriterHandle {
.unwrap()
}
#[tracing::instrument(name = "git_op", skip_all, fields(op = "metadata-push"))]
pub(crate) async fn write_snapshot(
&self,
dump: &RunDump,

View file

@ -158,6 +158,7 @@ pub async fn git_checkpoint(
clippy::too_many_arguments,
reason = "Checkpointing needs explicit run metadata, checkpoint settings, and author inputs."
)]
#[tracing::instrument(name = "git_op", skip_all, fields(op = "checkpoint-commit"))]
pub(crate) async fn checked_git_checkpoint(
runtime: &SandboxGitRuntime,
sandbox: &dyn Sandbox,