Skip to content

feat(outbox): carry the drop's trace identity and re-join Outbox.Proc… - #98

Merged
yilmaztayfun merged 1 commit into
masterfrom
feature/outbox-trace-continuity
Aug 28, 2026
Merged

feat(outbox): carry the drop's trace identity and re-join Outbox.Proc…#98
yilmaztayfun merged 1 commit into
masterfrom
feature/outbox-trace-continuity

Conversation

@yilmaztayfun

@yilmaztayfun yilmaztayfun commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

…ess to it

Summary by Sourcery

Carry event trace identity through the outbox so processed messages remain connected to their originating traces.

New Features:

  • Preserve the originating trace context and outbox message identity when events are stored.
  • Reconnect outbox processing spans to the originating event trace while linking them to the worker loop.

Enhancements:

  • Maintain existing tracing behavior for legacy, untraced, or invalid trace contexts.

Tests:

  • Add coverage for trace context persistence, message identity tagging, and outbox span parent/link behavior.

@yilmaztayfun yilmaztayfun self-assigned this Aug 28, 2026
@yilmaztayfun
yilmaztayfun requested review from a team August 28, 2026 06:23
@sourcery-ai

sourcery-ai Bot commented Aug 28, 2026

Copy link
Copy Markdown

Reviewer's Guide

Carries the originating publish span’s W3C trace identity and outbox row ID through persistence, then re-joins Outbox.Process spans to that trace with a worker-loop link while preserving legacy behavior for existing or untraced rows; comprehensive activity-based tests cover both paths.

Sequence diagram for outbox trace continuity

sequenceDiagram
    participant EventBus
    participant EfCoreOutboxStore
    participant OutboxRow
    participant OutboxProcessor
    participant ActivitySource

    EventBus->>EfCoreOutboxStore: StoreAsync(envelope, cancellationToken)
    EfCoreOutboxStore->>OutboxRow: Persist TraceParent and TraceState
    EfCoreOutboxStore->>EventBus: SetTag(outbox.message_id)
    OutboxProcessor->>OutboxRow: Read TraceParent and TraceState
    OutboxProcessor->>ActivitySource: StartActivity(Outbox.Process, parentContext, links)
    ActivitySource-->>OutboxProcessor: Outbox.Process activity
    OutboxProcessor->>EventBus: Publish stored event
Loading

File-Level Changes

Change Details Files
Persist the originating Activity trace context on newly created outbox rows and annotate the publish span with the generated row identifier.
  • Copy ambient TraceParent and optional TraceState into ExtraProperties.
  • Set the ambient activity's outbox.message_id tag.
  • Leave rows and spans unchanged when no ambient activity exists.
framework/src/BBT.Aether.Infrastructure/BBT/Aether/Events/EfCoreOutboxStore.cs
Restore trace continuity when processing outbox messages by creating each Outbox.Process span under the stored origin context while linking it to the worker loop.
  • Parse persisted W3C trace context and use it as the producer span parent.
  • Add an ActivityLink to the polling loop when re-parenting.
  • Fall back to the existing worker-loop parent for missing or invalid trace data.
framework/src/BBT.Aether.Infrastructure/BBT/Aether/Events/Processing/OutboxProcessor.cs
Add focused tests covering trace persistence, tagging, trace-state omission, re-parenting, linking, and backward-compatible fallbacks.
  • Verify StoreAsync behavior with sampled, unsampled, and absent ambient activities.
  • Verify processor behavior for valid, missing, and malformed trace parents.
framework/test/BBT.Aether.Infrastructure.Tests/BBT/Aether/Events/EfCoreOutboxStoreTraceTests.cs
framework/test/BBT.Aether.Infrastructure.Tests/BBT/Aether/Events/Processing/OutboxProcessorTraceTests.cs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b3b4d56c-77a8-4afa-807c-f5d9fc41ad71


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.

@yilmaztayfun
yilmaztayfun merged commit b538e24 into master Aug 28, 2026
5 of 6 checks passed

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 4 duplication

Metric Results
Duplication 4

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@sonarqubecloud

Copy link
Copy Markdown

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