New Method Logger.setAsyncContext()
This release introduces a new method & fields to further help with monitoring & troubleshooting of async jobs, using the platform-provided async context interfaces:
The new features in this release can be used either in place of, or in addition to, Nebula Logger's existing method, Logger.setParentTransactionId()
, to help with identifying logs from related asynchronous transactions.
Core Unlocked Package Changes
New Method Logger.setAsyncContext()
- Added new
global
methodLogger.setAsyncContext()
. There are 4 overloads - 1 for each of the platform-provided interfaces:void setAsyncContext(Database.BatchableContext batchableContext) {} void setAsyncContext(System.FinalizerContext finalizerContext) {} void setAsyncContext(System.QueueableContext queueableContext) {} void setAsyncContext(System.SchedulableContext schedulableContext) {}
New Fields on LogEntryEvent__e
and Log__c
- Added new fields on
LogEntryEvent__e
andLog__c
that are set by usingLogger.setAsyncContext()
New Fields Description LogEntryEvent__e.AsyncContextType__c
andLog__c.AsyncContextType__c
The interface of the platform-provided context. Current values are Database.BatchableContext
,System.FinalizerContext
,System.QueueableContext
, andSystem.SchedulableContext
.LogEntryEvent__e.AsyncContextParentJobId__c
andLog__c.AsyncContextParentJobId__c
The ID of the parent job ( Schema.AsyncApexJob
) that initiated the async transaction. Used forDatabase.Batchable
,System.FinalizerContext
, andSystem.QueueableContext
.LogEntryEvent__e.AsyncContextChildJobId__c
andLog__c.AsyncContextChildJobId__c
The ID of the child job ( Schema.AsyncApexJob
) that initiated the async transaction. Used forDatabase.Batchable
.LogEntryEvent__e.AsyncContextTriggerId__c
andLog__c.AsyncContextTriggerId__c
The ID of the cron trigger ( Schema.CronTrigger
) that initiated the async transaction. - Updated FlexiPage
LogRecordPage
to conditionally show a new page section, "Async Context Details", which also conditionally shows the 4 new fields, shown in the screenshot below (in the red box)
- Updated several async classes (including
LogBatchPurger
andLogBatchPurgeScheduler
) to leverage the new methodLogger.setAsyncContext()
Internal Code Cleanup
- Eliminated the helper method
LoggerMockDataCreator.createBatchableContext()
- the underlying mock batchable context class, as well as some new similar mocks forFinalizer
,Queueable, and
Schedulable`, are now public and can be instantiated directly- Having the extra static methods was adding a lot of unnecessary complication & redundant code to expose static methods for each constructor
Pipeline Changes
- Upgraded
sf
cli (again) to try to resolve some packaging issues in the pipeline (again) - Updated
build.yml
to outputsf version
to help with troubleshooting any future pipeline issues
Installation Info
Core Unlocked Package - no namespace
Full Changelog: v4.11.5...v4.11.6
- SF CLI:
sf package install --wait 20 --security-type AdminsOnly --package 04t5Y000001HZfGQAW
- SFDX CLI:
sfdx force:package:install --wait 20 --securitytype AdminsOnly --package 04t5Y000001HZfGQAW
- Sandbox: https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y000001HZfGQAW
- Production: https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y000001HZfGQAW