dd-sdk-ios icon indicating copy to clipboard operation
dd-sdk-ios copied to clipboard

RUM-5176 [CP] Allow reporting RUM error in sync

Open maxep opened this issue 10 months ago • 1 comments

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)

maxep avatar Jan 24 '25 15:01 maxep

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)

⚠️ Tests

⚠️ Warnings

❄️ 1 New flaky test detected

testWhenViewIsVisible from ViewAttributesTests (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

maxep avatar Sep 04 '25 15:09 maxep

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