Skip to content

Commit 75d3996

Browse files
authored
feat: Propagate traceId on platforms supported by sentry-native (#2089)
1 parent 98a2e87 commit 75d3996

File tree

5 files changed

+13
-1
lines changed

5 files changed

+13
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### Features
66

7-
- 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))
7+
- 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))
88
- The SDK now reports the game's name as part of the app context ([2083](https://github.com/getsentry/sentry-unity/pull/2083))
99
- The SDK now reports the active scene's name as part of the `Unity Context` ([2084](https://github.com/getsentry/sentry-unity/pull/2084))
1010

src/Sentry.Unity.Android/AndroidJavaScopeObserver.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public AndroidJavaScopeObserver(SentryOptions options, IJniExecutor jniExecutor)
1717
}
1818

1919
private static AndroidJavaObject GetSentryJava() => new AndroidJavaClass("io.sentry.Sentry");
20+
2021
private static AndroidJavaObject GetInternalSentryJava() => new AndroidJavaClass("io.sentry.android.core.InternalSentrySdk");
2122

2223
public override void AddBreadcrumbImpl(Breadcrumb breadcrumb)

src/Sentry.Unity.Native/NativeScopeObserver.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ public override void SetTraceImpl(SentryId traceId, SpanId spanId)
4545
// TODO: Needs to be implemented
4646
}
4747

48+
public override void SetTraceImpl(SentryId traceId, SpanId spanId) =>
49+
C.sentry_set_trace(traceId.ToString(), spanId.ToString());
50+
4851
private static string GetTimestamp(DateTimeOffset timestamp) =>
4952
// "o": Using ISO 8601 to make sure the timestamp makes it to the bridge correctly.
5053
// https://docs.microsoft.com/en-gb/dotnet/standard/base-types/standard-date-and-time-format-strings#Roundtrip

src/Sentry.Unity.iOS/NativeScopeObserver.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ public override void SetTraceImpl(SentryId traceId, SpanId spanId)
3030
// TODO: Needs to be implemented
3131
}
3232

33+
public override void SetTraceImpl(SentryId traceId, SpanId spanId)
34+
{
35+
// Todo: Needs to be implemented
36+
}
37+
3338
internal static string GetTimestamp(DateTimeOffset timestamp) =>
3439
// "o": Using ISO 8601 to make sure the timestamp makes it to the bridge correctly.
3540
// https://docs.microsoft.com/en-gb/dotnet/standard/base-types/standard-date-and-time-format-strings#Roundtrip

src/Sentry.Unity/NativeUtils/CFunctions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ internal static void SetValueIfNotNull(sentry_value_t obj, string key, double? v
148148
[DllImport("sentry")]
149149
internal static extern void sentry_remove_extra(string key);
150150

151+
[DllImport("sentry")]
152+
internal static extern void sentry_set_trace(string traceId, string parentSpanId);
153+
151154
internal static readonly Lazy<IEnumerable<DebugImage>> DebugImages = new(LoadDebugImages);
152155

153156
private static IEnumerable<DebugImage> LoadDebugImages()

0 commit comments

Comments
 (0)