Sentry Stefan Jandl Nov 4, 2024

Enabling Out Of The Box Performance Insights In The Unity SDK

M2 Related OWASP risk: Inadequate Supply Chain Security Learn more →

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

Critical Insight

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.

The IL weaving technique they built opens doors for auto-instrumenting UnityWebRequests and UI interactions next.

About This Article

Problem

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.

Solution

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.

Impact

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.