Skip to content

Commit b34b2c0

Browse files
authored
Made LogBatchPurger's batch size configurable (#880)
* Added the ability to configure the default batch size in LogBatchPurger, using the new LoggerParameter__mdt record LogBatchPurgerDefaultBatchSize
1 parent 4fbfaa8 commit b34b2c0

File tree

17 files changed

+100
-18
lines changed

17 files changed

+100
-18
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
The most robust observability solution for Salesforce experts. Built 100% natively on the platform, and designed to work seamlessly with Apex, Lightning Components, Flow, OmniStudio, and integrations.
77

8-
## Unlocked Package - v4.16.2
8+
## Unlocked Package - v4.16.3
99

10-
[![Install Unlocked Package in a Sandbox](./images/btn-install-unlocked-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04tKe0000011Mi9IAE)
11-
[![Install Unlocked Package in Production](./images/btn-install-unlocked-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04tKe0000011Mi9IAE)
10+
[![Install Unlocked Package in a Sandbox](./images/btn-install-unlocked-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04tKe0000011Mr1IAE)
11+
[![Install Unlocked Package in Production](./images/btn-install-unlocked-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04tKe0000011Mr1IAE)
1212
[![View Documentation](./images/btn-view-documentation.png)](https://github.com/jongpie/NebulaLogger/wiki)
1313

14-
`sf package install --wait 20 --security-type AdminsOnly --package 04tKe0000011Mi9IAE`
14+
`sf package install --wait 20 --security-type AdminsOnly --package 04tKe0000011Mr1IAE`
1515

1616
---
1717

docs/apex/Configuration/LoggerParameter.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ Indicates if Nebula Logger will append its own log entries about the logging sys
3434

3535
Indicates if Nebula Logger's tagging system is enabled. Controlled by the custom metadata record `LoggerParameter.EnableTagging`, or `true` as the default
3636

37+
#### `LOG_BATCH_PURGER_DEFAULT_BATCH_SIZE``Integer`
38+
39+
Controls the default batch size used by the batchable class `LogBatchPurger` when purging old logging data. Controlled by the custom metadata record `LoggerParameter.LogBatchPurgerDefaultBatchSize`, or `500` as the default
40+
3741
#### `NORMALIZE_SCENARIO_DATA``Boolean`
3842

3943
Indicates if Nebula Logger will store scenarios in the custom object `LoggerScenario__c`, or in the fields `Log__c.TransactionScenarioName__c` & `LogEntry__c.EntryScenario__c`. Controlled by the custom metadata record `LoggerParameter.NormalizeScenarioData`, or `true` as the default

docs/apex/Log-Management/LogBatchPurgeController.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ The instance of `List<PicklistOption>`, containing all picklist options fo
7474

7575
#### `runBatchPurge()``String`
7676

77-
execute the logBatchPurger batch with batch size 2000
77+
Executes the LogBatchPurger batch job with the default batch size
7878

7979
##### Return
8080

docs/apex/Log-Management/LogBatchPurger.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Integer
6464

6565
**Description**
6666

67-
The default `Integer` value of `2000`
67+
The `Integer` value configured in the custom metadata record `LoggerParameter.LogBatchPurgerDefaultBatchSize`, or `500` as the default
6868

6969
#### `setChainedBatchSize(Integer chainedBatchSize)``LogBatchPurger`
7070

docs/apex/Logger-Engine/LogEntryEventBuilder.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ Used by `Logger` to instantiate a new instance of `LogEntryEventBuilder`
5252

5353
#### `heapSizeMax``Integer`
5454

55+
#### `isDataMaskingEnabled``Boolean`
56+
5557
#### `mobilePushApexCallsMax``Integer`
5658

5759
#### `publishImmediateDmlStatementsMax``Integer`
@@ -66,10 +68,20 @@ Used by `Logger` to instantiate a new instance of `LogEntryEventBuilder`
6668

6769
#### `soslSearchesMax``Integer`
6870

71+
#### `textField``Schema.SObjectField`
72+
73+
#### `textValue``String`
74+
75+
#### `wasMasked``Boolean`
76+
77+
#### `wasTruncated``Boolean`
78+
6979
---
7080

7181
### Methods
7282

83+
#### `TextFieldValueCleaner(LoggerSettings__c settings, Schema.SObjectField textField, String originalTextValue)``public`
84+
7385
#### `addTag(String tag)``LogEntryEventBuilder`
7486

7587
Appends the tag to the existing list of tags

nebula-logger/core.package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,7 @@
725725
<members>LoggerParameter.EnableLoggerSystemMessages</members>
726726
<members>LoggerParameter.EnableStackTraceParsing</members>
727727
<members>LoggerParameter.EnableTagging</members>
728+
<members>LoggerParameter.LogBatchPurgerDefaultBatchSize</members>
728729
<members>LoggerParameter.LogEntryEventStreamDisplayFields</members>
729730
<members>LoggerParameter.NormalizeScenarioData</members>
730731
<members>LoggerParameter.NormalizeTagData</members>

nebula-logger/core/main/configuration/classes/LoggerParameter.cls

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,20 @@ public class LoggerParameter {
102102
private set;
103103
}
104104

105+
/**
106+
* @description Controls the default batch size used by the batchable class `LogBatchPurger` when purging old logging data.
107+
* Controlled by the custom metadata record `LoggerParameter.LogBatchPurgerDefaultBatchSize`, or `500` as the default
108+
*/
109+
public static final Integer LOG_BATCH_PURGER_DEFAULT_BATCH_SIZE {
110+
get {
111+
if (LOG_BATCH_PURGER_DEFAULT_BATCH_SIZE == null) {
112+
LOG_BATCH_PURGER_DEFAULT_BATCH_SIZE = getInteger('LogBatchPurgerDefaultBatchSize', 500);
113+
}
114+
return LOG_BATCH_PURGER_DEFAULT_BATCH_SIZE;
115+
}
116+
private set;
117+
}
118+
105119
/**
106120
* @description Indicates if Nebula Logger will store scenarios in the custom object `LoggerScenario__c`,
107121
* or in the fields `Log__c.TransactionScenarioName__c` & `LogEntry__c.EntryScenario__c`.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<CustomMetadata xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
3+
<label>Log Batch Purger: Default Batch Size</label>
4+
<protected>false</protected>
5+
<values>
6+
<field>Comments__c</field>
7+
<value xsi:nil="true"/>
8+
</values>
9+
<values>
10+
<field>Description__c</field>
11+
<value xsi:type="xsd:string">The integer value used to control the default batch size used by the batchable class LogBatchPurger (default is 500).</value>
12+
</values>
13+
<values>
14+
<field>Value__c</field>
15+
<value xsi:type="xsd:string">500</value>
16+
</values>
17+
</CustomMetadata>

nebula-logger/core/main/log-management/classes/LogBatchPurgeController.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public with sharing class LogBatchPurgeController {
8888
}
8989

9090
/**
91-
* @description execute the logBatchPurger batch with batch size 2000
91+
* @description Executes the LogBatchPurger batch job with the default batch size
9292
* @return Returns the ID of the Schema.AsyncApexJob object associated with the LogBatchPurger job as a string
9393
*/
9494
@AuraEnabled

nebula-logger/core/main/log-management/classes/LogBatchPurger.cls

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
*/
1111
@SuppressWarnings('PMD.AvoidGlobalModifier, PMD.CognitiveComplexity, PMD.CyclomaticComplexity, PMD.ExcessiveParameterList')
1212
global with sharing class LogBatchPurger implements Database.Batchable<SObject>, Database.Stateful {
13-
private static final Integer DEFAULT_BATCH_SIZE = 2000;
1413
private static final Date LOG_RETENTION_END_DATE = System.today();
1514
@TestVisible
1615
private static final String NO_DELETE_ACCESS_EXCEPTION_MESSAGE = 'User does not have access to delete logs';
@@ -36,10 +35,10 @@ global with sharing class LogBatchPurger implements Database.Batchable<SObject>,
3635

3736
/**
3837
* @description Returns the default batch size used when running `LogBatchPurger`
39-
* @return The default `Integer` value of `2000`
38+
* @return The `Integer` value configured in the custom metadata record `LoggerParameter.LogBatchPurgerDefaultBatchSize`, or `500` as the default
4039
*/
4140
public static Integer getDefaultBatchSize() {
42-
return DEFAULT_BATCH_SIZE;
41+
return LoggerParameter.LOG_BATCH_PURGER_DEFAULT_BATCH_SIZE;
4342
}
4443

4544
/**

0 commit comments

Comments
 (0)