dd-sdk-ios
dd-sdk-ios copied to clipboard
RUM-3588 fix: Always update crash context with RUM attributes
What and why?
📦 With this PR, RUM error and RUM view sent after crash will always include up-to-date attributes set on RUMMonitor
.
Because we don't update crash context with the "last RUM view" info on every change to global attributes, the global RUM attributes held in "last view" were not always correct. Global attributes change that happened during the last active view was never included in the crash error.
How?
The RUM.FatalErrorContextNotifier
is updated with globalAttributes
property. Upon change, it sends a baggage over message bus holding DatadogInternal.GlobalRUMAttributes
(new type). It is received in DatadogCrashReporting
and gets encoded into CrashContext
.
Upon restarting the app from crash, the value is decoded to RUM.CrashContext
on regular basis.
🎁 On testing front, I separated tests for updating the FatalErrorContextNotifier
(1 and 2) from sending encoded baggage over message bus (3 and 4):
♻️ Considered Alternative Approach
In my initial attempt, I tried a simpler approach of updating crashContext.lastRUMView
with latest RUM attributes. That only required producing view updates on every global attribute change and updating the view event in FatalErrorContext
inside RUMViewScope
. This however added a linear backpressure to the RUM queue (red line), growing with the number of calls to monitor.addAttribute(forKey:)
. With lack of "add multiple attributes" API, this perf hit is not acceptable.
The solution implemented in this PR adds much less to the RUM backpressure (yellow line). The impact is related to message bus communication which is done on shared thread.
Review checklist
- [x] Feature or bugfix MUST have appropriate tests (unit, integration)
- [x] Make sure each commit and the PR mention the Issue number or JIRA reference
- [x] Add CHANGELOG entry for user facing changes
Custom CI job configuration (optional)
- [ ] Run unit tests for Core, RUM, Trace, Logs, CR and WVT
- [ ] Run unit tests for Session Replay
- [ ] Run integration tests
- [ ] Run smoke tests
- [ ] Run tests for
tools/