Set Up Profiling

Learn how to enable profiling in your app if it is not already set up.

With profiling, Sentry tracks your software's performance by sampling your program's call stack in a variety of environments. This feature collects function-level information about your code and enables you to fine-tune your program's performance. Sentry's profiler captures function calls and their exact locations, aggregates them, and shows you the most common code paths of your program. This highlights areas you could optimize to help increase both the performance of your code and user satisfaction.

In a browser environment, profiling can help you pinpoint causes of UI jank, surface why values like interaction to next paint (INP) are performing poorly, or why a long task was keeping the browser from repainting the screen and causing frame drops. All of this information enables you to fix real world performance issues and deliver a snappier user experience to your users.

Profiling depends on Sentry’s Tracing product being enabled beforehand. To enable tracing in the SDK:

Copied
Sentry.init({
  dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
  // 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:

Copied
Sentry.init({
  dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
  // 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.

Copied
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.

Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").