-
-
Notifications
You must be signed in to change notification settings - Fork 371
Structured Logs: Add SentrySwiftLog Integration
#6286
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6286 +/- ##
========================================
Coverage ? 85.153%
========================================
Files ? 452
Lines ? 27657
Branches ? 12120
========================================
Hits ? 23551
Misses ? 4060
Partials ? 46
Continue to review full report in Codecov by Sentry.
|
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| d66f082 | 1227.08 ms | 1247.04 ms | 19.96 ms |
| 09471ff | 1239.98 ms | 1256.65 ms | 16.67 ms |
| fc0757d | 1231.83 ms | 1248.98 ms | 17.15 ms |
| 1bf432b | 1200.22 ms | 1226.90 ms | 26.67 ms |
| b6f8eb3 | 1217.94 ms | 1246.57 ms | 28.63 ms |
| 2ec2700 | 1238.28 ms | 1258.82 ms | 20.53 ms |
| 52603c5 | 1226.94 ms | 1257.66 ms | 30.72 ms |
| 409a607 | 1229.57 ms | 1251.45 ms | 21.88 ms |
| 7d88965 | 1228.86 ms | 1248.53 ms | 19.67 ms |
| 2be5991 | 1228.55 ms | 1264.65 ms | 36.10 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| d66f082 | 23.75 KiB | 928.85 KiB | 905.10 KiB |
| 09471ff | 23.75 KiB | 990.16 KiB | 966.41 KiB |
| fc0757d | 23.75 KiB | 850.73 KiB | 826.98 KiB |
| 1bf432b | 23.75 KiB | 926.64 KiB | 902.90 KiB |
| b6f8eb3 | 23.75 KiB | 988.70 KiB | 964.95 KiB |
| 2ec2700 | 23.75 KiB | 980.80 KiB | 957.05 KiB |
| 52603c5 | 23.75 KiB | 969.78 KiB | 946.03 KiB |
| 409a607 | 23.74 KiB | 874.08 KiB | 850.33 KiB |
| 7d88965 | 23.75 KiB | 994.72 KiB | 970.98 KiB |
| 2be5991 | 23.75 KiB | 994.73 KiB | 970.98 KiB |
Previous results on branch: denrase/swift-log-sentry-poc
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 0fd08ab | 1225.14 ms | 1256.49 ms | 31.35 ms |
| f23a1b4 | 1226.17 ms | 1264.55 ms | 38.38 ms |
| b52b178 | 1227.86 ms | 1255.65 ms | 27.79 ms |
| 2bd1339 | 1223.22 ms | 1248.85 ms | 25.64 ms |
| 53379e0 | 1231.19 ms | 1269.38 ms | 38.20 ms |
| 6245148 | 1229.77 ms | 1269.93 ms | 40.17 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 0fd08ab | 23.75 KiB | 995.43 KiB | 971.68 KiB |
| f23a1b4 | 23.75 KiB | 1.01 MiB | 1016.14 KiB |
| b52b178 | 23.75 KiB | 989.97 KiB | 966.22 KiB |
| 2bd1339 | 23.75 KiB | 1.01 MiB | 1006.48 KiB |
| 53379e0 | 23.75 KiB | 1.00 MiB | 1002.40 KiB |
| 6245148 | 23.75 KiB | 1023.82 KiB | 1000.07 KiB |
# Conflicts: # Package.swift # Sentry.xcodeproj/project.pbxproj
swift-log IntegrationSentrySwiftLog Integration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just a small comment
| # Clean up orphaned commas and fix syntax | ||
| sed -i '' '/^[[:space:]]*,$/d' $PACKAGE_FILE | ||
| sed -i '' 's/name: "Sentry\(-.*\)\?"$/name: "Sentry\1",/g' $PACKAGE_FILE | ||
| sed -i '' 's/platforms: \[\.iOS(\.v11), \.macOS(\.v10_13), \.tvOS(\.v11), \.watchOS(\.v4)\]$/platforms: [.iOS(.v11), .macOS(.v10_13), .tvOS(.v11), .watchOS(.v4)],/g' $PACKAGE_FILE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this trying to do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the CI jobs is replacing dependencies with local build artefacts. This broke, as swift-log was added to our Package.swift. This code fixes those issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this only happen because of swift-log or should we do the fix in a separate PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only because of swift-log dependency added in our Package.swift
| .library(name: "SentrySwiftUI", targets: ["Sentry", "SentrySwiftUI", "SentryCppHelper"]), | ||
| .library(name: "SentryDistribution", targets: ["SentryDistribution"]) | ||
| .library(name: "SentryDistribution", targets: ["SentryDistribution"]), | ||
| .library(name: "SentrySwiftLog", targets: ["Sentry", "SentrySwiftLog"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
m: I don't fully understand why this is another target. Is this only here because swift-log is a new dependency? Shouldn't we add it as a dependency to Sentry instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The intent was to only pull in the dependency for users that actually are using swift-log, but then again, I am not sure how this would behave if a user is not using SentrySwiftLog target. Will check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, there is a proposal that was partially adopted:
I created a sample app with a similar setup. While SPM will always resolve the dependency, it will bot be linked/build if it is not required by the target.
So this setup works as expected.
# Conflicts: # Sentry.xcodeproj/project.pbxproj
# Conflicts: # Sentry.xcodeproj/project.pbxproj
# Conflicts: # Package.swift # Sentry.xcodeproj/project.pbxproj
📜 Description
The Sentry
swift-logintegration.Setup
SentrySwiftLogas a target toSentrytargetSentrySwiftLogtoPackage.swiftiOS15-SwiftUiapp so you can play around with itImplementation
SentryLogHandlersentry-logmetadata is mapped to attributes and prefixed withswift-logDiscussion
Here vs Own Repo
Added the integration to this repo, because it is easier for us to maintain.
On the
swift-logrepo integrations section is linking to the swift package index with search termswift-log. So for visibility, we'd need to have a separateswift-log-sentryrepo.https://github.com/apple/swift-log?tab=readme-ov-file#available-log-handler-backends
https://swiftpackageindex.com/search?query=swift-log
Distribution
Only distributed through SPM, as
swift-logdropped support for CocoaPods. Also, we'll not be able to distribute this as a binary, asswift-logis not supporting that.💡 Motivation and Context
Closes #5372
💚 How did you test it?
Unit Tests
Sample App
📝 Checklist
You have to check all boxes before merging:
sendDefaultPIIis enabled.