Profiling

Profiling offers a deeper level of visibility on top of traditional tracing, removing the need for custom instrumentation and enabling precise code-level visibility into your application in a production environment.

Sentry's profiling feature builds upon our established Performance Monitoring capabilities to provide precise code-level visibility into application execution in a production environment. Profiling provides context at a deeper level than traditional tracing, enabling you to visualize the precise details of the call stack without the need for custom instrumentation. With Profiling you can quickly identify hot paths in your code and understand potential performance bottlenecks, enabling you to build in performance as a feature from day one.

Sentry profiling supports common platforms for both Mobile and Backend applications:

  • Mobile app profiling makes it possible to collect profiles from real devices in production, providing a complete picture of how the app performs in a variety of environments.
  • Backend platform profiling makes it possible to easily target the essential code that yields the biggest improvements in backend throughput and resource utilization.

Sentry profiling data is structured as an extension of performance transactions. This means you can "zoom in" on transactions to see their profiles directly by clicking on any transaction on the Performance page.

Performance page

This will take you to the Transaction Summary page where you'll see a list of transaction events.

Transaction Summary page

Transaction events that have a profile contain a link in the "Profile" column which will take you to a flame graph with details about that event. Learn how to read Flame Graphs and Aggregated Flame Graphs.

Profile details page showing a flame graph

Alternatively, if you click on the "Event ID" for a transaction, you'll see a span waterfall where you can identify suspect spans - operations that may be impacting performance, including slow DB queries and HTTP requests. You can click on a span to see profile information, including the most frequently occurring code path (call stack with exact line numbers), along with the approximate percentage of time required for that code path.

Transaction showing call stack data from a profile

From this view, you can also click "View Profile" to zoom in on the flame graph.

On the Profiling page, you'll find two tabs: "transactions" and "flamegraph". The transactions tab lists transactions in descending order of execution-time for your selected project(s), while the flamegraph tab shows an aggregate flamegraph that spans across transactions. Depending on how profiling has been set up, you might be interested more in one than the other.

Using the Profiling page is typically an advanced workflow where you can select transactions of interest directly and closely examine profiling data.

This page shows a list of transactions in descending order of execution-time for your selected project(s).

Transactions View

The "Profiles by Percentiles" timeline chart can be used to filter transaction data by highlighting a desired time period.

The "Slowest Functions" widget lists the functions that took the most time in your application, including the transactions each function was called from. Clicking on a transaction will take you to an example profile.

The flamegraph tab shows an aggregate flamegraph based on the query you selected. You can use this tab to visualize a flamegraph across transaction boundaries so you can better understand bottlenecks that might be affecting the system as a whole. The aggregate flamegraph is a more advanced workflow that's relevant to users who've set up continuous profiling and are interested in looking at system-wide performance.

Flamegraph View

The function width in an aggregate flamegraph represents the number of times a particular function has been sampled. This view shows you where your system is spending the majority of its time. We recommend that you look for functions with a large sample count and optimize them, as they're the ones most frequently occupying the program's stack.

You can right click on a function to open some example profiles and see the function executing. This is useful for gaining context into how and why that function might be running.

Selecting one of the transactions will take you to the Profile Summary page below. On this page, you can examine the aggregated information of this profile.

Transaction Profile summary page

While the Profiling page can be used to view information about the profiles in our application, the Profile Summary page shows aggregated information from profiles collected under a single type of transaction.

This information allows you to dive deeper into what your code was executing during this transaction and may get you closer to the root of the problem.

If you want to narrow down your investigation to profiles executed in a specific environment, use the search bar filters.

The right side of the page has a list of the slowest functions. There's also a list of general information about the profile including:

  • When the profile was last seen
  • The total number of profiles collected for this transaction
  • p75, p95, and p99 values

On the left side of the page is an aggregate flamegraph as well as a digest of the slowest and most regressed functions. We recommend looking for wide frames that have no children as a starting point. This will allow you to identify frames that are often occupying the stack and make good candidates for optimization. Read the Flame Graphs and Aggregated Flame Graphs docs if you'd like a deeper understanding of this data.

An alternative way to visualize the flamegraph is by clicking on the "Call Tree" button which will render the flamegraph as an inverted call tree with the leftmost nodes first, which will then expand to their parent nodes. The sample column in the call tree represents the frequency with which Profiling collected stack samples where that function was on the stack. You can expand the tree by clicking on the caret before the function name. (Holding ⌘ at the same time will expand that entire branch all the way to the root.)

To learn more about profiling tools, read the docs about Flame Graphs and Aggregated Flame Graphs.

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").