diff --git a/CHANGELOG.md b/CHANGELOG.md index 95ff44c6e..c2b117580 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### Features -- When running on Android, the SDK now links errors and events originating on different layers (managed, native errors) via `trace ID` ([#1997](https://github.com/getsentry/sentry-unity/pull/1997)) +- When running on Android, Windows or Linux, the SDK now links errors and events originating on different layers (managed, native errors) via `trace ID` ([#1997](https://github.com/getsentry/sentry-unity/pull/1997), [#2089](https://github.com/getsentry/sentry-unity/pull/2089)) - The SDK now reports the game's name as part of the app context ([2083](https://github.com/getsentry/sentry-unity/pull/2083)) - The SDK now reports the active scene's name as part of the `Unity Context` ([2084](https://github.com/getsentry/sentry-unity/pull/2084)) diff --git a/src/Sentry.Unity.Android/AndroidJavaScopeObserver.cs b/src/Sentry.Unity.Android/AndroidJavaScopeObserver.cs index 0f80acfd8..199de6498 100644 --- a/src/Sentry.Unity.Android/AndroidJavaScopeObserver.cs +++ b/src/Sentry.Unity.Android/AndroidJavaScopeObserver.cs @@ -17,6 +17,7 @@ public AndroidJavaScopeObserver(SentryOptions options, IJniExecutor jniExecutor) } private static AndroidJavaObject GetSentryJava() => new AndroidJavaClass("io.sentry.Sentry"); + private static AndroidJavaObject GetInternalSentryJava() => new AndroidJavaClass("io.sentry.android.core.InternalSentrySdk"); public override void AddBreadcrumbImpl(Breadcrumb breadcrumb) diff --git a/src/Sentry.Unity.Native/NativeScopeObserver.cs b/src/Sentry.Unity.Native/NativeScopeObserver.cs index 3499e38d8..5263ae2b7 100644 --- a/src/Sentry.Unity.Native/NativeScopeObserver.cs +++ b/src/Sentry.Unity.Native/NativeScopeObserver.cs @@ -45,6 +45,9 @@ public override void SetTraceImpl(SentryId traceId, SpanId spanId) // TODO: Needs to be implemented } + public override void SetTraceImpl(SentryId traceId, SpanId spanId) => + C.sentry_set_trace(traceId.ToString(), spanId.ToString()); + private static string GetTimestamp(DateTimeOffset timestamp) => // "o": Using ISO 8601 to make sure the timestamp makes it to the bridge correctly. // https://docs.microsoft.com/en-gb/dotnet/standard/base-types/standard-date-and-time-format-strings#Roundtrip diff --git a/src/Sentry.Unity.iOS/NativeScopeObserver.cs b/src/Sentry.Unity.iOS/NativeScopeObserver.cs index 836a8532e..ca69e4bd0 100644 --- a/src/Sentry.Unity.iOS/NativeScopeObserver.cs +++ b/src/Sentry.Unity.iOS/NativeScopeObserver.cs @@ -30,6 +30,11 @@ public override void SetTraceImpl(SentryId traceId, SpanId spanId) // TODO: Needs to be implemented } + public override void SetTraceImpl(SentryId traceId, SpanId spanId) + { + // Todo: Needs to be implemented + } + internal static string GetTimestamp(DateTimeOffset timestamp) => // "o": Using ISO 8601 to make sure the timestamp makes it to the bridge correctly. // https://docs.microsoft.com/en-gb/dotnet/standard/base-types/standard-date-and-time-format-strings#Roundtrip diff --git a/src/Sentry.Unity/NativeUtils/CFunctions.cs b/src/Sentry.Unity/NativeUtils/CFunctions.cs index 3af0f1b69..76088e02b 100644 --- a/src/Sentry.Unity/NativeUtils/CFunctions.cs +++ b/src/Sentry.Unity/NativeUtils/CFunctions.cs @@ -148,6 +148,9 @@ internal static void SetValueIfNotNull(sentry_value_t obj, string key, double? v [DllImport("sentry")] internal static extern void sentry_remove_extra(string key); + [DllImport("sentry")] + internal static extern void sentry_set_trace(string traceId, string parentSpanId); + internal static readonly Lazy> DebugImages = new(LoadDebugImages); private static IEnumerable LoadDebugImages()