Skip to content

Conversation

@adityachoudhari26
Copy link
Member

@adityachoudhari26 adityachoudhari26 commented Feb 11, 2026

Summary by CodeRabbit

  • New Features
    • Added distributed tracing support for asynchronous operations in job dispatch, improving observability and monitoring for ArgoCD and GitHub Actions workflows.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 11, 2026

📝 Walkthrough

Walkthrough

Introduces OpenTelemetry tracing instrumentation to asynchronous dispatch operations in ArgoCD and GitHub Actions handlers. Creates traced spans with parent context linking and propagates the instrumented context through subsequent upsert and verification operations without altering existing functional behavior.

Changes

Cohort / File(s) Summary
ArgoCD Async Dispatch Tracing
apps/workspace-engine/pkg/workspace/jobagents/argo/argoapp.go
Adds OTEL tracer initialization and creates an async span linked to parent context. Routes async dispatch, upsert, and verification operations through the traced context instead of the original context.
GitHub Actions Async Dispatch Tracing
apps/workspace-engine/pkg/workspace/jobagents/github/githubaction.go
Adds OTEL tracer initialization and wraps async dispatch logic in a span linked to parent context. Ensures API calls and error-path state updates propagate through the traced async context.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

Suggested reviewers

  • jsbroks

Poem

🐰 Traces now light the async way,
Spans and links in grand display,
ArgoCD and GitHub dance with care,
Observability blooms in the air!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: separating job dispatching from the parent trace by introducing OpenTelemetry tracing with linked spans in both ArgoCD and GitHub Actions modules.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch separate-job-dispatch-from-parent-trace

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
apps/workspace-engine/pkg/workspace/jobagents/github/githubaction.go (1)

63-79: Consider recording errors on the span for observability.

The tracing setup (detached context.Background() with a link to the parent) is the correct pattern for fire-and-forget goroutines. However, when the dispatch or upsert fails, the span is ended without recording the error, so traces won't surface failures.

♻️ Optional: record error on span
+	"go.opentelemetry.io/otel/codes"
 		if _, err := client.Actions.CreateWorkflowDispatchEventByID(asyncCtx, cfg.Owner, cfg.Repo, cfg.WorkflowId, github.CreateWorkflowDispatchEventRequest{
 			Ref:    ref,
 			Inputs: map[string]any{"job_id": dispatchCtx.Job.Id},
 		}); err != nil {
+			span.RecordError(err)
+			span.SetStatus(codes.Error, "dispatch workflow failed")
 			message := fmt.Sprintf("failed to dispatch workflow: %s", err.Error())
apps/workspace-engine/pkg/workspace/jobagents/argo/argoapp.go (1)

72-98: Same optional improvement: record errors on the span for failed paths.

The detached-context-with-link pattern is correct and cleanly replaces the previous context.WithoutCancel approach. Three early-return error paths (lines 81, 87, 93) exit the goroutine without marking the span as errored, so failures won't be visible in traces.

Additionally, sendJobFailureEvent and sendJobUpdateEvent don't accept a context.Context, so they can't propagate the trace. If you want end-to-end trace coverage for those Kafka publishes, that's a separate follow-up.

♻️ Optional: record errors on span
+	"go.opentelemetry.io/otel/codes"
 		ioCloser, appClient, err := a.getApplicationClient(serverAddr, apiKey)
 		if err != nil {
+			span.RecordError(err)
+			span.SetStatus(codes.Error, "failed to create ArgoCD client")
 			a.sendJobFailureEvent(dispatchCtx, fmt.Sprintf("failed to create ArgoCD client: %s", err.Error()))
 			return
 		}
 		defer ioCloser.Close()

 		if err := a.upsertApplicationWithRetry(asyncCtx, app, appClient); err != nil {
+			span.RecordError(err)
+			span.SetStatus(codes.Error, "failed to upsert application")
 			a.sendJobFailureEvent(dispatchCtx, fmt.Sprintf("failed to upsert application: %s", err.Error()))
 			return
 		}

 		verification := newArgoApplicationVerification(a.verifications, dispatchCtx.Job, app.Name, serverAddr, apiKey)
 		if err := verification.StartVerification(asyncCtx, dispatchCtx.Job); err != nil {
+			span.RecordError(err)
+			span.SetStatus(codes.Error, "failed to start verification")
 			a.sendJobFailureEvent(dispatchCtx, fmt.Sprintf("failed to start verification: %s", err.Error()))
 			return
 		}

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@adityachoudhari26 adityachoudhari26 merged commit 117cfce into main Feb 11, 2026
8 of 9 checks passed
@adityachoudhari26 adityachoudhari26 deleted the separate-job-dispatch-from-parent-trace branch February 11, 2026 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant