-
-
Notifications
You must be signed in to change notification settings - Fork 62
Description
Problem Statement
The Unity SDK currently lacks proper trace ID propagation from the managed (C#) layer to the underlying native SDKs (Cocoa, Android, Native). This creates disconnected traces across different layers of the application, making it difficult to correlate events. There is no way to connect C# errors prior to a native event outside of breadcrumb messages.
Current Status by Platform
Native SDK
- ❌ No propagation context available on the scope
- ❌ Missing functionality to set trace context on the scope
- ❌ No
continue traceAPI implementation - Impact: Events from native crashes cannot be correlated with their originating managed traces
Android SDK
- ✅ Java errors are connected by a trace ID
- ❌ Native SDK trace context missing
- ❌ NDK Scope Observer not propagating trace ID
- Impact: Mixed trace propagation success; native crashes still disconnected
Cocoa SDK
- ❌ Missing
continue traceAPI - ❌ Trace propagation via bridge not functioning
- Impact: Crash events generate new trace IDs instead of continuing existing traces
.NET SDK
- ❌ Missing functionality for the Unity SDK to set and control the trace ID's lifecycle
Proposal
What we're working here right now is
- Typically, we disable the performance feature on the native layer, keeping it to the "head" SDK.
- This makes these SDKs fall back on the TwP, using the
PropagationContexton the scope
We could add some internal SetTrace method that allows an SDK to set the trace on the native SDK's propagation context. This can then be observed and in turn, be propagated further down the layers.
We'd also need a way to disable any auto-trace-generation on those native SDKs.
Step by Step
Native SDK:
- Add trace context support to scope: feat: Added
sentry_set_tracesentry-native#1137 -
(Optional) Addcontinue traceAPI -
(Optional) Implement propagation context mechanism - Let the Unity SDK propagate the trace ID to the native layer for Windows & Linux feat: Propagate
traceIdon platforms supported bysentry-native#2089
Android SDK:
- Implement trace context support in native layer feat: Added
sentry_set_tracesentry-native#1137 - Prevent the Java SDK from generating trace IDs. This is achieved via a dedicated
enableTraceIdGenerationto theAndroidOptionsfeat: AddedenableTraceIdGenerationoption sentry-java#4188 - Implement
SetTracefeat: Allow Hybrid SDK tosetTracesentry-java#4137 - Extend NDK Scope Observer to handle trace ID propagation: feat: Allow Hybrid SDK to
setTracesentry-java#4137 - Let the Unity SDK propagate the trace ID on Android and further, to native feat: Propagate
traceIdto the Android SDK #1997
.NET SDK:
- Provide
SetTracefunctionality so the Unity SDK can take control over the trace ID generation feat: AllowIScopeObserverto observe trace sentry-dotnet#4026 - Extend ScopeObserver to handle trace ID propagation
Cocoa SDK:
-
Prevent the Cocoa SDK from generating trace IDs.The SDK does this by creating a new propagationContext when creating a new scope. - Implement
SetTracefeat: Allow Hybrid SDKs tosetTracesentry-cocoa#5081 - Update bridge to use
SetTrace. feat: PropagatetraceIdto the Cocoa SDK #2106 - Extend ScopeObserver to handle trace ID propagation. feat: Propagate
traceIdto the Cocoa SDK #2106
React Native SDK:
- Tracking that separately here Synchronize
PropagationContextacross layers sentry-react-native#3918
Expected Outcome
After implementation, all events (managed and native) should maintain consistent trace IDs throughout the entire crash reporting pipeline. This enables proper event correlation across all layers of Unity games.
Metadata
Metadata
Assignees
Labels
Projects
Status
