Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
### Features

- Create the Android view managers of the SDK on demand, so React Native 0.89+ with the New Architecture does not build their view configs at startup ([#7049](https://github.com/getsentry/sentry-react-native/pull/7049))
- Report MetricKit hangs on iOS as flame graph attachments with the experimental `metricKitHangReportingMode` option ([#7059](https://github.com/getsentry/sentry-react-native/pull/7059))
- With `flamegraphAttachment`, the native SDK attaches the aggregated call trees of a MetricKit hang diagnostic as a flame graph, which the backend symbolicates. The default `legacy` mode reports the flattened call stack tree.

```js
Sentry.init({
dsn: '__DSN__',
enableMetricKit: true,
metricKitHangReportingMode: 'flamegraphAttachment',
});
```

### Fixes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,23 @@ final class RNSentryStartTests: XCTestCase {
assertReactDefaults(actualOptions)
}

func testCreateOptionsSetsMetricKitHangReportingMode() throws {
let options = try RNSentryStart.createOptions(with: [
"dsn": "https://[email protected]/123456",
"metricKitHangReportingMode": "flamegraphAttachment"
])

XCTAssertEqual(options.experimental.metrickit.hangReportingMode, SentryMetricKitHangReportingMode.flamegraphAttachment)
}

func testCreateOptionsUsesLegacyMetricKitHangReportingModeByDefault() throws {
let options = try RNSentryStart.createOptions(with: [
"dsn": "https://[email protected]/123456"
])

XCTAssertEqual(options.experimental.metrickit.hangReportingMode, SentryMetricKitHangReportingMode.legacy)
}

func testAutoStartSetsReactDefaults() throws {
try startFromRN(options: [
"dsn": "https://[email protected]/123456"
Expand Down
1 change: 1 addition & 0 deletions packages/core/etc/sentry-react-native.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ export interface BaseReactNativeOptions {
logsOrigin?: 'all' | 'js' | 'native';
maxCacheItems?: number;
maxQueueSize?: number;
metricKitHangReportingMode?: 'legacy' | 'flamegraphAttachment';
ndkAppHangTimeoutIntervalMillis?: number;
onNativeLog?: (log: NativeLogEntry) => void;
onReady?: (response: {
Expand Down
18 changes: 18 additions & 0 deletions packages/core/src/js/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,24 @@ export interface BaseReactNativeOptions {
*/
enableMetricKitRawPayload?: boolean;

/**
* How the native iOS SDK reports MetricKit hang diagnostics.
*
* - `legacy` reports the flattened call stack tree in the event.
* - `flamegraphAttachment` attaches the aggregated call trees as a flame graph, which the
* backend symbolicates. When the SDK cannot create the flame graph, it reports the flattened
* call stack tree.
*
* Only has an effect when `enableMetricKit` is `true`. Other MetricKit diagnostics do not change.
*
* iOS only
*
* @default 'legacy'
* @experimental
* @platform ios
*/
metricKitHangReportingMode?: 'legacy' | 'flamegraphAttachment';

/**
* When enabled, `SentryCrash` reads memory near the crash site while capturing a native crash
* (e.g. `EXC_BAD_ACCESS`) and embeds string-based stack contents in the event. This can help
Expand Down
17 changes: 17 additions & 0 deletions packages/core/test/wrapper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,23 @@ describe('Tests Native Wrapper', () => {
expect(initParameter.enableMetricKitRawPayload).toBe(true);
});

test('forwards metricKitHangReportingMode to the Native SDK', async () => {
await NATIVE.initNativeSdk({
dsn: VALID_DSN,
enableNative: true,
autoInitializeNativeSdk: true,
metricKitHangReportingMode: 'flamegraphAttachment',
devServerUrl: undefined,
defaultSidecarUrl: undefined,
mobileReplayOptions: undefined,
});

expect(RNSentry.initNativeSdk).toHaveBeenCalled();
// @ts-expect-error mock value
const initParameter = RNSentry.initNativeSdk.mock.calls[0][0];
expect(initParameter.metricKitHangReportingMode).toBe('flamegraphAttachment');
});

test('forwards enablePreWarmedAppStartTracing to the Native SDK', async () => {
await NATIVE.initNativeSdk({
dsn: VALID_DSN,
Expand Down
Loading