RUM-17613: timeseries [4/5] Flush the batch in background - #3719
Draft
satween wants to merge 1 commit into
Draft
Conversation
Sampling kept running while the app sat in background, and the buffered batch was only written on session stop, so points collected before a backgrounding could stay unsent for the rest of the session. The collector now suspends the sampling chain when the active view leaves the foreground and flushes the buffers at that point, attributing the batch to the last foreground context. The suspension is delayed by 200 ms to match ActivityViewTrackingStrategy.STOP_VIEW_DELAY_MS, so an Activity-to-Activity transition is not mistaken for a backgrounding. Sampling state carries a generation counter so a suspension pending on an older generation cannot stop a chain that has since been resumed. Drops TimeseriesConfiguration.collectInBackground: background suspension is now unconditional, so the flag no longer has a meaning. Ref: RUM-17613
🎉 All green!🧪 All tests passed 🔄 Datadog auto-retried 2 jobs - 2 passed on retry 🎯 Code Coverage (details) 🔗 Commit SHA: 40a19e5 | Docs | Datadog PR Page | Give us feedback! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes timeseries not being sent when the app goes to background with a partially filled batch.
Sampling used to keep running in background (unless
collectInBackgroundwas off) and the buffer was only written on session stop, so points collected before a backgrounding could stay unsent for the rest of the session. Now, when the active view leaves the foreground, the collector suspends the sampling chain and flushes the buffers, attributing the batch to the last foreground context — a background flush has no view of its own to attribute to.The suspension is delayed by 200 ms to match
ActivityViewTrackingStrategy.STOP_VIEW_DELAY_MS: an Activity-to-Activity transition leaves no active view for a moment and must not be mistaken for a backgrounding. If the app returns to the foreground within that window, collection simply continues. Sampling state carries a generation counter so a suspension pending on an older generation cannot stop a chain that has since been resumed.TimeseriesConfiguration.collectInBackgroundis dropped: background suspension is now unconditional, so the flag no longer has a meaning.Review checklist (to be filled by reviewers)
Ref: RUM-17613