Skip to content

refactor: centralize branch tracing into BranchTracing helper#3539

Draft
dkrizan wants to merge 1 commit intobdshadow/add-tracing-to-branchingfrom
dkrizan/tracing-aop-layer
Draft

refactor: centralize branch tracing into BranchTracing helper#3539
dkrizan wants to merge 1 commit intobdshadow/add-tracing-to-branchingfrom
dkrizan/tracing-aop-layer

Conversation

@dkrizan
Copy link
Copy Markdown
Member

@dkrizan dkrizan commented Mar 18, 2026

Summary

Alternative approach to the tracing attribute-setting in #3464 — as discussed in this review comment.

Instead of scattering Span.current().setAttribute() calls and private fun set*TracingAttributes() methods in each service, this introduces a shared BranchTracing component with one high-level method per operation type.

What changes:

  • New BranchTracing component in backend/data with typed, explicit methods: traceCopy(), traceDryRunMerge(), traceApplyMerge(), traceCreateBranch()
  • Services call a single method instead of multiple raw span attribute calls
  • No TolgeeTracingContext injection needed in services (only BranchTracing)
  • All private fun set*TracingAttributes() helper methods removed from services
  • @WithSpan annotations kept as-is

Before (current PR):

private fun setDryRunTracingAttributes(sourceBranch: Branch, targetBranch: Branch) {
    tracingContext.setContext(sourceBranch.project.id, null)
    val span = Span.current()
    span.setAttribute("tolgee.branch.source.id", sourceBranch.id)
    span.setAttribute("tolgee.branch.source.name", sourceBranch.name)
    span.setAttribute("tolgee.branch.target.id", targetBranch.id)
    span.setAttribute("tolgee.branch.target.name", targetBranch.name)
}

After:

branchTracing.traceDryRunMerge(sourceBranch, targetBranch)

Test plan

  • Verify span attributes match the original PR's output in Grafana/Tempo
  • Confirm @WithSpan creates spans as before

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 18, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: eef345bf-9500-41f4-9e38-33d75bcdc2d9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dkrizan/tracing-aop-layer
📝 Coding Plan
  • Generate coding plan for human review comments

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.

Instead of scattering Span.current().setAttribute() calls and private
set*TracingAttributes() methods across each branch service, introduce
a shared BranchTracing component with one high-level method per
operation type (traceCopy, traceDryRunMerge, traceApplyMerge, etc.).

Services now need only a single tracing call per method.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dkrizan dkrizan force-pushed the dkrizan/tracing-aop-layer branch from a8c6c4e to c602761 Compare March 18, 2026 10:18
@github-actions
Copy link
Copy Markdown
Contributor

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Apr 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant