Enabling Out Of The Box Performance Insights In The Unity SDK
Article Summary
Stefan Jandl from Sentry just cracked a tough problem: how do you auto-instrument performance monitoring in Unity games without asking developers to write a single line of code?
Unity games run on every platform imaginable, but traditional mobile performance monitoring concepts like screen navigation don't translate to game engines. Sentry's team needed to find universal hooks that work across all Unity games while providing actionable insights developers actually care about.
Key Takeaways
- IL weaving injects performance tracking into compiled C# code during build process
- Auto-instruments game startup and scene loading without any developer configuration
- Wraps every GameObject's Awake method to capture initialization bottlenecks automatically
- Unity SDK ships native SDKs for each platform via P/Invoke for crash reporting
Sentry's Unity SDK now delivers out-of-the-box performance traces for startup and scene loading across all platforms with zero code changes required.
About This Article
Unity games update 30-60 times per second, which makes creating spans for every frame impractical. The SDK needed a way to identify which logical operations were worth measuring without relying on fixed instrumentation points that would work across different game architectures.
Stefan Jandl's team used the Cecil library to perform IL weaving on the compiled Assembly-CSharp.dll file. They injected span tracking into MonoBehaviour Awake methods using just three lines of code that wrap around the user's initialization logic.
Developers can now see complete trace views that break down startup and scene loading performance automatically across all platforms. There's no configuration needed and no manual code changes required.