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

Backtrace data models serialization optimization #144

Open
wants to merge 116 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 111 commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
809a69b
Org.json serializer
Aug 10, 2023
50b5a7b
Performance tests
Aug 21, 2023
24680bb
Tmp serialization
Aug 26, 2023
feb8ee3
Improve serializer
Aug 30, 2023
ec19211
Remove unused code
Aug 30, 2023
88d2df8
Remove unused code
Aug 30, 2023
0c8c1e8
Deserializer
Aug 30, 2023
3f67d73
Deserialization unit tests
Sep 17, 2023
e4fe04b
Add sample json
Sep 18, 2023
5e9d7f5
Merge branch 'master' into org-json-serializer
Sep 25, 2023
79c1f08
Add naming converter to allow different casing on serialization
Sep 28, 2023
3943c32
Fix gson differences
Oct 4, 2023
5af11bd
Json org serializer tests
Oct 9, 2023
c8fee80
Merge branch 'master' into org-json-serializer
Oct 11, 2023
9aa36f2
Add unit tests, code refactor
Oct 17, 2023
78fcdc0
Add unit tests for naming converter
Oct 17, 2023
0f673a9
Replace gson serializer
Oct 18, 2023
312a57d
Fix unit tests
Oct 18, 2023
fb0a261
Add tmp deserializer
Nov 1, 2023
58019d0
Merge branch 'master' into org-json-serializer
Dec 4, 2023
6f52f47
Add custom serializer annotation
Dec 11, 2023
91d74b5
Deserialize refactor
Dec 31, 2023
8dff878
Fix
Dec 31, 2023
9ffd261
Code refactor
Jan 2, 2024
b9a63d9
Unit tests deserializer
Jan 10, 2024
3686709
Serialize exception
Feb 6, 2024
b8e01b4
Prepare unit test for backtrace data
Feb 6, 2024
f89ec68
Deserializer database record
Feb 7, 2024
fb1ff11
Add field name cache and annotation reader
Feb 8, 2024
c9d5074
Refactor Backtrace result api
Feb 10, 2024
3f21f87
Implementation of next deserialization methods of Backtrace Data obj
Feb 11, 2024
9817c7b
Add next deserializers
Feb 17, 2024
8cc35d6
Deserializers implementation
Feb 17, 2024
3c21c68
Deserialize backtrace data annotation, add unit test checks
Feb 28, 2024
a9d8f51
Add next tests
Mar 5, 2024
83781e8
Fix backtrace data deserialization
Mar 5, 2024
621f84b
Merge branch 'master' into backtrace-data-refactor
Apr 3, 2024
6daa876
Remove unused file
Apr 3, 2024
7c693fc
Fix doc
Apr 3, 2024
546968f
Code cleanup
Apr 3, 2024
c42e6c8
Remove unused code
Apr 3, 2024
6b6db45
Optimize imports
Apr 3, 2024
fd8a6d5
Fixes and unit tests
Apr 3, 2024
1829c4c
Merge branch 'master' into backtrace-data-refactor
May 21, 2024
f936667
Fix unit tests
May 21, 2024
ec62127
Add extra check
May 22, 2024
77d0fb8
Remove commented code
May 22, 2024
e0dd7a3
Fix naming
May 22, 2024
f1c44a5
Revert custom serializer
May 27, 2024
fb1b6f9
Remove deserializer tests
May 27, 2024
71a00e7
Remove unused file
May 27, 2024
b81b4ce
Optimize imports
May 27, 2024
8230f86
Merge branch 'master' into backtrace-data-refactor
May 27, 2024
44078b4
Merge branch 'backtrace-data-refactor' into backtrace-data-models-ref…
May 27, 2024
66359f7
Merge branch 'BT-2920/optimize-imports' into backtrace-data-models-re…
May 28, 2024
e6f7abc
Merge branch 'master' into backtrace-data-models-refactor
May 29, 2024
8bacf18
Use get report method
May 29, 2024
2759a60
Move getters below
May 29, 2024
8072dfd
Rename method
May 29, 2024
e515faa
Remove todo
May 29, 2024
fd20277
Remove todo
May 29, 2024
0602990
Remove todo
May 29, 2024
8c89316
Remove unused code
May 29, 2024
804251c
Remove todo
May 29, 2024
b68784d
Improve backtrace-report model
May 29, 2024
9189726
Remove unused files
May 29, 2024
0faf51c
Use getters
May 29, 2024
3e082d7
Remove todo
May 29, 2024
d253450
Remove unnecessary annotation
May 29, 2024
600c3b1
Merge branch 'master' into backtrace-data-models-refactor
May 29, 2024
a4175d3
Merge branch 'master' into backtrace-data-models-refactor
Jun 12, 2024
98381cc
Add unit tests for BacktraceResult and BacktraceApiResult
Jun 12, 2024
428f880
Merge branch 'master' into backtrace-data-models-refactor
Jun 19, 2024
9c4311c
Add Thread information tests
Jun 19, 2024
8e87bee
Add test for backtrace stack frame
Jul 8, 2024
55e92f0
Refactor db record test
Jul 8, 2024
ad59a87
Add unit tests
Jul 9, 2024
e9012b4
Add unit tests
Jul 9, 2024
fb49d59
Test backtrace report
Jul 15, 2024
83d153b
Backtrace report unit tests
Jul 15, 2024
dbc6e58
Add BacktraceData unit tests
Jul 16, 2024
0f20ef0
Add backtrace data unit tests
Jul 17, 2024
93a4222
Refactor unit-tests
Jul 17, 2024
7174fbd
Remove todo
Jul 17, 2024
b43e341
Merge branch 'backtrace-data-use-report-getter' into backtrace-data-m…
Jul 22, 2024
737a032
Merge branch 'master' into backtrace-data-models-refactor
Aug 12, 2024
8970185
Merge branch 'master' into backtrace-data-models-refactor
BartoszLitwiniuk Aug 14, 2024
30e4d08
Merge branch 'master' into backtrace-data-models-refactor
BartoszLitwiniuk Aug 14, 2024
72360ef
PR improvements
Aug 20, 2024
503db78
Fix warnings
Aug 21, 2024
1001d6f
Merge branch 'master' into backtrace-data-models-refactor
BartoszLitwiniuk Oct 2, 2024
f5a2e74
Use getter for report
Oct 2, 2024
bf20af1
Bump guava version
Oct 2, 2024
6af0b6a
Add backward compatibility
Oct 7, 2024
5cd32b2
Add backward compatibility
Oct 7, 2024
6382adb
Tmp
Oct 9, 2024
96ede96
Add backward compatibility
Oct 9, 2024
2b91f66
Backward compatibility
Oct 9, 2024
c93cfb3
Tmp change
Oct 15, 2024
d1e9a40
Remove unused code
Oct 15, 2024
4d9e1e6
Add doc
Oct 15, 2024
c51af92
Resolve TODOs
Oct 21, 2024
eefc7a6
Update deprecated docs
Oct 21, 2024
f385467
Fix enum issue with different status case
Oct 22, 2024
f96cc52
Add BacktraceResultStatus tests
Oct 23, 2024
e15ff05
Mock logger in StackFrame tests
Oct 23, 2024
3a51ad1
Fix BacktraceData tests
Oct 23, 2024
2c2d3c2
Add BacktraceData constructor test
Oct 23, 2024
4b76c02
Improve formatting
Oct 23, 2024
7a3eb9d
Revert test changes
Oct 23, 2024
ad7017b
Reverse test args
Oct 23, 2024
59df612
Revert removed method
Oct 24, 2024
835dd1d
Throw exception instead of return null
Oct 24, 2024
f254db4
Add deprecated docs to BacktraceStackFrame constructors
Oct 24, 2024
52282bc
Fix minify json - use JSONObject to verify serialization
Oct 24, 2024
ca7cda6
Refactor BacktraceData builder - move to separated methods
Oct 25, 2024
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
1 change: 1 addition & 0 deletions backtrace-library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
androidTestImplementation 'org.mockito:mockito-core:5.2.0'
androidTestImplementation "org.mockito:mockito-android:2.28.2"
testImplementation "com.google.guava:guava:33.3.1-jre"
}

apply from: 'publish.gradle'
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void sendBacktraceExceptionAttachments() {
RequestHandler rh = new RequestHandler() {
@Override
public BacktraceResult onRequest(BacktraceData data) {
return new BacktraceResult(data.getReport(), data.report.exception.getMessage(),
return new BacktraceResult(data.getReport(), data.getReport().exception.getMessage(),
BacktraceResultStatus.Ok);
}
};
Expand Down Expand Up @@ -104,7 +104,7 @@ public void sendBacktraceExceptionNoAttachments() {
RequestHandler rh = new RequestHandler() {
@Override
public BacktraceResult onRequest(BacktraceData data) {
return new BacktraceResult(data.getReport(), data.report.exception.getMessage(),
return new BacktraceResult(data.getReport(), data.getReport().exception.getMessage(),
BacktraceResultStatus.Ok);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import net.jodah.concurrentunit.Waiter;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -30,19 +31,26 @@ public class BacktraceClientAttributeTests {
private BacktraceCredentials credentials;
private BacktraceDatabase database;

private BacktraceClient backtraceClient;

@Before
public void setUp() {
context = InstrumentationRegistry.getInstrumentation().getContext();
credentials = new BacktraceCredentials("https://example-endpoint.com/", "");
database = new BacktraceDatabase(context, context.getFilesDir().getAbsolutePath());
backtraceClient = new BacktraceClient(context, credentials, database);
}

@After
public void cleanUp() {
database.clear();
}

@Test
public void shouldAddASingleAttribute() {
// GIVEN
final String attributeKey = "test-attribute";
final String attributeValue = "test-value";
final BacktraceClient backtraceClient = new BacktraceClient(context, credentials, database);

// WHEN
backtraceClient.addAttribute(attributeKey, attributeValue);
Expand All @@ -66,7 +74,6 @@ public void shouldAddMultipleAttributesAtOnce() {
attributes.put(String.format("%s %d", attributeKey, attributeIteration), attributeValue);
}
// WHEN
final BacktraceClient backtraceClient = new BacktraceClient(context, credentials, database);
backtraceClient.addAttribute(attributes);

// THEN
Expand All @@ -85,7 +92,6 @@ public void shouldReplaceExistingAttribute() {
final String newAttributeValue = "test-value-new";

// WHEN
final BacktraceClient backtraceClient = new BacktraceClient(context, credentials, database);
backtraceClient.addAttribute(attributeKey, oldAttributeValue);

backtraceClient.addAttribute(attributeKey, newAttributeValue);
Expand Down Expand Up @@ -129,14 +135,14 @@ public void attributesShouldBeAvailableInReport() {
final String errorMessage = "error message";
final String attributeKey = "test-attribute";
final String attributeValue = "test-value";
final BacktraceClient backtraceClient = new BacktraceClient(context, credentials, database);

backtraceClient.addAttribute(attributeKey, attributeValue);
RequestHandler rh = data -> {
// THEN
Object value = data.attributes.get(attributeKey);
Object value = data.getAttributes().get(attributeKey);
assertNotNull(value);
assertEquals(value, attributeValue);
return new BacktraceResult(data.getReport(), data.report.exception.getMessage(),
return new BacktraceResult(data.getReport(), data.getReport().exception.getMessage(),
BacktraceResultStatus.Ok);
};
backtraceClient.setOnRequestHandler(rh);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void sendBacktraceExceptionBreadcrumbs() {
RequestHandler rh = new RequestHandler() {
@Override
public BacktraceResult onRequest(BacktraceData data) {
return new BacktraceResult(data.getReport(), data.report.exception.getMessage(),
return new BacktraceResult(data.getReport(), data.getReport().exception.getMessage(),
BacktraceResultStatus.Ok);
}
};
Expand Down Expand Up @@ -122,7 +122,7 @@ public void sendBacktraceExceptionBreadcrumbsAddBreadcrumb() {
RequestHandler rh = new RequestHandler() {
@Override
public BacktraceResult onRequest(BacktraceData data) {
return new BacktraceResult(data.getReport(), data.report.exception.getMessage(),
return new BacktraceResult(data.getReport(), data.getReport().exception.getMessage(),
BacktraceResultStatus.Ok);
}
};
Expand Down Expand Up @@ -276,7 +276,7 @@ public void sendBacktraceExceptionNoBreadcrumbs() {
RequestHandler rh = new RequestHandler() {
@Override
public BacktraceResult onRequest(BacktraceData data) {
return new BacktraceResult(data.report, data.report.exception.getMessage(),
return new BacktraceResult(data.getReport(), data.getReport().exception.getMessage(),
BacktraceResultStatus.Ok);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void useBeforeSendAndRequestHandler() {
RequestHandler rh = new RequestHandler() {
@Override
public BacktraceResult onRequest(BacktraceData data) {
return new BacktraceResult(null, data.attributes.get(attributeKey),
return new BacktraceResult(null, data.getAttributes().get(attributeKey),
BacktraceResultStatus.Ok);
}
};
Expand All @@ -95,7 +95,7 @@ public BacktraceResult onRequest(BacktraceData data) {
backtraceClient.setOnBeforeSendEventListener(new OnBeforeSendEventListener() {
@Override
public BacktraceData onEvent(BacktraceData data) {
data.attributes.put(attributeKey, resultMessage);
data.getAttributes().put(attributeKey, resultMessage);
return data;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void sendBacktraceReportWithStringAndAttributesProguard() {
RequestHandler rh = new RequestHandler() {
@Override
public BacktraceResult onRequest(BacktraceData data) {
assertEquals("proguard", data.symbolication);
assertEquals("proguard", data.getSymbolication());
return new BacktraceResult(data.getReport(), data.getReport().message,
BacktraceResultStatus.Ok);
}
Expand Down Expand Up @@ -97,7 +97,7 @@ public void sendBacktraceReportWithStringAndAttributesNoProguard() {
RequestHandler rh = new RequestHandler() {
@Override
public BacktraceResult onRequest(BacktraceData data) {
assertNull(data.symbolication);
assertNull(data.getSymbolication());
return new BacktraceResult(data.getReport(), data.getReport().message,
BacktraceResultStatus.Ok);
}
Expand Down Expand Up @@ -138,7 +138,7 @@ public void sendBacktraceReportWithExceptionAndAttributesProguard() {
RequestHandler rh = new RequestHandler() {
@Override
public BacktraceResult onRequest(BacktraceData data) {
assertEquals("proguard", data.symbolication);
assertEquals("proguard", data.getSymbolication());
return new BacktraceResult(data.getReport(), data.getReport().exception.getMessage(),
BacktraceResultStatus.Ok);
}
Expand Down Expand Up @@ -180,7 +180,7 @@ public void sendBacktraceReportWithExceptionAndAttributesNoProguard() {
RequestHandler rh = new RequestHandler() {
@Override
public BacktraceResult onRequest(BacktraceData data) {
assertNull(data.symbolication);
assertNull(data.getSymbolication());
return new BacktraceResult(data.getReport(), data.getReport().exception.getMessage(),
BacktraceResultStatus.Ok);
}
Expand Down Expand Up @@ -224,7 +224,7 @@ public void sendBacktraceExceptionProguard() {
RequestHandler rh = new RequestHandler() {
@Override
public BacktraceResult onRequest(BacktraceData data) {
assertEquals("proguard", data.symbolication);
assertEquals("proguard", data.getSymbolication());
return new BacktraceResult(data.getReport(), data.getReport().exception.getMessage(),
BacktraceResultStatus.Ok);
}
Expand Down Expand Up @@ -266,7 +266,7 @@ public void sendBacktraceExceptionNoProguard() {
RequestHandler rh = new RequestHandler() {
@Override
public BacktraceResult onRequest(BacktraceData data) {
assertNull(data.symbolication);
assertNull(data.getSymbolication());
return new BacktraceResult(data.getReport(), data.getReport().exception.getMessage(),
BacktraceResultStatus.Ok);
}
Expand Down Expand Up @@ -309,7 +309,7 @@ public void sendBacktraceStringProguard() {
RequestHandler rh = new RequestHandler() {
@Override
public BacktraceResult onRequest(BacktraceData data) {
assertEquals("proguard", data.symbolication);
assertEquals("proguard", data.getSymbolication());
return new BacktraceResult(data.getReport(), data.getReport().message,
BacktraceResultStatus.Ok);
}
Expand Down Expand Up @@ -351,7 +351,7 @@ public void sendBacktraceStringNoProguard() {
RequestHandler rh = new RequestHandler() {
@Override
public BacktraceResult onRequest(BacktraceData data) {
assertNull(data.symbolication);
assertNull(data.getSymbolication());
return new BacktraceResult(data.getReport(), data.getReport().message,
BacktraceResultStatus.Ok);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void sendExceptionWithManyCause() {
fail(e.getMessage());
}

return new BacktraceResult(data.getReport(), data.report.message,
return new BacktraceResult(data.getReport(), data.getReport().message,
BacktraceResultStatus.Ok);
};
backtraceClient.setOnRequestHandler(rh);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import backtraceio.library.models.BacktraceResult;
import backtraceio.library.models.database.BacktraceDatabaseSettings;
import backtraceio.library.models.json.BacktraceAttributes;
import backtraceio.library.models.json.BacktraceReport;
import backtraceio.library.models.types.BacktraceResultStatus;


Expand Down Expand Up @@ -176,10 +177,13 @@ public void run() {
@Override
public BacktraceResult onRequest(BacktraceData data) {
// THEN
waiter.assertTrue(data.getReport().attributes.containsKey(customClientAttributeKey));
waiter.assertEquals(customClientAttributeValue, data.getReport().attributes.get(customClientAttributeKey));

final BacktraceReport dataReport = data.getReport();
waiter.assertTrue(dataReport.attributes.containsKey(customClientAttributeKey));
waiter.assertEquals(customClientAttributeValue, dataReport.attributes.get(customClientAttributeKey));
waiter.assertEquals(exceptionMessage, data.getReport().exception.getMessage());
waiter.assertEquals(data.getReport().attributes.get(BacktraceAttributeConsts.ErrorType), BacktraceAttributeConsts.UnhandledExceptionAttributeType);
waiter.assertEquals(dataReport.attributes.get(BacktraceAttributeConsts.ErrorType), BacktraceAttributeConsts.UnhandledExceptionAttributeType);

waiter.resume();
return new BacktraceResult(data.getReport(), "", BacktraceResultStatus.Ok);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,13 @@ public void setUp() {
this.context = InstrumentationRegistry.getInstrumentation().getContext();
this.dbPath = this.context.getFilesDir().getAbsolutePath();
this.databaseSettings = new BacktraceDatabaseSettings(this.dbPath, RetryOrder.Queue);
this.databaseContext = new BacktraceDatabaseContext(this.context, this.databaseSettings);
this.databaseContext = new BacktraceDatabaseContext(this.databaseSettings);
}

@After
public void after() {
this.databaseContext.clear();
}


@Test
public void firstFromDatabaseContextQueue() {
// GIVEN
Expand Down Expand Up @@ -79,7 +77,7 @@ public void lastFromDatabaseContextQueue() {
public void firstFromDatabaseContextStack() {
// GIVEN
BacktraceDatabaseSettings settings = new BacktraceDatabaseSettings(this.dbPath, RetryOrder.Stack);
this.databaseContext = new BacktraceDatabaseContext(this.context, settings);
this.databaseContext = new BacktraceDatabaseContext(settings);
List<BacktraceDatabaseRecord> records = fillDatabase();

// WHEN
Expand All @@ -94,7 +92,7 @@ public void firstFromDatabaseContextStack() {
public void lastFromDatabaseContextStack() {
// GIVEN
BacktraceDatabaseSettings settings = new BacktraceDatabaseSettings(this.dbPath, RetryOrder.Stack);
this.databaseContext = new BacktraceDatabaseContext(this.context, settings);
this.databaseContext = new BacktraceDatabaseContext(settings);
List<BacktraceDatabaseRecord> records = fillDatabase();

// WHEN
Expand Down Expand Up @@ -147,7 +145,7 @@ public void notContainsInDatabaseContext() {
// GIVEN
fillDatabase();
BacktraceReport report = new BacktraceReport(this.testMessage);
BacktraceData data = new BacktraceData(this.context, report, null);
BacktraceData data = new BacktraceData.Builder(this.context, report, null).build();
BacktraceDatabaseRecord record = new BacktraceDatabaseRecord(data, this.dbPath);

// WHEN
Expand Down Expand Up @@ -236,7 +234,7 @@ public void tryDeleteNotExistingRecordFromDatabaseContext() {
// GIVEN
fillDatabase();
BacktraceReport report = new BacktraceReport(this.testMessage);
BacktraceData data = new BacktraceData(this.context, report, null);
BacktraceData data = new BacktraceData.Builder(this.context, report, null).build();
BacktraceDatabaseRecord record = new BacktraceDatabaseRecord(data, this.dbPath);

// WHEN
Expand All @@ -261,9 +259,9 @@ private List<BacktraceDatabaseRecord> fillDatabase() {
BacktraceReport report = new BacktraceReport(this.testMessage);
BacktraceReport report2 = new BacktraceReport(this.testMessage);
BacktraceReport report3 = new BacktraceReport(this.testMessage);
BacktraceData data = new BacktraceData(this.context, report, null);
BacktraceData data2 = new BacktraceData(this.context, report2, null);
BacktraceData data3 = new BacktraceData(this.context, report3, null);
BacktraceData data = new BacktraceData.Builder(this.context, report, null).build();
BacktraceData data2 = new BacktraceData.Builder(this.context, report2, null).build();
BacktraceData data3 = new BacktraceData.Builder(this.context, report3, null).build();
result.add(databaseContext.add(data));
result.add(databaseContext.add(data2));
result.add(databaseContext.add(data3));
Expand Down
Loading
Loading