| title | Set Up Profiling |
|---|---|
| sidebar_title | Profiling |
| description | Learn how to enable profiling in your app if it is not already set up. |
| sidebar_order | 3 |
| sidebar_section | features |
Profiling depends on Sentry’s Tracing product being enabled beforehand. To enable tracing in the SDK:
Sentry.init({
dsn: "___DSN___",
// Set tracesSampleRate to 1.0 to capture 100% of transactions for tracing.
// We recommend adjusting this value in production.
// Learn more at
// https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate
tracesSampleRate: 1.0,
});Check out the tracing setup documentation for more detailed information on how to configure sampling. Setting the sample rate to 1.0 means all transactions will be captured.
Profiling for React Native is available in SDK versions 5.32.0 and above.
To enable profiling, set the profilesSampleRate:
Sentry.init({
dsn: "___DSN___",
// Set tracesSampleRate to 1.0 to capture 100% of transactions for tracing.
// We recommend adjusting this value in production.
// Learn more at
// https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate
tracesSampleRate: 1.0,
// profilesSampleRate is relative to tracesSampleRate.
// Here, we'll capture profiles for 100% of transactions.
profilesSampleRate: 1.0,
});To change the React Native profiling options add the hermesProfilingIntegration to the integrations in Sentry.init.
Sentry.init({
integrations: [
Sentry.hermesProfilingIntegration({
platformProfilers: false,
}),
],
});Default value true, platform profilers are enabled. By default both React Native JS code executed in Hermes engine and platform specific code (Swift, Objective-C, Kotlin, Java) are profiled by their respective profilers. Setting platformProfilers to false will disable profiling of the platform specific code and only the JS code executed in Hermes will be profiled. This option is available since the SDK version 5.33.0.
Profiling for React Native is available in SDK versions 7.9.0 and above. Android is currently the only supported platform, and support is still experimental.
import * as Sentry from '@sentry/react-native';
Sentry.init({
dsn: 'YOUR_DSN',
tracesSampleRate: 1.0, // Required for trace mode
_experiments: {
androidProfilingOptions: {
profileSessionSampleRate: 1.0,
lifecycle: 'trace',
startOnAppStart: true,
},
},
});For more information, see the Android SDK documentation