dd-sdk-ios
dd-sdk-ios copied to clipboard
RUM-5176 [CP] Allow reporting RUM error in sync
What and why?
Cross-platform SDKs can report fatal errors before the native process crashes. However, RUM and the Core execute processing and write asynchronously, and the crash can suspend these executions, leading to the loss of the cross-platform error information.
We should let cross-platform SDKs to report error in sync, blocking the caller-thread.
How?
The change involve changes at different layers:
Core module
Add completion argument to Writer interface. The completion callback is called when the data is written to disk.
RUM Module
Add completionHandler property to RUMErrorCommand. The RUMViewScope calls the completion handler after writing the error event and the view update.
The RUM Monitor now expose a method to report an error with a completion handler, The method is exposed using the @_spi(Internal) attribute.
/// Adds RUM error to current RUM view.
///
/// - Parameters:
/// - error: the `Error` object. It will be used to infer error details.
/// - source: the origin of the error.
/// - attributes: custom attributes to attach to this error.
/// - completionHandler: A completion closure called when reporting the error is completed.
@_spi(Internal)
func addError(
error: Error,
source: RUMErrorSource,
attributes: [AttributeKey: AttributeValue],
completionHandler: @escaping CompletionHandler
)
Objc Module
The DDRUMMonitor now expose a _internal_sync_addError to report an error in sync. This method will wait for the underlying completion handler to be called before returning.
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
- [ ] Add CHANGELOG entry for user facing changes
- [x] Add Objective-C interface for public APIs (see our guidelines [internal]) and run
make api-surface)
Datadog Report
Branch report: maxep/RUM-5176/sync-error
Commit report: 9c35df9
Test service: dd-sdk-ios
:white_check_mark: 0 Failed, 930 Passed, 2819 Skipped, 53.72s Total duration (1m 37.66s time saved)
⚠️ Warnings
❄️ 1 New flaky test detected
testWhenViewIsVisiblefromViewAttributesTests(Datadog)Assertion Failure at ViewTreeSnapshotTests.swift:52: XCTAssertTrue failed
ℹ️ Info
🧪 All tests passed
This comment will be updated automatically if new data arrives.🔗 Commit SHA: 91164fa | Docs | Was this helpful? Give us feedback!
/merge
View all feedbacks in Devflow UI.
2025-09-04 15:02:43 UTC :information_source: Start processing command /merge
2025-09-04 15:03:05 UTC :information_source: MergeQueue: pull request added to the queue
The expected merge time in develop is approximately 1h (p90).
2025-09-04 15:43:24 UTC :information_source: MergeQueue: This merge request was merged