fix: reset client report counters during initialization#1632
fix: reset client report counters during initialization#1632tustanivsky wants to merge 2 commits intomasterfrom
Conversation
I went a bit back and forth with the init-time reset. I ended up leaving it out because as far as I know, client reports are not associated with sessions, so carrying over the counts felt like the right behavior. I don't have a strong opinion on this, but perhaps fixing the concurrent test could be an alternative option? |
|
Wouldn't it be the correct behavior to reset the counters at the beginning of |
|
Even though client reports aren’t technically tied to sessions, I'd say that carrying them over into a new SDK lifecycle feels somewhat misleading compared to simply dropping them (which as I understand from https://develop.sentry.dev/sdk/telemetry/client-reports/#core-operation is acceptable). We could fix this in the test itself but wouldn't that mean individual tests depend on that implicit global state shared across SDK sessions? Adding new tests or simply reordering existing ones could break things again. |
|
I think either way makes sense. :) @supervacuus do you have any preference? |
Nope, not really. As always, when specs are unclear, I would look at how a sample of other SDKs is doing it. |
This PR fixes a bug where the global
g_discard_countsarray in the client report system is not reset betweensentry_close()/sentry_init()cycles. As a result, discard counts from a previous SDK session leak into the nextone within the same process.
This causes the
client_report_concurrentunit test to fail on platforms that run all tests in a single process (e.g.Xbox, where process forking is unavailable). A prior test leaves one residual discard count, causing the concurrent
test to observe 80,001 instead of the expected 80,000 (failing Xbox CI run example).
The fix introduces
sentry__client_report_reset()and calls it at the start ofsentry_init(), ensuring that each SDKinitialization begins with a clean state. This is also semantically correct for production: applications that
re-initialize the SDK within a single process should not carry over stale discard counts into a new session.
Related items: