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

chore(internal): Add packages set to SentrySdkInfo #4598

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

krystofwoldrich
Copy link
Member

@krystofwoldrich krystofwoldrich commented Dec 4, 2024

📜 Description

This PR adds packages to Sentry Envelope Header SDK Info and to Sentry Event SDK Info.

Before this PR packages were not set in the Event and in Header the Cocoa package was hardcoded.

💡 Motivation and Context

This will be used by hybrid SDKs to add itself as package, later we can use this information during debugging SR and other events.

💚 How did you test it?

By sending events from Sentry SwiftUI sample and unit tests.

📝 Checklist

You have to check all boxes before merging:

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

Copy link

github-actions bot commented Dec 4, 2024

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1217.10 ms 1246.40 ms 29.30 ms
Size 22.30 KiB 752.19 KiB 729.89 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
187edbf 1224.29 ms 1239.69 ms 15.40 ms
2095ae0 1238.20 ms 1251.37 ms 13.17 ms
df2835d 1218.78 ms 1238.35 ms 19.57 ms
8c9d1d4 1239.13 ms 1253.00 ms 13.87 ms
62c15d4 1235.30 ms 1260.82 ms 25.52 ms
e5ac362 1204.12 ms 1229.41 ms 25.29 ms
72c8d84 1238.96 ms 1247.34 ms 8.38 ms
fcde045 1260.71 ms 1275.00 ms 14.29 ms
e3adcd5 1206.47 ms 1215.39 ms 8.92 ms
42ef6ba 1195.04 ms 1214.35 ms 19.31 ms

App size

Revision Plain With Sentry Diff
187edbf 21.58 KiB 729.90 KiB 708.32 KiB
2095ae0 21.90 KiB 709.06 KiB 687.16 KiB
df2835d 21.58 KiB 706.14 KiB 684.55 KiB
8c9d1d4 21.58 KiB 706.97 KiB 685.39 KiB
62c15d4 22.85 KiB 411.14 KiB 388.29 KiB
e5ac362 20.76 KiB 426.11 KiB 405.34 KiB
72c8d84 22.85 KiB 408.88 KiB 386.03 KiB
fcde045 20.76 KiB 435.26 KiB 414.50 KiB
e3adcd5 21.58 KiB 539.87 KiB 518.28 KiB
42ef6ba 21.58 KiB 417.87 KiB 396.28 KiB

Previous results on branch: kw/internal-add-packages-to-sdk-info

Startup times

Revision Plain With Sentry Diff
10894a6 1228.14 ms 1248.37 ms 20.22 ms
1d36029 1236.36 ms 1257.19 ms 20.83 ms
dc421e2 1239.73 ms 1251.85 ms 12.13 ms

App size

Revision Plain With Sentry Diff
10894a6 22.30 KiB 752.13 KiB 729.83 KiB
1d36029 22.30 KiB 752.19 KiB 729.89 KiB
dc421e2 22.30 KiB 752.19 KiB 729.89 KiB

Comment on lines -104 to -107
sdk[@"packages"] = @{
@"name" : [NSString stringWithFormat:format, self.name],
@"version" : self.version
};
Copy link
Member Author

@krystofwoldrich krystofwoldrich Dec 5, 2024

Choose a reason for hiding this comment

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

Based on the development docs this should be an array, I don't know if this value was used anywhere, so I just updated it to the array.

If it's not used I would consider removing it completely and only create packages in SentryClient (same as features, integrations...).

Headers docs: https://develop.sentry.dev/sdk/data-model/envelopes/#envelope-headers

SDK Info interface docs: https://develop.sentry.dev/sdk/data-model/event-payloads/sdk/

Copy link

codecov bot commented Dec 5, 2024

Codecov Report

Attention: Patch coverage is 96.36364% with 10 lines in your changes missing coverage. Please review.

Project coverage is 91.025%. Comparing base (963b49c) to head (3b3e844).

Files with missing lines Patch % Lines
Sources/Sentry/SentrySdkPackage.m 93.103% 4 Missing ⚠️
Sources/Sentry/SentrySdkPackage+Equality.m 90.000% 1 Missing and 1 partial ⚠️
...ests/SentryTests/Protocol/SentrySdkInfo+Equality.m 50.000% 2 Missing ⚠️
Sources/Sentry/SentrySdkInfo.m 96.774% 1 Missing ⚠️
...ests/SentryTests/Protocol/SentrySdkInfoTests.swift 98.809% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #4598       +/-   ##
=============================================
+ Coverage   90.978%   91.025%   +0.047%     
=============================================
  Files          616       620        +4     
  Lines        70785     71159      +374     
  Branches     25173     25419      +246     
=============================================
+ Hits         64399     64773      +374     
+ Misses        6293      6292        -1     
- Partials        93        94        +1     
Files with missing lines Coverage Δ
Sources/Sentry/PrivateSentrySDKOnly.mm 89.447% <100.000%> (+0.161%) ⬆️
Sources/Sentry/SentryClient.m 98.703% <100.000%> (+0.001%) ⬆️
Sources/Sentry/SentryEnvelope.m 90.625% <100.000%> (+0.049%) ⬆️
Sources/Sentry/SentryMeta.m 100.000% <100.000%> (ø)
Tests/SentryTests/PrivateSentrySDKOnlyTests.swift 99.756% <100.000%> (+0.003%) ⬆️
Tests/SentryTests/Protocol/SentryMetaTests.swift 100.000% <100.000%> (ø)
Tests/SentryTests/SentryClientTests.swift 97.840% <100.000%> (+0.012%) ⬆️
Sources/Sentry/SentrySdkInfo.m 90.625% <96.774%> (-1.042%) ⬇️
...ests/SentryTests/Protocol/SentrySdkInfoTests.swift 97.005% <98.809%> (+0.815%) ⬆️
Sources/Sentry/SentrySdkPackage+Equality.m 90.000% <90.000%> (ø)
... and 2 more

... and 30 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 963b49c...3b3e844. Read the comment docs.

@krystofwoldrich krystofwoldrich marked this pull request as ready for review December 5, 2024 10:55
@krystofwoldrich
Copy link
Member Author

This seems like a lot of code for a small change, please when review let me know, if I've overlooked something and there is better place to save the packages to.

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.

I found a view high-level issues. We need to address them before I give this a more detailed review. @krystofwoldrich we can also discuss this on a call.

Comment on lines +34 to +35
andVersion:SentryMeta.versionString
andPackages:[SentryMeta getSdkPackages]];
Copy link
Member

Choose a reason for hiding this comment

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

h: The SDKInfo of the envelope header is the same as the one from the event payload: see

This can carry the same payload as the sdk interface
in the event payload but can be carried for all events. This means that SDK
information can be carried for minidumps, session data and other submissions. - https://develop.sentry.dev/sdk/data-model/envelopes/#envelope-headers

Now that we touch both SDKInfo for the envelope header and the event payload, I think it would be great to merge the different implementations. To make this easier we could do this in an extra PR before adding the new packages implementation.

/**
* Return an array of Serialized SDK packages
*/
+ (NSArray<NSDictionary<NSString *, NSString *> *> *)getSdkPackagesSerialized;
Copy link
Member

Choose a reason for hiding this comment

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

m: I don't think the SDK packages really belong here. The SentryMeta is only about version and SDK name. getSdkPackagesSerialized is a sign for me that it doesn't belong here. Instead, I would create an extra class just for the SDK packages. You can even write it in Swift.

#import "SentryMeta.h"
#import <Foundation/Foundation.h>

typedef NS_ENUM(NSUInteger, SentryPackageManagerOption) {
Copy link
Member

Choose a reason for hiding this comment

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

m: Can we convert this code to Swift, please?

# import "SentrySdkPackage.h"
#endif

@interface SentrySdkPackage ()
Copy link
Member

Choose a reason for hiding this comment

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

m: SentrySDKPackage is internal. Why did you have to add a +Private.h header?


NS_ASSUME_NONNULL_BEGIN

@interface SentrySdkPackage (Equality)
Copy link
Member

Choose a reason for hiding this comment

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

m: If we use a Swift struct for just the data of SentrySDKPackage you get isEqual for free.

@@ -10,6 +10,10 @@

- Track adoption of `enablePersistingTracesWhenCrashing` (#4587)

### Internal

- Add `packages` set to SentrySdkInfo (#4598)
Copy link

Choose a reason for hiding this comment

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

  • 🚫 The changelog entry seems to be part of an already released section ## 8.42.0.
    Consider moving the entry to the ## Unreleased section, please.

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.

2 participants