Ottrelite Core is the main tracing API that provides a lightweight, unified interface for performance instrumentation across all React Native platforms. It offers a simple set of methods to trace synchronous operations, asynchronous workflows, and counter metrics in your React Native applications.
Ottrelite Core supports tracing across all major React Native development languages:
| Feature | Status |
|---|---|
| C++ API | ✅ |
| JS API | ✅ |
| Swift API | ⏳ (in progress, see #4 for details) |
| Java/Kotlin API | ✅ |
First, install the package with:
The quickest way to use Ottrelite is via the Tracing API.
Before you use Ottrelite, you need to configure it by including the following Ottrelite.install() call in your entrypoint file (e.g. index.js):
To learn more about available backends, see the backends section.
In case of debugging performance problems, tracing usually makes sense only in optimized builds, not debug builds. Debug builds are unoptimized (both native and JavaScript sides) and their performance may not be representative of production.
Recommended approach: Create a separate build configuration specifically for performance profiling (e.g., "profiling" or "release-dev") instead of using the production release configuration. This ensures you get optimized performance characteristics while avoiding the risk of accidentally shipping tracing code to production.
To record synchronous traces, you can use the Ottrelite.beginEvent() and Ottrelite.endEvent() methods. The beginEvent method starts a new event (imagine it is put on top of a stack), while the endEvent method ends the most recent event (analogy: popping it off the stack). The event name is a string that identifies the event.
Events maintain a hierarchical structure, so you can nest them. If you begin a new event while another one is already in progress, the new event will be a child of the previous one.
To record asynchronous traces, you can use the Ottrelite.beginAsyncEvent() and Ottrelite.endAsyncEvent() methods. The beginAsyncEvent method starts a new asynchronous event, while the endAsyncEvent method ends the most recent asynchronous event.
To record counter events, you can use the Ottrelite.counterEvent() method. This method allows you to record a numeric value over time, which can be useful for tracking metrics such as performance counters.