Skip to content

[RUM-18282] Expose native profilers to React Native SDK - #1466

Open
sbarrio wants to merge 1 commit into
developfrom
sbarrio/RUM-18282/expose-native-profilers
Open

sbarrio wants to merge 1 commit into
developfrom
sbarrio/RUM-18282/expose-native-profilers

Conversation

@sbarrio

@sbarrio sbarrio commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

Exposes the native Datadog Profilers for iOS and Android to be enabled and configured from the React Native SDK.
It does so by adding a new @datadog/mobile-react-native-profiling package.

  • New DdProfiling.enable({ applicationLaunchSampleRate?, continuousSampleRate?, customEndpoint? }) API, available on both the old and new architecture.
  • Sample rates left unset keep each platform's native default (currently 15% on Android, 5% on iOS). On Android, enable does nothing below API 35, the native profiler's minimum.
  • JS, iOS and Android unit tests. CI gets a new test:native-ios-profiling job, and the Android profiling build runs in test:native-android. The version and native SDK bump scripts now include the package.
  • Both example apps enable profiling at 100%. The example app also sets longTaskThresholdMs: 200 and adds a "Trigger JS long task" button, because continuous profiles are only uploaded when they capture a long task, an ANR/app hang or a vital.

Motivation

Native profilers are already available and running on the native SDKs, so RN users should be able to leverage them on their apps.

Additional Notes

This PR depends on #1336 being merged (and dd-sdk-android to be bumped) before it can be merged. Otherwise TTID-based profiles will not be tracked on Android devices.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)
  • If this PR is auto-generated, please make sure also to manually update the code related to the change

@sbarrio sbarrio added the Do not merge This PR is not ready to be merged yet label Oct 2, 2026
@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Tests

✅ All CI checks and tests passed.

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: f92f052 | Docs | View more details | Give us feedback!

@sbarrio
sbarrio marked this pull request as ready for review October 5, 2026 13:19
Copilot AI balanced review requested due to automatic review settings October 5, 2026 13:19
@sbarrio
sbarrio requested review from a team as code owners October 5, 2026 13:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The public API does not enforce its documented sampling-rate range, allowing invalid values to produce inconsistent native behavior.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
What changed in this PR

Adds a profiling package that exposes Datadog’s native iOS and Android profilers to React Native applications.

Changes:

  • Adds the DdProfiling.enable API and native bridges for both architectures.
  • Adds JavaScript and native tests, documentation, and example integrations.
  • Integrates profiling into CI, packaging, and SDK version-management scripts.
File Description
yarn.lock Registers the profiling workspace.
update-version.sh Packages profiling during releases.
update-native-sdk-versions.sh Includes profiling in version checks.
packages/​react-native-profiling/​tsconfig.json Adds TypeScript configuration.
packages/​react-native-profiling/​src/​specs/​NativeDdProfiling.ts Defines the TurboModule contract.
packages/​react-native-profiling/​src/​Profiling.ts Implements the public profiling API.
packages/​react-native-profiling/​src/​nativeModulesTypes.ts Defines native module types.
packages/​react-native-profiling/​src/​index.ts Exports the package API.
packages/​react-native-profiling/​src/​__tests__/​Profiling.test.ts Tests configuration forwarding.
packages/​react-native-profiling/​README.md Documents setup and behavior.
packages/​react-native-profiling/​package.json Configures package build and codegen.
packages/​react-native-profiling/​ios/​Tests/​DdProfilingTests.swift Tests the iOS implementation.
packages/​react-native-profiling/​ios/​Sources/​DdProfilingImplementation.swift Configures the iOS profiler.
packages/​react-native-profiling/​ios/​Sources/​DdProfiling.mm Implements the iOS bridge.
packages/​react-native-profiling/​ios/​Sources/​DdProfiling.h Declares the iOS module.
packages/​react-native-profiling/​DatadogSDKReactNativeProfiling.podspec Defines the profiling pod.
packages/​react-native-profiling/​babel.config.js Adds Babel configuration.
packages/​react-native-profiling/​android/​src/​test/​kotlin/​com/​datadog/​reactnative/​tools/​unit/​ReflectUtils.kt Adds reflection test utilities.
packages/​react-native-profiling/​android/​src/​test/​kotlin/​com/​datadog/​reactnative/​tools/​unit/​GenericAssert.kt Adds native test assertions.
packages/​react-native-profiling/​android/​src/​test/​kotlin/​com/​datadog/​reactnative/​profiling/​DdProfilingImplementationTest.kt Tests Android profiling behavior.
packages/​react-native-profiling/​android/​src/​rnpre74/​kotlin/​com/​datadog/​reactnative/​profiling/​DdSDKReactNativeProfilingPackage.kt Registers the pre-0.74 package.
packages/​react-native-profiling/​android/​src/​rnpost74/​kotlin/​com/​datadog/​reactnative/​profiling/​DdSDKReactNativeProfilingPackage.kt Registers the post-0.74 package.
packages/​react-native-profiling/​android/​src/​oldarch/​kotlin/​com/​datadog/​reactnative/​profiling/​DdProfiling.kt Adds the legacy bridge module.
packages/​react-native-profiling/​android/​src/​newarch/​kotlin/​com/​datadog/​reactnative/​profiling/​DdProfiling.kt Adds the TurboModule implementation.
packages/​react-native-profiling/​android/​src/​main/​kotlin/​com/​datadog/​reactnative/​profiling/​ProfilingWrapper.kt Defines the profiler wrapper.
packages/​react-native-profiling/​android/​src/​main/​kotlin/​com/​datadog/​reactnative/​profiling/​ProfilingSDKWrapper.kt Delegates to the native SDK.
packages/​react-native-profiling/​android/​src/​main/​kotlin/​com/​datadog/​reactnative/​profiling/​DdProfilingImplementation.kt Builds Android profiler configuration.
packages/​react-native-profiling/​android/​src/​main/​AndroidManifest.xml Declares Android permissions.
packages/​react-native-profiling/​android/​settings.gradle Configures local Gradle dependencies.
packages/​react-native-profiling/​android/​gradlew.bat Adds the Windows Gradle wrapper.
packages/​react-native-profiling/​android/​gradlew Adds the POSIX Gradle wrapper.
packages/​react-native-profiling/​android/​gradle/​wrapper/​gradle-wrapper.properties Configures the Gradle distribution.
packages/​react-native-profiling/​android/​gradle.properties Defines Android build defaults.
packages/​react-native-profiling/​android/​detekt.yml Configures Kotlin analysis.
packages/​react-native-profiling/​android/​build.gradle Builds and tests the Android module.
packages/​react-native-profiling/​__mocks__/​react-native.ts Mocks the native module.
example/​src/​screens/​MainScreen.tsx Adds a JS long-task trigger.
example/​src/​ddUtils.tsx Enables JS long-task reporting.
example/​src/​App.tsx Enables profiling in the example.
example/​package.json Adds the profiling dependency.
example/​ios/​Podfile.lock Locks profiling pods.
example/​ios/​Podfile Includes profiling native tests.
example-new-architecture/​package.json Adds profiling to the new-architecture example.
example-new-architecture/​ios/​Podfile.lock Locks new-architecture profiling pods.
example-new-architecture/​App.tsx Enables profiling under the new architecture.
bump-native-dd-sdk.sh Includes profiling in SDK bumps.
.gitlab-ci.yml Builds and tests native profiling.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

<Text style={{ marginTop: 20 }}>{this.state.resultLongTaskAction}</Text>
<Button
title="Trigger JS long task (500ms)"
accessibilityLabel="trigger_js_long_task_button"
Comment on lines +71 to +74
applicationLaunchSampleRate:
applicationLaunchSampleRate !== undefined
? applicationLaunchSampleRate
: DEFAULTS.applicationLaunchSampleRate,

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Do not merge This PR is not ready to be merged yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants