Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
4c00864
propagate during startup
bitsandfoxes Jan 29, 2025
3dc1d67
setting trace in java
bitsandfoxes Feb 7, 2025
c3c8ff8
merged main
bitsandfoxes Feb 25, 2025
59976fe
bump
bitsandfoxes Feb 27, 2025
43b1486
test
bitsandfoxes Feb 27, 2025
63d5a25
bumped java
bitsandfoxes Feb 28, 2025
18c23cc
bumped java
bitsandfoxes Mar 3, 2025
85bf657
use scope observer instead
bitsandfoxes Mar 5, 2025
ddd5619
merged all kinds of things
bitsandfoxes Mar 28, 2025
882eed9
updated trace generation and sync
bitsandfoxes Mar 28, 2025
84d971c
removed redundant android trace start
bitsandfoxes Mar 31, 2025
559deab
.
bitsandfoxes Mar 31, 2025
e708ade
native and ios scope observers are not there yet
bitsandfoxes Mar 31, 2025
6d8e9af
Merge branch 'main' into feat/propagate-traceid-android
bitsandfoxes Mar 31, 2025
165b425
Format code
getsentry-bot Mar 31, 2025
256a721
bump .NET to get the scope observer
bitsandfoxes Mar 31, 2025
929073c
starting a trace
bitsandfoxes Mar 31, 2025
3203e9c
merged
bitsandfoxes Mar 31, 2025
de43fd5
Updated CHANGELOG.md
bitsandfoxes Mar 31, 2025
9aeb52e
Updated CHANGELOG.md
bitsandfoxes Mar 31, 2025
f2cfb1a
use internal API
bitsandfoxes Apr 2, 2025
fa68abf
Merge branch 'main' into feat/propagate-traceid-android
bitsandfoxes Apr 2, 2025
f16e148
merged main
bitsandfoxes Apr 3, 2025
8894c78
merged
bitsandfoxes Apr 3, 2025
bb2a09a
sync for macOS
bitsandfoxes Apr 9, 2025
db260c7
Merge branch 'main' into feat/propagate-traceid-android
bitsandfoxes Apr 9, 2025
6013e11
.
bitsandfoxes Apr 9, 2025
6265ac0
bump
bitsandfoxes Apr 9, 2025
3c0b627
Merge branch 'feat/propagate-traceid-desktop' into feat/cocoa-sync-tr…
bitsandfoxes Apr 9, 2025
04eb298
implemented observer
bitsandfoxes Apr 9, 2025
41a625f
pause
bitsandfoxes Apr 9, 2025
675c3ae
.
bitsandfoxes Apr 9, 2025
c05d425
return success state
bitsandfoxes Apr 9, 2025
260e67f
Merge remote-tracking branch 'origin/fix/macos-native-init' into feat…
bitsandfoxes Apr 9, 2025
a1d1c27
.
bitsandfoxes Apr 9, 2025
6084429
enable setTrace in bridge
bitsandfoxes Apr 10, 2025
e48ae6c
merged
bitsandfoxes Apr 10, 2025
451ab78
fixed conflicts
bitsandfoxes Apr 10, 2025
250aed7
more merge conflicts
bitsandfoxes Apr 10, 2025
f001e3a
missing bridge code
bitsandfoxes Apr 10, 2025
7953bd7
nope bridge
bitsandfoxes Apr 10, 2025
f4a2e8b
merged
bitsandfoxes Apr 10, 2025
f926798
adapt the iOS bridge
bitsandfoxes Apr 11, 2025
1473956
fixed the iOS bridge (fr this time)
bitsandfoxes Apr 11, 2025
53f81c6
proxy fix. ios bridge sentryid lookup
bitsandfoxes Apr 14, 2025
ed5fb58
Merge branch 'main' into feat/cocoa-sync-trace-id
bitsandfoxes Apr 17, 2025
3794566
bump cocoa
bitsandfoxes Apr 22, 2025
f697a37
Updated CHANGELOG.md
bitsandfoxes Apr 22, 2025
5d1fc48
Merge branch 'main' into feat/cocoa-sync-trace-id
bitsandfoxes Apr 22, 2025
5a49697
Updated CHANGELOG.md
bitsandfoxes Apr 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@

### Features

- The SDK now links errors and events (managed and native errors) via `trace ID`. This allows you to correlate events captured from different layers of your game ([#1997](https://github.com/getsentry/sentry-unity/pull/1997), [#2089](https://github.com/getsentry/sentry-unity/pull/2089), [#2106](https://github.com/getsentry/sentry-unity/pull/2106))
- Drastically improved performance of scope sync when targeting Android ([#2107](https://github.com/getsentry/sentry-unity/pull/2107))
- 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))

### Dependencies

- Bump Cocoa SDK from v8.45.0 to v8.49.0 ([#2063](https://github.com/getsentry/sentry-unity/pull/2063), [#2071](https://github.com/getsentry/sentry-unity/pull/2071), [#2105](https://github.com/getsentry/sentry-unity/pull/2105))
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8490)
- [diff](https://github.com/getsentry/sentry-cocoa/compare/8.45.0...8.49.0)
- Bump Cocoa SDK from v8.45.0 to v8.49.1 ([#2063](https://github.com/getsentry/sentry-unity/pull/2063), [#2071](https://github.com/getsentry/sentry-unity/pull/2071), [#2105](https://github.com/getsentry/sentry-unity/pull/2105), [#2106](https://github.com/getsentry/sentry-unity/pull/2106))
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8491)
- [diff](https://github.com/getsentry/sentry-cocoa/compare/8.45.0...8.49.1)
- Bump Java SDK from v8.3.0 to v8.8.0 ([#2066](https://github.com/getsentry/sentry-unity/pull/2066), [#2075](https://github.com/getsentry/sentry-unity/pull/2075), [#2092](https://github.com/getsentry/sentry-unity/pull/2092), [#2103](https://github.com/getsentry/sentry-unity/pull/2103), [#2111](https://github.com/getsentry/sentry-unity/pull/2111))
- [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#880)
- [diff](https://github.com/getsentry/sentry-java/compare/8.3.0...8.8.0)
Expand Down
2 changes: 1 addition & 1 deletion modules/sentry-cocoa.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = 8.49.0
version = 8.49.1
repo = https://github.com/getsentry/sentry-cocoa
23 changes: 23 additions & 0 deletions package-dev/Plugins/iOS/SentryNativeBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,29 @@ void SentryNativeBridgeUnsetUser()
return cString;
}

void SentryNativeBridgeSetTrace(const char *traceId, const char *spanId)
{
if (traceId == NULL || spanId == NULL) {
return;
}

NSString *traceIdStr = [NSString stringWithUTF8String:traceId];
NSString *spanIdStr = [NSString stringWithUTF8String:spanId];

// This is a workaround to deal with SentryId living inside the Swift header
Class sentryIdClass = NSClassFromString(@"_TtC6Sentry8SentryId");
Class sentrySpanIdClass = NSClassFromString(@"SentrySpanId");

if (sentryIdClass && sentrySpanIdClass) {
id sentryTraceId = [[sentryIdClass alloc] initWithUUIDString:traceIdStr];
id sentrySpanId = [[sentrySpanIdClass alloc] initWithValue:spanIdStr];

if (sentryTraceId && sentrySpanId) {
[PrivateSentrySDKOnly setTrace:sentryTraceId spanId:sentrySpanId];
}
}
}

static inline NSString *_NSStringOrNil(const char *value)
{
return value ? [NSString stringWithUTF8String:value] : nil;
Expand Down
2 changes: 2 additions & 0 deletions package-dev/Plugins/iOS/SentryNativeBridgeNoOp.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ void SentryNativeBridgeUnsetUser() { }

char *SentryNativeBridgeGetInstallationId() { return NULL; }

void SentryNativeBridgeSetTrace(const char *traceId, const char *spanId) { }

void SentryNativeBridgeWriteScope( // clang-format off
// // const char *AppStartTime,
// const char *AppBuildType,
Expand Down
31 changes: 31 additions & 0 deletions package-dev/Plugins/macOS/SentryNativeBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
static Class SentryBreadcrumb;
static Class SentryUser;
static Class SentryOptions;
static Class SentryId;
static Class SentrySpanId;
static Class PrivateSentrySDKOnly;

#define LOAD_CLASS_OR_BREAK(name) \
Expand All @@ -17,6 +19,13 @@
break; \
}

#define LOAD_SWIFT_CLASS_OR_BREAK(name, mangled_name) \
name = (__bridge Class)dlsym(dylib, "OBJC_CLASS_$_" #mangled_name); \
if (!name) { \
NSLog(@"Sentry (bridge): Couldn't load class '" #name "' from the dynamic library"); \
break; \
}

// Returns (bool): 0 on failure, 1 on success
// WARNING: you may only call other Sentry* functions AFTER calling this AND only if it returned "1"
int SentryNativeBridgeLoadLibrary()
Expand All @@ -40,6 +49,8 @@ int SentryNativeBridgeLoadLibrary()
LOAD_CLASS_OR_BREAK(SentryBreadcrumb)
LOAD_CLASS_OR_BREAK(SentryUser)
LOAD_CLASS_OR_BREAK(SentryOptions)
LOAD_SWIFT_CLASS_OR_BREAK(SentryId, _TtC6Sentry8SentryId)
LOAD_CLASS_OR_BREAK(SentrySpanId)
LOAD_CLASS_OR_BREAK(PrivateSentrySDKOnly)

// everything above passed - mark as successfully loaded
Expand Down Expand Up @@ -263,6 +274,26 @@ void SentryNativeBridgeUnsetUser()
return cString;
}

void SentryNativeBridgeSetTrace(const char *traceId, const char *spanId)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the iOS and Mac bridges the same? I wonder if we could use symlinks

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, they are not. Functionally, yes, but we load the lib dynamically on macOS:

/*******************************************************************************/
/* The remaining code is a copy of iOS/SentryNativeBridge.m with changes to */
/* make it work with dynamically loaded classes. Mainly: */
/* - call: [class performSelector:@selector(arg1:arg2:) */
/* withObject:arg1Value withObject:arg2Value]; */
/* or xCode warns of class/instance method not found */
/* - use `id` as variable types */
/* - use [obj setValue:value forKey:@"prop"] instead of `obj.prop = value` */
/*******************************************************************************/

{
if (traceId == NULL || spanId == NULL) {
return;
}

id sentryTraceId = [[SentryId alloc]
performSelector:@selector(initWithUUIDString:)
withObject:[NSString stringWithUTF8String:traceId]];

id sentrySpanId = [[SentrySpanId alloc]
performSelector:@selector(initWithValue:)
withObject:[NSString stringWithUTF8String:spanId]];

[PrivateSentrySDKOnly
performSelector:@selector(setTrace:spanId:)
withObject:sentryTraceId
withObject:sentrySpanId];
}

static inline NSString *_NSStringOrNil(const char *value)
{
return value ? [NSString stringWithUTF8String:value] : nil;
Expand Down
6 changes: 2 additions & 4 deletions src/Sentry.Unity.iOS/NativeScopeObserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ public override void SetUserImpl(SentryUser user) =>

public override void UnsetUserImpl() => SentryCocoaBridgeProxy.UnsetUser();

public override void SetTraceImpl(SentryId traceId, SpanId spanId)
{
// TODO: Needs to be implemented
}
public override void SetTraceImpl(SentryId traceId, SpanId spanId) =>
SentryCocoaBridgeProxy.SetTrace(traceId.ToString(), spanId.ToString());

internal static string GetTimestamp(DateTimeOffset timestamp) =>
// "o": Using ISO 8601 to make sure the timestamp makes it to the bridge correctly.
Expand Down
3 changes: 3 additions & 0 deletions src/Sentry.Unity.iOS/SentryCocoaBridgeProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,7 @@ public static bool Init(SentryUnityOptions options)

[DllImport("__Internal", EntryPoint = "SentryNativeBridgeGetInstallationId")]
public static extern string GetInstallationId();

[DllImport("__Internal", EntryPoint = "SentryNativeBridgeSetTrace")]
public static extern void SetTrace(string traceId, string spanId);
}