Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Propagate traceId to native layer #1998

@bitsandfoxes

Description

@bitsandfoxes

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 trace API 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 trace API
  • ❌ 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

  1. Typically, we disable the performance feature on the native layer, keeping it to the "head" SDK.
  2. This makes these SDKs fall back on the TwP, using the PropagationContext on 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:

Android SDK:

.NET SDK:

Cocoa SDK:

React Native SDK:

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.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureNew feature or request

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions