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

Improve performance of leaving breadcrumbs #863

Merged
merged 24 commits into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8aba236
Tidy up BugsnagBreadcrumbs.h
nickdowell Oct 22, 2020
f9dc70e
Remove -[BugsnagBreadcrumbs arrayValue]
nickdowell Oct 22, 2020
f39e7dd
Remove unused BugsnagBreadcrumbs.enabledBreadcrumbTypes
nickdowell Oct 22, 2020
48bf906
Remove unnecessary _Nonnull
nickdowell Oct 22, 2020
636fad7
Merge pull request #857 from bugsnag/feature/breadcrumbs-file-storage
nickdowell Oct 22, 2020
f66ab47
Implement granular breadcrumb storage
nickdowell Oct 22, 2020
45a1ce5
Fix KSCrashReport JSON syntax error
nickdowell Oct 22, 2020
57153d7
Use BSGCachesDirectory
nickdowell Oct 23, 2020
8c6d322
Sort headers
nickdowell Oct 23, 2020
7260dbb
Make cachePath nonnull
nickdowell Oct 23, 2020
f1c4943
Insert breadcrumbs into KSCrashReport
nickdowell Oct 23, 2020
9758017
Merge pull request #858 from bugsnag/feature/breadcrumbs-granular-sto…
nickdowell Oct 23, 2020
5293741
Pass NULL name for array elements
nickdowell Oct 23, 2020
4d08cbf
Add missing call to free()
nickdowell Oct 23, 2020
5f4ffc5
Move crash report writing to BugsnagBreadcrumbs.m
nickdowell Oct 26, 2020
d37e50f
Fix deletion of breadcrumb 0
nickdowell Oct 26, 2020
b68bce2
Remove NSJSONReadingFragmentsAllowed
nickdowell Oct 26, 2020
d5d44ea
Fix signed / unsigned mismatch
nickdowell Oct 26, 2020
b2a806d
Fix format string
nickdowell Oct 26, 2020
ace5928
Fix const warning
nickdowell Oct 26, 2020
c1b7261
Merge pull request #860 from bugsnag/feature/breadcrumbs-granular-sto…
nickdowell Oct 26, 2020
9eb3943
Remove in-memory breadcrumbs
nickdowell Oct 26, 2020
4699107
Merge pull request #861 from bugsnag/feature/remove-breadcrumbs-in-me…
nickdowell Oct 27, 2020
175694e
Add #863 to changelog
nickdowell Oct 27, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Bugsnag.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,9 @@
01B14C56251CE55F00118748 /* report-react-native-promise-rejection.json in Resources */ = {isa = PBXBuildFile; fileRef = 01B14C55251CE55F00118748 /* report-react-native-promise-rejection.json */; };
01B14C57251CE55F00118748 /* report-react-native-promise-rejection.json in Resources */ = {isa = PBXBuildFile; fileRef = 01B14C55251CE55F00118748 /* report-react-native-promise-rejection.json */; };
01B14C58251CE55F00118748 /* report-react-native-promise-rejection.json in Resources */ = {isa = PBXBuildFile; fileRef = 01B14C55251CE55F00118748 /* report-react-native-promise-rejection.json */; };
01C17AE72542ED7F00C102C9 /* KSCrashReportWriterTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 01C17AE62542ED7F00C102C9 /* KSCrashReportWriterTests.m */; };
01C17AE82542ED7F00C102C9 /* KSCrashReportWriterTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 01C17AE62542ED7F00C102C9 /* KSCrashReportWriterTests.m */; };
01C17AE92542ED7F00C102C9 /* KSCrashReportWriterTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 01C17AE62542ED7F00C102C9 /* KSCrashReportWriterTests.m */; };
3A700A9424A63ABC0068CD1B /* BugsnagThread.h in Headers */ = {isa = PBXBuildFile; fileRef = 3A700A8024A63A8E0068CD1B /* BugsnagThread.h */; settings = {ATTRIBUTES = (Public, ); }; };
3A700A9524A63AC50068CD1B /* BugsnagSession.h in Headers */ = {isa = PBXBuildFile; fileRef = 3A700A8124A63A8E0068CD1B /* BugsnagSession.h */; settings = {ATTRIBUTES = (Public, ); }; };
3A700A9624A63AC60068CD1B /* BugsnagStackframe.h in Headers */ = {isa = PBXBuildFile; fileRef = 3A700A8224A63A8E0068CD1B /* BugsnagStackframe.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -1272,6 +1275,7 @@
00E636C12487031D006CBF1A /* docker-compose.yml */ = {isa = PBXFileReference; lastKnownFileType = text.yaml; path = "docker-compose.yml"; sourceTree = SOURCE_ROOT; };
00E636C324878FFC006CBF1A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
01B14C55251CE55F00118748 /* report-react-native-promise-rejection.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "report-react-native-promise-rejection.json"; sourceTree = "<group>"; };
01C17AE62542ED7F00C102C9 /* KSCrashReportWriterTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KSCrashReportWriterTests.m; sourceTree = "<group>"; };
3A700A8024A63A8E0068CD1B /* BugsnagThread.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BugsnagThread.h; sourceTree = "<group>"; };
3A700A8124A63A8E0068CD1B /* BugsnagSession.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BugsnagSession.h; sourceTree = "<group>"; };
3A700A8224A63A8E0068CD1B /* BugsnagStackframe.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BugsnagStackframe.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1414,6 +1418,7 @@
008966E92486D43700DC48C2 /* KSCrashIdentifierTests.m */,
008966DF2486D43700DC48C2 /* KSCrashReportConverter_Tests.m */,
008966DE2486D43700DC48C2 /* KSCrashReportStore_Tests.m */,
01C17AE62542ED7F00C102C9 /* KSCrashReportWriterTests.m */,
008966DD2486D43700DC48C2 /* KSCrashSentry_NSException_Tests.m */,
008966E72486D43700DC48C2 /* KSCrashSentry_Signal_Tests.m */,
008966E62486D43700DC48C2 /* KSCrashSentry_Tests.m */,
Expand Down Expand Up @@ -2545,6 +2550,7 @@
008966FD2486D43700DC48C2 /* BugsnagOnBreadcrumbTest.m in Sources */,
008967812486D43700DC48C2 /* KSSystemInfo_Tests.m in Sources */,
0089671B2486D43700DC48C2 /* BugsnagSessionTest.m in Sources */,
01C17AE72542ED7F00C102C9 /* KSCrashReportWriterTests.m in Sources */,
008967A82486D43700DC48C2 /* KSCrashIdentifierTests.m in Sources */,
008967572486D43700DC48C2 /* BugsnagClientMirrorTest.m in Sources */,
0089677B2486D43700DC48C2 /* RFC3339DateTool_Tests.m in Sources */,
Expand Down Expand Up @@ -2746,6 +2752,7 @@
008967762486D43700DC48C2 /* XCTestCase+KSCrash.m in Sources */,
008967312486D43700DC48C2 /* BugsnagStateEventTest.m in Sources */,
004E35362487AFF2007FBAE4 /* BugsnagHandledStateTest.m in Sources */,
01C17AE82542ED7F00C102C9 /* KSCrashReportWriterTests.m in Sources */,
0089678B2486D43700DC48C2 /* KSCrashReportStore_Tests.m in Sources */,
00896A412486DBDD00DC48C2 /* BSGConfigurationBuilderTests.m in Sources */,
008967672486D43700DC48C2 /* BugsnagNotifierTest.m in Sources */,
Expand Down Expand Up @@ -2905,6 +2912,7 @@
CBA2249D251E429C00B87416 /* TestSupport.m in Sources */,
004E35372487AFF2007FBAE4 /* BugsnagHandledStateTest.m in Sources */,
0089678C2486D43700DC48C2 /* KSCrashReportStore_Tests.m in Sources */,
01C17AE92542ED7F00C102C9 /* KSCrashReportWriterTests.m in Sources */,
00896A422486DBDD00DC48C2 /* BSGConfigurationBuilderTests.m in Sources */,
008967682486D43700DC48C2 /* BugsnagNotifierTest.m in Sources */,
0089676E2486D43700DC48C2 /* BugsnagTestsDummyClass.m in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
<dict>
<key>baselineAverage</key>
<real>0.28</real>
<real>0.0488</real>
<key>baselineIntegrationDisplayName</key>
<string>Local Baseline</string>
</dict>
Expand Down
46 changes: 30 additions & 16 deletions Bugsnag/Breadcrumbs/BugsnagBreadcrumbs.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,47 +8,61 @@

#import <Foundation/Foundation.h>

#import "BugsnagBreadcrumb.h"
#import "BugsnagConfiguration.h"
@class BugsnagBreadcrumb;
@class BugsnagConfiguration;
typedef struct BSG_KSCrashReportWriter BSG_KSCrashReportWriter;

typedef void (^BSGBreadcrumbConfiguration)(BugsnagBreadcrumb *_Nonnull);

#pragma mark -

NS_ASSUME_NONNULL_BEGIN

@interface BugsnagBreadcrumbs : NSObject

- (instancetype _Nonnull)initWithConfiguration:(BugsnagConfiguration *_Nonnull)config;
- (instancetype)initWithConfiguration:(BugsnagConfiguration *)config;

/**
* The current breadcrumbs, loaded from disk.
*/
@property (readonly) NSArray<BugsnagBreadcrumb *> *breadcrumbs;

/**
* Path where breadcrumbs are persisted on disk
*/
@property (nonatomic, readonly, strong, nullable) NSString *cachePath;
@property (readonly) NSString *cachePath;

/**
* Store a new breadcrumb with a provided message.
*/
- (void)addBreadcrumb:(NSString *_Nonnull)breadcrumbMessage;
- (void)addBreadcrumb:(NSString *)breadcrumbMessage;

/**
* Store a new breadcrumb configured via block.
*
* @param block configuration block
*/
- (void)addBreadcrumbWithBlock:
(void (^_Nonnull)(BugsnagBreadcrumb *_Nonnull))block;
- (void)addBreadcrumbWithBlock:(BSGBreadcrumbConfiguration)block;

/**
* Generates an array of dictionaries representing the current buffer of breadcrumbs.
* Returns the breadcrumb JSON dictionaries stored on disk.
*/
- (NSArray *_Nonnull)arrayValue;
- (nullable NSArray<NSDictionary *> *)cachedBreadcrumbs;

/**
* Returns an array containing the current buffer of breadcrumbs.
* Removes breadcrumbs from disk.
*/
- (NSArray<BugsnagBreadcrumb *> *_Nonnull)getBreadcrumbs;
- (void)removeAllBreadcrumbs;

@end

NS_ASSUME_NONNULL_END

#pragma mark -

/**
* The types of breadcrumbs which will be automatically captured.
* By default, this is all types.
* Inserts the current breadcrumbs into a crash report.
*
* This function is async-signal-safe.
*/
@property BSGEnabledBreadcrumbType enabledBreadcrumbTypes;

@end
void BugsnagBreadcrumbsWriteCrashReport(const BSG_KSCrashReportWriter * _Nonnull writer);
Loading