Skip to content

feat(spans-buffer): Add more flusher documentation#108029

Merged
lvthanh03 merged 3 commits intomasterfrom
tony/flusher-docs
Feb 18, 2026
Merged

feat(spans-buffer): Add more flusher documentation#108029
lvthanh03 merged 3 commits intomasterfrom
tony/flusher-docs

Conversation

@lvthanh03
Copy link
Copy Markdown
Member

Documenting flusher behaviour on kafka rebalancing/consumer deployment.

@lvthanh03 lvthanh03 requested review from a team as code owners February 11, 2026 14:47
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Feb 11, 2026
This means the queue a segment lands in depends on both the trace ID and the
current set of assigned partitions. On a Kafka rebalance (triggered by
consumer deployment, scaling, or crashes), `assigned_shards` changes, possibly
in length or in values. Then, the same trace ID may route to a different queue.
Copy link
Copy Markdown
Member

@evanh evanh Feb 11, 2026

Choose a reason for hiding this comment

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

Reading the code, the queue that a segment ends up on is based on the modulo of the number of assigned shards. So the queue that a segment is written too doesn't depend on the value of assigned shards. Just the queues that are read from are just the assigned shards.

shard = self.assigned_shards[
    int(project_and_trace.split(":")[1], 16) % len(self.assigned_shards)
]
queue_key = self._get_queue_key(shard)

I think this means that assuming partitions are evenly spread (which they should be) we won't get incomplete segments even if the values themselves change.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't think so, the shard (and therefore the queue) is the value at an index of self.assigned_shards.

Example with same length, different values:

Before: assigned_shards = [0,1,2,3,4], index=3 -> shard=3 -> span-buf:q:3
After: assigned_shards = [0,3,5,8,9], index=3 -> shard=8 -> span-buf:q:8

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yep you're right. Sorry about that.

@lvthanh03 lvthanh03 enabled auto-merge (squash) February 18, 2026 17:21
@lvthanh03 lvthanh03 merged commit 491a9f8 into master Feb 18, 2026
93 checks passed
@lvthanh03 lvthanh03 deleted the tony/flusher-docs branch February 18, 2026 17:43
mchen-sentry pushed a commit that referenced this pull request Feb 24, 2026
Documenting flusher behaviour on kafka rebalancing/consumer deployment.
@github-actions github-actions bot locked and limited conversation to collaborators Mar 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

claude-code-assisted Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants