-
-
Notifications
You must be signed in to change notification settings - Fork 358
[Structured Logging] Public API & Send Logs Envelope #5532
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 ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5532 +/- ##
=============================================
+ Coverage 86.175% 86.310% +0.134%
=============================================
Files 407 409 +2
Lines 35091 35217 +126
Branches 15025 15291 +266
=============================================
+ Hits 30240 30396 +156
+ Misses 4808 4773 -35
- Partials 43 48 +5
... and 18 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
# Conflicts: # Sources/Sentry/SentryDependencyContainer.m
Sources/Sentry/SentryClient.m
Outdated
[self.logBatcher processLog:log with:scope]; | ||
} | ||
|
||
// SentryLogBatcherDelegate |
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.
Using the delegation pattern to avoid injecting transportAdapter
into the batcher.
- (SentryLogger *)logger SENTRY_THREAD_SANITIZER_DOUBLE_CHECKED_LOCK | ||
{ | ||
SENTRY_LAZY_INIT(_logger, ({ | ||
_logger = [[SentryLogger alloc] initWithHub: SentrySDK.currentHub |
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.
Not happy with using SentrySDK.currentHub
static accessor here TBH. Would be great to get your perspective here on how to avoid this. Dependency injection?
super.init() | ||
} | ||
|
||
public func trace(_ body: String) { |
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.
These methods are the user facing api, accessed by SentrySDK.logger.trace(...)
etc.
|
||
@_spi(Private) public func processLog(_ log: SentryLog, with scope: Scope) { | ||
do { | ||
let envelope = try SentryEnvelope(logs: [log]) |
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.
For now we only create the envelope from logs. Actual batching will be implemented in a later PR.
SentryEnvelope, imported with `@_implementationOnly import _SentryPrivate` is being ‚exposed‘ by SentryLogBatcher as public, even with _spi(Private). Movet the delegate protocol to ObjC to fix this.
Performance metrics 🚀
|
Revision | Plain | With Sentry | Diff |
---|---|---|---|
9be5373 | 1215.92 ms | 1239.44 ms | 23.52 ms |
db9572a | 1223.13 ms | 1241.60 ms | 18.47 ms |
aa96485 | 1215.37 ms | 1234.04 ms | 18.67 ms |
701b301 | 1226.10 ms | 1245.57 ms | 19.47 ms |
4d264fa | 1223.48 ms | 1246.91 ms | 23.44 ms |
8fd192f | 1202.10 ms | 1220.19 ms | 18.09 ms |
e18d392 | 1228.69 ms | 1244.43 ms | 15.73 ms |
d637379 | 1226.43 ms | 1250.77 ms | 24.34 ms |
7908e84 | 1224.33 ms | 1246.39 ms | 22.06 ms |
f92cfa9 | 1228.45 ms | 1251.33 ms | 22.88 ms |
App size
Revision | Plain | With Sentry | Diff |
---|---|---|---|
9be5373 | 23.75 KiB | 866.50 KiB | 842.75 KiB |
db9572a | 23.75 KiB | 858.64 KiB | 834.89 KiB |
aa96485 | 23.75 KiB | 874.46 KiB | 850.71 KiB |
701b301 | 23.75 KiB | 867.16 KiB | 843.41 KiB |
4d264fa | 23.74 KiB | 874.07 KiB | 850.33 KiB |
8fd192f | 23.74 KiB | 872.75 KiB | 849.01 KiB |
e18d392 | 23.75 KiB | 866.68 KiB | 842.93 KiB |
d637379 | 23.75 KiB | 855.38 KiB | 831.63 KiB |
7908e84 | 23.74 KiB | 872.75 KiB | 849.00 KiB |
f92cfa9 | 23.75 KiB | 855.38 KiB | 831.62 KiB |
@@ -14,6 +14,14 @@ NS_ASSUME_NONNULL_BEGIN | |||
replayRecording:(SentryReplayRecording *)replayRecording | |||
video:(NSURL *)videoURL; | |||
|
|||
- (instancetype)initWithHeader:(SentryEnvelopeItemHeader *)header data:(NSData *)data; |
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.
These are not correct, but it was the only way to get access to SentryEnvelope
in the Swift part of the SDK.
The SPM action on CLI is failing, as SentryEnvelope.h
cannot be found.
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.
Failing CI: https://github.com/getsentry/sentry-cocoa/actions/runs/16053769859/job/45302808174?pr=5532
I'm sure there's a correct way to access SDK internal classes from the Swift code that i'm not aware of.
|
||
@interface SentryEnvelope () | ||
|
||
- (instancetype)initWithId:(SentryId *_Nullable)id singleItem:(SentryEnvelopeItem *)item; |
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.
Dito
API Stability Check is failing for now, as i want to have feedback before resolving this. |
@@ -0,0 +1,41 @@ | |||
@_implementationOnly import _SentryPrivate |
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.
SPM is not building as SentryEnvelope
can't be accessed.
import Foundation | ||
|
||
#if CARTHAGE || SWIFT_PACKAGE | ||
import Sentry._Hybrid |
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.
Just a failed attempt to resolve the SPM issue.
#skip-changelog
📜 Description
SentryLogger
, which is the user facing API:capture
methods toHub
andClient
enableLogs
to experimental options💡 Motivation and Context
This mirrors the structures we have on the Flutter SDK and should be seen as a first attempt to integrate this into cocoa. So please scrutinise it and give me feedback so we can get this right. 🙇
The placement in the Swift folders of the added classes is also something i was not sure about.
Needed to change
SentryLog
to a class in order to integrate with the ObjCHub
. Kept as much as possible Swift only and module internal.Also, this is obviously missing many other features (default attributes, user attributes, client reports, batching, etc), but the PR is large enough as is and I hope that the next ones are smaller again.
Relates to #5122
💚 How did you test it?
Unit tests + tried to send a log in the sample app.
📝 Checklist
You have to check all boxes before merging:
sendDefaultPII
is enabled.