Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: CoreData tracking entity name retrieval #2329

Merged
merged 2 commits into from
Nov 2, 2022

Conversation

armcknight
Copy link
Member

@armcknight armcknight commented Oct 25, 2022

Fixes #2328 and possible bug in CoreData tracker.

I originally noticed a system error logged for us using a non-designated initializer for an NSManagedObject subclass. Fixing that led to some test failures:

image

which led to me discovering that we might have only ever tracked CoreData entity transactions using "NSManagedObject" in the span descriptions instead of the actual entity names being used by developers.

Comment on lines -150 to +151
for (id item in entities) {
NSString *cl = NSStringFromClass([item class]);
for (NSManagedObject *item in entities) {
NSString *cl = item.entity.name;
Copy link
Member Author

Choose a reason for hiding this comment

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

This is an actual functional change that I think was a bug.

@github-actions
Copy link

github-actions bot commented Oct 25, 2022

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1201.93 ms 1237.96 ms 36.03 ms
Size 20.50 KiB 338.91 KiB 318.41 KiB

Baseline results on branch: master

Startup times

Revision Plain With Sentry Diff
791123d 1256.10 ms 1266.68 ms 10.58 ms
202334c 1265.41 ms 1277.34 ms 11.93 ms
e2f1150 1220.39 ms 1249.94 ms 29.55 ms
5ecf9f6 1230.76 ms 1232.86 ms 2.10 ms
654f180 1220.08 ms 1248.76 ms 28.67 ms
4a188b8 1229.81 ms 1255.96 ms 26.15 ms
7138b7d 1243.40 ms 1252.08 ms 8.68 ms
0fdf0b2 1243.92 ms 1250.86 ms 6.94 ms
3e85a23 1244.94 ms 1265.55 ms 20.61 ms
5025d2e 1248.52 ms 1251.72 ms 3.20 ms

App size

Revision Plain With Sentry Diff
791123d 20.51 KiB 331.81 KiB 311.30 KiB
202334c 20.51 KiB 331.79 KiB 311.28 KiB
e2f1150 20.51 KiB 333.10 KiB 312.59 KiB
5ecf9f6 20.51 KiB 332.66 KiB 312.15 KiB
654f180 20.50 KiB 335.95 KiB 315.45 KiB
4a188b8 20.50 KiB 337.70 KiB 317.20 KiB
7138b7d 20.51 KiB 331.79 KiB 311.28 KiB
0fdf0b2 20.51 KiB 332.90 KiB 312.39 KiB
3e85a23 20.50 KiB 339.00 KiB 318.49 KiB
5025d2e 20.51 KiB 331.79 KiB 311.28 KiB

Copy link
Contributor

@brustolin brustolin left a comment

Choose a reason for hiding this comment

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

Thanks for this.
Looks like the bug is only during test.
I run the old code in production and it gets the right name, but I believe your change will keep this future proof.

@armcknight
Copy link
Member Author

armcknight commented Oct 31, 2022

Oh interesting, I wonder if that's because there's no xcdatamodel/NSManagedObjectModel in the unit tests @brustolin ? 🤔

If that's the case and there's no actual user-facing bug right now, i'll remove the changelog entry.

@brustolin
Copy link
Contributor

Oh interesting, I wonder if that's because there's no xcdatamodel/NSManagedObjectModel in the unit tests @brustolin ? 🤔

If that's the case and there's no actual user-facing bug right now, i'll remove the changelog entry.

Im not sure if this is the reason.
But is totally possible to have Core data in a project without the xcdatamodel.
No need to remove the changelog entry.

Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

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

Thanks.

@armcknight armcknight merged commit 1453a8a into master Nov 2, 2022
@armcknight armcknight deleted the armcknight/fix/coredata-entity-names branch November 2, 2022 23:26
kevinrenskers added a commit that referenced this pull request Nov 7, 2022
* master:
  test: Delete empty OOMLogicTests (#2361)
  fix: profiling transaction timestamps (#2359)
  fix: profiling transaction thread IDs (#2358)
  test: Use flush for macOS-SPM sample (#2360)
  release: 7.30.0
  fix: SentryCrash writing nan for invalid number (#2348)
  HTTP Client errors (#2308)
  ci: Call make for analyze (#2353)
  fix: CoreData tracking entity name retrieval (#2329)
  fix: sampled profile format backend validation errors (#2350)
  build(deps): bump github/codeql-action from 2.1.29 to 2.1.30 (#2351)
  build(deps): bump github/codeql-action from 2.1.28 to 2.1.29 (#2344)
  fix: Fixed flaky testTimezoneChangeNotificationBreadcrumb (#2335)

# Conflicts:
#	Sentry.xcodeproj/project.pbxproj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CoreData TestEntity error in test logs
4 participants