Skip to content

Commit f07cdb1

Browse files
Merge pull request #579 from lukecotter/feature-soql-dml-rows-columns-on-calltree
feat: soql + dml row counts
2 parents f5dbd47 + 83ab8ca commit f07cdb1

8 files changed

Lines changed: 326 additions & 43 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- Table actions: Copy to clipboard and Export to CSV directly from the button above the Analysis and Database table ([#589]).
1414
- Sort grouped rows by clicking column headers ([#592]).
1515
- Tri state on Group name column will sort by number of items in the group
16+
- Replace the Rows column on the Call Tree with two seperate columns, DML rows and SOQL rows ([#93]).
17+
- Replace Rows count on the Timeline tooltip with two new counts, DML rows and SOQL rows ([#93]).
1618

1719
### Changed
1820

@@ -391,6 +393,7 @@ Skipped due to adopting odd numbering for pre releases and even number for relea
391393
[#589]: https://github.com/certinia/debug-log-analyzer/issues/589
392394
[#590]: https://github.com/certinia/debug-log-analyzer/issues/590
393395
[#592]: https://github.com/certinia/debug-log-analyzer/issues/592
396+
[#93]: https://github.com/certinia/debug-log-analyzer/issues/93
394397

395398
<!-- 1.16.1 -->
396399

log-viewer/modules/__tests__/ApexLogParser.test.ts

Lines changed: 181 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,8 @@ describe('parseLog tests', () => {
432432
parent: execEvent,
433433
type: 'SOQL_EXECUTE_BEGIN',
434434
aggregations: 2,
435-
rowCount: { self: 50, total: 50 },
435+
soqlRowCount: { self: 50, total: 50 },
436+
soqlCount: { self: 1, total: 1 },
436437
});
437438

438439
const soqlExplain = soqlLine.children[0] as SOQLExecuteExplainLine;
@@ -1179,3 +1180,182 @@ describe('Line Type Tests', () => {
11791180
expect(qp.sObjectType).toBe(null);
11801181
});
11811182
});
1183+
1184+
describe('Aggregating Totals', () => {
1185+
it('should sum from child to parent', () => {
1186+
const logArray = [
1187+
'01:02:03.04 (0)|EXECUTION_STARTED',
1188+
'01:02:03.04 (1)|METHOD_ENTRY|[1]|a00000000000000|ns.MyClass.myMethod()',
1189+
'01:02:03.04 (2)|METHOD_ENTRY|[1]|a00000000000000|ns.MyClass.soql()',
1190+
'01:02:03.04 (3)|SOQL_EXECUTE_BEGIN|[2]|Aggregations:0|SELECT ID FROM MyObject__c',
1191+
'01:02:03.04 (4)|SOQL_EXECUTE_END|[2]|Rows:1',
1192+
'01:02:03.04 (5)|SOQL_EXECUTE_BEGIN|[2]|Aggregations:0|SELECT ID FROM MyObject__c',
1193+
'01:02:03.04 (6)|SOQL_EXECUTE_END|[2]|Rows:2',
1194+
'01:02:03.04 (7)|METHOD_EXIT|[1]|a00000000000000|ns.MyClass.soql()',
1195+
'01:02:03.04 (8)|METHOD_ENTRY|[1]|a00000000000000|ns.MyClass.dml()',
1196+
'01:02:03.04 (9)|DML_BEGIN|[194]|Op:Update|Type:ns2__MyObject__c|Rows:1',
1197+
'01:02:03.04 (10)|DML_END|[194]',
1198+
'01:02:03.04 (11)|DML_BEGIN|[194]|Op:Update|Type:ns2__MyObject__c|Rows:4',
1199+
'01:02:03.04 (12)|DML_END|[194]',
1200+
'01:02:03.04 (13)|METHOD_EXIT|[1]|a00000000000000|ns.MyClass.dml()',
1201+
'01:02:03.04 (14)|METHOD_ENTRY|[1]|a00000000000000|ns.MyClass.sosl()',
1202+
"01:02:03.04 (15)|SOSL_EXECUTE_BEGIN|[1]|FIND 'hello*' IN ALL FIELDS RETURNING account(Id, Name)",
1203+
'01:02:03.04 (16)|SOSL_EXECUTE_END|[1]|Rows:250',
1204+
"01:02:03.04 (17)|SOSL_EXECUTE_BEGIN|[1]|FIND 'hello*' IN ALL FIELDS RETURNING account(Id, Name)",
1205+
'01:02:03.04 (18)|SOSL_EXECUTE_END|[1]|Rows:150',
1206+
'01:02:03.04 (19)|EXCEPTION_THROWN|[60]|System.LimitException: c2g:Too many SOQL queries: 101',
1207+
'01:02:03.04 (20)|METHOD_EXIT|[1]|a00000000000000|ns.MyClass.sosl()',
1208+
'01:02:03.04 (21)|EXCEPTION_THROWN|[60]|System.LimitException: c2g:Too many SOQL queries: 101',
1209+
'01:02:03.04 (22)|EXCEPTION_THROWN|[60]|System.LimitException: c2g:Too many SOQL queries: 101',
1210+
'01:02:03.04 (23)|METHOD_EXIT|[1]|a00000000000000|ns.MyClass.myMethod()',
1211+
'01:02:03.04 (24)|EXECUTION_FINISHED',
1212+
];
1213+
const log1 = logArray.join('\n');
1214+
1215+
const defaultCounts = {
1216+
dmlCount: { total: 0, self: 0 },
1217+
soqlCount: { total: 0, self: 0 },
1218+
soslCount: { total: 0, self: 0 },
1219+
dmlRowCount: { total: 0, self: 0 },
1220+
soqlRowCount: { total: 0, self: 0 },
1221+
soslRowCount: { total: 0, self: 0 },
1222+
totalThrownCount: 0,
1223+
};
1224+
1225+
const apexLog = parse(log1);
1226+
expect(apexLog).toMatchObject(
1227+
// EXECUTION_STARTED
1228+
{
1229+
duration: { total: 24, self: 0 },
1230+
dmlCount: { total: 2, self: 0 },
1231+
soqlCount: { total: 2, self: 0 },
1232+
soslCount: { total: 2, self: 0 },
1233+
dmlRowCount: { total: 5, self: 0 },
1234+
soqlRowCount: { total: 3, self: 0 },
1235+
soslRowCount: { total: 400, self: 0 },
1236+
type: null,
1237+
children: [
1238+
{
1239+
duration: { total: 24, self: 2 },
1240+
dmlCount: { total: 2, self: 0 },
1241+
soqlCount: { total: 2, self: 0 },
1242+
soslCount: { total: 2, self: 0 },
1243+
dmlRowCount: { total: 5, self: 0 },
1244+
soqlRowCount: { total: 3, self: 0 },
1245+
soslRowCount: { total: 400, self: 0 },
1246+
totalThrownCount: 3,
1247+
logLine: logArray[0],
1248+
children: [
1249+
// ns.MyClass.myMethod()
1250+
{
1251+
duration: { total: 22, self: 6 },
1252+
dmlCount: { total: 2, self: 0 },
1253+
soqlCount: { total: 2, self: 0 },
1254+
soslCount: { total: 2, self: 0 },
1255+
dmlRowCount: { total: 5, self: 0 },
1256+
soqlRowCount: { total: 3, self: 0 },
1257+
soslRowCount: { total: 400, self: 0 },
1258+
totalThrownCount: 3,
1259+
logLine: logArray[1],
1260+
children: [
1261+
// ns.MyClass.soql()
1262+
{
1263+
...defaultCounts,
1264+
duration: { total: 5, self: 3 },
1265+
logLine: logArray[2],
1266+
soqlCount: { total: 2, self: 0 },
1267+
soqlRowCount: { total: 3, self: 0 },
1268+
children: [
1269+
//SELECT ID FROM MyObject__c
1270+
{
1271+
...defaultCounts,
1272+
duration: { total: 1, self: 1 },
1273+
soqlCount: { total: 1, self: 1 },
1274+
soqlRowCount: { total: 1, self: 1 },
1275+
logLine: logArray[3],
1276+
},
1277+
// SELECT ID FROM MyObject__c
1278+
{
1279+
...defaultCounts,
1280+
duration: { total: 1, self: 1 },
1281+
soqlCount: { total: 1, self: 1 },
1282+
soqlRowCount: { total: 2, self: 2 },
1283+
logLine: logArray[5],
1284+
},
1285+
],
1286+
},
1287+
// ns.MyClass.dml()
1288+
{
1289+
...defaultCounts,
1290+
duration: { total: 5, self: 3 },
1291+
dmlCount: { total: 2, self: 0 },
1292+
dmlRowCount: { total: 5, self: 0 },
1293+
logLine: logArray[8],
1294+
children: [
1295+
{
1296+
...defaultCounts,
1297+
duration: { total: 1, self: 1 },
1298+
dmlCount: { total: 1, self: 1 },
1299+
dmlRowCount: { total: 1, self: 1 },
1300+
logLine: logArray[9],
1301+
},
1302+
{
1303+
...defaultCounts,
1304+
duration: { total: 1, self: 1 },
1305+
dmlCount: { total: 1, self: 1 },
1306+
dmlRowCount: { total: 4, self: 4 },
1307+
logLine: logArray[11],
1308+
},
1309+
],
1310+
},
1311+
//ns.MyClass.sosl()
1312+
{
1313+
...defaultCounts,
1314+
duration: { total: 6, self: 4 },
1315+
soslCount: { total: 2, self: 0 },
1316+
soslRowCount: { total: 400, self: 0 },
1317+
totalThrownCount: 1,
1318+
logLine: logArray[14],
1319+
children: [
1320+
{
1321+
...defaultCounts,
1322+
duration: { total: 1, self: 1 },
1323+
soslCount: { total: 1, self: 1 },
1324+
soslRowCount: { total: 250, self: 250 },
1325+
totalThrownCount: 0,
1326+
logLine: logArray[15],
1327+
},
1328+
{
1329+
...defaultCounts,
1330+
duration: { total: 1, self: 1 },
1331+
soslCount: { total: 1, self: 1 },
1332+
soslRowCount: { total: 150, self: 150 },
1333+
totalThrownCount: 0,
1334+
logLine: logArray[17],
1335+
},
1336+
// Exception
1337+
{
1338+
...defaultCounts,
1339+
totalThrownCount: 1,
1340+
},
1341+
],
1342+
},
1343+
// Exception
1344+
{
1345+
...defaultCounts,
1346+
totalThrownCount: 1,
1347+
},
1348+
// Exception
1349+
{
1350+
...defaultCounts,
1351+
totalThrownCount: 1,
1352+
},
1353+
],
1354+
},
1355+
],
1356+
},
1357+
],
1358+
},
1359+
);
1360+
});
1361+
});

log-viewer/modules/components/calltree-view/CalltreeView.ts

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ export class CalltreeView extends LitElement {
678678
},
679679
{
680680
title: 'DML Count',
681-
field: 'totalDmlCount',
681+
field: 'dmlCount.total',
682682
sorter: 'number',
683683
width: 60,
684684
hozAlign: 'right',
@@ -687,7 +687,7 @@ export class CalltreeView extends LitElement {
687687
},
688688
{
689689
title: 'SOQL Count',
690-
field: 'totalSoqlCount',
690+
field: 'soqlCount.total',
691691
sorter: 'number',
692692
width: 60,
693693
hozAlign: 'right',
@@ -704,8 +704,17 @@ export class CalltreeView extends LitElement {
704704
bottomCalc: 'max',
705705
},
706706
{
707-
title: 'Rows',
708-
field: 'rows',
707+
title: 'DML Rows',
708+
field: 'dmlRowCount.total',
709+
sorter: 'number',
710+
width: 60,
711+
hozAlign: 'right',
712+
headerHozAlign: 'right',
713+
bottomCalc: 'max',
714+
},
715+
{
716+
title: 'SOQL Rows',
717+
field: 'soqlRowCount.total',
709718
sorter: 'number',
710719
width: 60,
711720
hozAlign: 'right',
@@ -714,7 +723,7 @@ export class CalltreeView extends LitElement {
714723
},
715724
{
716725
title: 'Total Time (ms)',
717-
field: 'duration',
726+
field: 'duration.total',
718727
sorter: 'number',
719728
headerSortTristate: true,
720729
width: 150,
@@ -736,7 +745,7 @@ export class CalltreeView extends LitElement {
736745
},
737746
{
738747
title: 'Self Time (ms)',
739-
field: 'selfTime',
748+
field: 'duration.self',
740749
sorter: 'number',
741750
headerSortTristate: true,
742751
width: 150,
@@ -753,7 +762,10 @@ export class CalltreeView extends LitElement {
753762
},
754763
headerFilter: MinMaxEditor,
755764
headerFilterFunc: MinMaxFilter,
756-
headerFilterFuncParams: { columnName: 'selfTime', filterCache: selfTimeFilterCache },
765+
headerFilterFuncParams: {
766+
columnName: 'duration.self',
767+
filterCache: selfTimeFilterCache,
768+
},
757769
headerFilterLiveFilter: false,
758770
},
759771
],
@@ -829,16 +841,16 @@ export class CalltreeView extends LitElement {
829841
const children = node.children.length ? this._toCallTree(node.children) : null;
830842
results.push({
831843
id: node.timestamp + '-' + i,
844+
originalData: node,
845+
_children: children,
832846
text: node.text,
833847
namespace: node.namespace,
834-
duration: node.duration.total,
835-
selfTime: node.duration.self,
836-
_children: children,
837-
totalDmlCount: node.dmlCount.total,
838-
totalSoqlCount: node.soqlCount.total,
848+
duration: node.duration,
849+
dmlCount: node.dmlCount,
850+
soqlCount: node.soqlCount,
851+
dmlRowCount: node.dmlRowCount,
852+
soqlRowCount: node.soqlRowCount,
839853
totalThrownCount: node.totalThrownCount,
840-
rows: node.rowCount.total,
841-
originalData: node,
842854
});
843855
}
844856
return results;
@@ -888,17 +900,19 @@ export class CalltreeView extends LitElement {
888900
interface CalltreeRow {
889901
id: string;
890902
originalData: LogLine;
903+
_children: CalltreeRow[] | undefined | null;
891904
text: string;
892-
duration: number;
905+
duration: CountTotals;
893906
namespace: string;
894-
selfTime: number;
895-
_children: CalltreeRow[] | undefined | null;
896-
totalDmlCount: number;
897-
totalSoqlCount: number;
907+
dmlCount: CountTotals;
908+
soqlCount: CountTotals;
909+
dmlRowCount: CountTotals;
910+
soqlRowCount: CountTotals;
898911
totalThrownCount: number;
899-
rows: number;
900912
}
901913

914+
type CountTotals = { self: number; total: number };
915+
902916
export async function goToRow(timestamp: number) {
903917
document.dispatchEvent(
904918
new CustomEvent('calltree-go-to-row', { detail: { timestamp: timestamp } }),

log-viewer/modules/components/database-view/DMLView.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ export class DMLView extends LitElement {
256256
for (const dml of dmlLines) {
257257
dmlData.push({
258258
dml: dml.text,
259-
rowCount: dml.rowCount.self,
259+
rowCount: dml.dmlRowCount.self,
260260
timeTaken: dml.duration.total,
261261
timestamp: dml.timestamp,
262262
_children: [{ timestamp: dml.timestamp, isDetail: true }],

log-viewer/modules/components/database-view/DatabaseSection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class DatabaseSection extends LitElement {
3636
const totalCount = this.dbLines.length;
3737
let totalRows = 0;
3838
this.dbLines.forEach((value) => {
39-
totalRows += value.rowCount.self || 0;
39+
totalRows += value.dmlRowCount.self || value.soqlRowCount.self || 0;
4040
});
4141

4242
return html`

log-viewer/modules/components/database-view/SOQLView.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ export class SOQLView extends LitElement {
296296
relativeCost: explainLine?.relativeCost,
297297
soql: soql.text,
298298
namespace: soql.namespace,
299-
rowCount: soql.rowCount.self,
299+
rowCount: soql.soqlRowCount.self,
300300
timeTaken: soql.duration.total,
301301
aggregations: soql.aggregations,
302302
timestamp: soql.timestamp,

0 commit comments

Comments
 (0)