sentry-cocoa icon indicating copy to clipboard operation
sentry-cocoa copied to clipboard

Issue Ownership

Open embassem opened this issue 3 years ago • 1 comments

Platform

iOS

Installed

CocoaPods

Version

7.24.1

Steps to Reproduce

  1. Create a new Framework and have a crash func inside it
  2. use this package from an example app and call the func to crash the app
  3. create an issue onwnership on the dashboard using type module: FRAMEWORK_NAME and assign it to member/team

Expected Result

the crash should be suggested or assigned to the member/team

Actual Result

this is not happening because Sentry on Dashboard is using stacktracke.module values for the issue ownership rule module but the reported stack from the iOS SDK is Ignoring the SentryFrame.module and only sends SentryFrame.package

https://github.com/getsentry/sentry-cocoa/blob/2168cdc3bd2dbbe520316513015af1fb547c9bfc/Sources/Sentry/Public/SentryFrame.h#L25-L34

Screen Shot 2022-09-14 at 10 45 22 AM

embassem avatar Sep 14 '22 08:09 embassem

Thanks for pointing that out, @embassem. While we could start sending module, I first have to check what implications that would trigger.

I need to clarify the exact difference between module and package, as our develop docs https://develop.sentry.dev/sdk/event-payloads/stacktrace/ don't give me a clear answer.

The Android SDK sends module, but not package. Same for the Python SDK. Maybe the solution is also that issue ownership would work with package as well. Currently, it only supports module, path, URL, and tag, see https://docs.sentry.io/product/issues/issue-owners/. I will clarify that and get back to you.

philipphofmann avatar Sep 16 '22 08:09 philipphofmann

For reference, internal Slack discussion.

philipphofmann avatar Sep 28 '22 13:09 philipphofmann

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

github-actions[bot] avatar Oct 27 '22 00:10 github-actions[bot]

The SDK uses the imageName as package. The imageName contains the full path to the image, such as

  • "/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore"
  • "/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation"
  • "/private/var/containers/Bundle/Application/ED1CA0BB-A6D4-45AB-9232-9EE2802D9C7F/iOS-Swift.app/iOS-Swift"

Although the SDK sends the full path to Sentry, the JSON payload in Sentry only contains the last path components, such as UIKitCore, or iOS-Swift. So we strip the path somewhere in Sentry.

I think we could start sending module with the same value, which Sentry doesn't strip. So it would be the whole image path, which would align with our develop docs: Platform-specific module path (e.g. sentry.interfaces.Stacktrace).

philipphofmann avatar Feb 16 '23 12:02 philipphofmann

Unfortunately, setting SentryFrame.module impacts grouping; see docs and screenshot:

Screenshot 2023-02-28 at 09 05 11

I have to validate if we can make some changes on the backend to make this a nonbreaking change. Even if we do this in a major bump, it'd be highly annoying to users as every issue grouped by stacktrace would end up in a new group.

Git Diff for setting `SentryFrame.module`
diff --git a/Sources/Sentry/SentryCrashReportConverter.m b/Sources/Sentry/SentryCrashReportConverter.m
index d6672fad..65a3ae51 100644
--- a/Sources/Sentry/SentryCrashReportConverter.m
+++ b/Sources/Sentry/SentryCrashReportConverter.m
@@ -264,6 +264,7 @@ - (SentryFrame *)stackFrameAtIndex:(NSInteger)frameIndex inThreadIndex:(NSIntege
     frame.instructionAddress = sentry_formatHexAddress(frameDictionary[@"instruction_addr"]);
     frame.imageAddress = sentry_formatHexAddress(binaryImage[@"image_addr"]);
     frame.package = binaryImage[@"name"];
+    frame.module = [binaryImage[@"name"] lastPathComponent];
     BOOL isInApp = [self.inAppLogic isInApp:binaryImage[@"name"]];
     frame.inApp = @(isInApp);
     if (frameDictionary[@"symbol_name"]) {
diff --git a/Sources/Sentry/SentryCrashStackEntryMapper.m b/Sources/Sentry/SentryCrashStackEntryMapper.m
index 4937146f..c92bfa33 100644
--- a/Sources/Sentry/SentryCrashStackEntryMapper.m
+++ b/Sources/Sentry/SentryCrashStackEntryMapper.m
@@ -45,6 +45,7 @@ - (SentryFrame *)sentryCrashStackEntryToSentryFrame:(SentryCrashStackEntry)stack
         NSString *imageName = [NSString stringWithCString:stackEntry.imageName
                                                  encoding:NSUTF8StringEncoding];
         frame.package = imageName;
+        frame.module = [imageName lastPathComponent];
         frame.inApp = @([self.inAppLogic isInApp:imageName]);
     }
 
diff --git a/Sources/Sentry/SentryMetricKitIntegration.m b/Sources/Sentry/SentryMetricKitIntegration.m
index df637276..3d2b67ec 100644
--- a/Sources/Sentry/SentryMetricKitIntegration.m
+++ b/Sources/Sentry/SentryMetricKitIntegration.m
@@ -271,6 +271,7 @@ - (SentryStacktrace *)convertMXFramesToSentryStacktrace:(NSEnumerator<SentryMXFr
     for (SentryMXFrame *mxFrame in mxFrames) {
         SentryFrame *frame = [[SentryFrame alloc] init];
         frame.package = mxFrame.binaryName;
+        frame.module = [mxFrame.binaryName lastPathComponent];
         frame.instructionAddress = sentry_formatHexAddress(@(mxFrame.address));
         NSNumber *imageAddress = @(mxFrame.address - mxFrame.offsetIntoBinaryTextSegment);
         frame.imageAddress = sentry_formatHexAddress(imageAddress);

philipphofmann avatar Feb 28 '23 08:02 philipphofmann

Unfortunately, setting SentryFrame.module impacts grouping;

I believe is high unlikely that issues created by different modules have the same stacktrace, so they will end up in a new group anyway.

brustolin avatar Feb 28 '23 08:02 brustolin

@brustolin, have a look at https://sentry-sdks.sentry.io/issues/?project=5428557&query=is%3Aunresolved+captured+a+message&referrer=issue-list&statsPeriod=14d.

Screenshot 2023-02-28 at 11 31 42

Existing Grouping

https://sentry-sdks.sentry.io/issues/2895893229/events/b3a2e3a1132c43a6a5fefe8dd9e58171/?project=5428557 Screenshot 2023-02-28 at 11 34 41

New Group 1

https://sentry-sdks.sentry.io/issues/3963189205/events/1c3b5d72e9004849b54ba3a7128eb5b0/?project=5428557 Screenshot 2023-02-28 at 11 32 17

New Group 2

https://sentry-sdks.sentry.io/issues/3963200633/events/a9bebe6f64da4a2ab31968d46d4d1ef4/?project=5428557 Screenshot 2023-02-28 at 11 33 41

philipphofmann avatar Feb 28 '23 10:02 philipphofmann

You mean, errors will change from one group to another when we add modules, but then the groups will be consistent in the new rule?

IMO this is not a problem.

brustolin avatar Feb 28 '23 14:02 brustolin

IMO this is not a problem.

It will trigger tons of alerts, and the same issues will end up in different groups depending on the Cocoa SDK version. That's why it's a problem.

philipphofmann avatar Feb 28 '23 15:02 philipphofmann

This will happen for a week, maybe a little more while every user update their apps, and then wont happen anymore, and the dev will start to have the module in the event.

I would gladly accept this tradeoff as an app developer.

brustolin avatar Feb 28 '23 16:02 brustolin

@embassem, until we support module for issue ownership, you should be able to paths, as the SDK sends these, see https://docs.sentry.io/product/issues/issue-owners/#methods.

philipphofmann avatar Mar 14 '23 15:03 philipphofmann

Hello @philipphofmann, this is what we have in our setup for now, we are using paths.

embassem avatar Mar 15 '23 08:03 embassem

@embassem, is it working correctly for you? Anything we can improve?

philipphofmann avatar Mar 15 '23 15:03 philipphofmann

I'm gonna close this now as it is stale. Please let us know if this is still relevant for you.

kahest avatar Nov 08 '23 13:11 kahest