Skip to content

Conversation

@csmarchbanks
Copy link
Contributor

@csmarchbanks csmarchbanks commented Feb 11, 2026

Description

There is a bug in (*batcher).MoveToEarlierBatch where if the trace id is still in the current batch it will not be properly removed from the current batch causing a decision to be made for the trace twice. This does not break any functionality but will cause the trace dropped too early metric to be improperly incremented if a decision cache is used while also using the new decision_wait_after_root_received option.

I also noticed that we aren't updating the batch id on actualData after moving a trace so fixed that too. It shouldn't make too much of a difference as it shouldn't be possible to receive two root spans, but better to be safe.

Testing

New tests added that reproduce the failure and cover 100% of code paths in id_batcher.go. I have also deployed this to a couple of internal environments and verified that traces dropped too early metric is no longer incremented.

@csmarchbanks csmarchbanks force-pushed the fix-rebatching-from-current-batch branch from 080babe to b1e7258 Compare February 11, 2026 03:36
@csmarchbanks csmarchbanks marked this pull request as ready for review February 11, 2026 03:37
@csmarchbanks csmarchbanks requested review from a team and jmacd as code owners February 11, 2026 03:37
@github-actions github-actions bot added the processor/tailsampling Tail sampling processor label Feb 11, 2026
There is a bug in MoveToEarlierBatch where if the trace id is still in
the current batch it will not be properly removed from the current batch
causing a decision to be made for the trace twice. This does not break
any functionality but will cause the trace dropped too early metric to
be improperly incremented if a decision cache is used.

Signed-off-by: Chris Marchbanks <[email protected]>
@csmarchbanks csmarchbanks force-pushed the fix-rebatching-from-current-batch branch from b1e7258 to a4ca32c Compare February 11, 2026 03:53
// processed before the proposed batch it will do nothing. Returns the
// batch that the trace will now be a part of (which may stay the same).
MoveToEarlierBatch(id pcommon.TraceID, currentBatch, batchesFromNow uint64) uint64
MoveToEarlierBatch(id pcommon.TraceID, traceCurrentBatch, batchesFromNow uint64) uint64
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This rename is to avoid confusion withcurrentBatch in the batcher struct.

}

func (b *batcher) MoveToEarlierBatch(id pcommon.TraceID, currentBatch, batchesFromNow uint64) uint64 {
func (b *batcher) MoveToEarlierBatch(id pcommon.TraceID, traceCurrentBatch, batchesFromNow uint64) uint64 {
Copy link
Contributor

Choose a reason for hiding this comment

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

why rename that variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to differentiate between the batch the trace is currently in and b.currentBatch/currentBatchID.

Signed-off-by: Chris Marchbanks <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants