v4.13.1 - Apex Observability Enhancements #642
jongpie
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This release is a big one - and so is the description, to try to cover all of the changes.
Overview
This introduces some very powerful enhancements to improve the observability of Apex code, making it easier for Salesforce experts to answer questions like "what happened in my Apex code?" and "what did my Apex code look like?". It also takes some big steps towards streamlining the fields on
LogEntry__c
to simplify reporting, and shifting towards using custom LWCs to provide an improved user experience for viewing logging data.Source Snippets
Nebula Logger now automatically logs a snippet of your Apex code, providing a snapshot of the relevant codeblock. These snippets are displayed in a very fancy code-viewer on the
LogEntry__c
page, using PrismJSLogEntry__c
record.For example, if you deploy the example Apex class below:
Example Class with Logging
...if you then run and run
new ExampleClassWithLogging().doSomething();
, Nebula Logger will generate a newLogEntry__c
record with 2 code snippets - one snippet for the origin of the entry, and another snippet for the included exception.In each snippet, you can see about 12 lines of source code that executed - the relevant line of code is automatically highlighted.
You can also click the 'View Full Source' button to see the entire Apex class or trigger that is currently deployed to the org. The modal even indicates if the source code has been modified since the
LogEntry__c
was generated, making it easy to know if the snippet on theLogEntry__c
is still accurate.Streamlined Reporting with New Origin & Exception Source Fields
Nebula Logger supports logging in 5 (5-ish) metadata types:
This release tries to provide a more consistent set of fields to use for reporting, regardless of which metadata type is using Nebula Logger.
Current State:
LogEntry__c
Fields Are Not Very ScalableOriginally when Nebula Logger was first created, Apex classes were the only focus - as new metadata types have been added over the years, new fields have also been added
LogEntry__c
that are specific to each metadata type. For example:ApexClassName__c
andApexMethodName__c
FlowActiveVersionId__c
ComponentApiName__c
andComponentFunctionName__c
These approach has led to 2 challenges:
LogEntry__c
.These challenges have created a cycle of new challenges & issues:
ApexClassName__c
,FlowActiveVersionId__c
,ComponentApiName__c
, etc) are only for the log entry's origin (i.e., the metadata the generated the log entry). Due to concerns with field limits, there are not equivalent fields for exception details - arguably, it's more important to capture granular details about exceptions (instead of the origin), but the origin fields came first, and exception fields have never been added, which is a big gap in actionable data.Future State: Scalable Exception & Origin Fields
To streamline things, this release introduces 2 sets of fields.
Each set of fields consists of ~16 fields (about 16 Origin fields, and about 16 Exception fields). These fields are intended to work for all supported metadata types, which helps to simplify reporting, list views, etc.
The older, metadata-specific fields (like
ApexClassName__c
,FlowActiveVersionId__c
,ComponentApiName__c
, etc) will continue to be populated & supported for now, though it is likely that they will eventually be deprecated in the future.LogEntry__c
UI ChangesOverhauled the
LogEntry__c
flexipageLogEntryRecordPage
As the number of fields on
LogEntry__c
has grown, the complexity of theLogEntryRecordPage
has also grown. This releases adds more tabs to the page's horizontal tab set.Shifting To Custom LWCs for Nebula Logger's Record Pages
Nebula Logger heavily utilizies App Builder record pages (
FlexiPage
metadata) for displaying data inLog__c
,LogEntry__c
, etc - including heavy use of dynamic forms, conditional visibility, and some of the other amazing declarative features. However, there are several new & existing features that would benefit from custom UIs, and this release is the first step in adding new components that will improve the usefulness of theLogEntry__c
page.In particular, this release introduces a few new components, used to display Apex snippets with PrismJS. Other new components will be introduced over the coming months.
Core Unlocked Package Changes
New
LogEntry__c
Lighting Web Components (LWC)logEntryMetadataViewer
- Added a new component built specifically for theLogEntry__c
object's record page. This LWCNew Helper Lighting Web Components (LWCs)
loggerCodeViewer
- Added a new helper UI component that uses Prism JS to provide some very nice syntax highlighting & line numbers for displaying blocks of JSON and Apex codeloggerPageSection
- Added a new helper UI component that provides a reusable way of implementing the lightning design system's "expandable section" component bluprint to mimic the functionality that the platform uses for native page layout sectionsUpdated Lighting Web Components (LWCs)
loggerHomeHeader
- Updated to use the new helper LWCloggerPageSection
to provide collapsible page sections in theView Environment Details
modalloggerSettings
- Updated to use the new helper LWCloggerPageSection
to provide collapsible page sections in theNew
/Edit
settings modallogViewer
- Updated to use the new helper LWCloggerCodeViewer
to display theLog__c
record's JSON dataNew
LogEntryEvent__e
Platform Event FieldsExceptionLocation__c
ExceptionSourceActionName__c
ExceptionSourceApiName__c
ExceptionSourceMetadataType__c
OriginSourceActionName__c
OriginSourceApiName__c
OriginSourceMetadataType__c
New
LogEntry__c
FieldsThe 3 permission sets
LoggerLogViewer
, andLoggerEndUser
have been updated to have the relevant access to these new fieldsExceptionLocation__c
- this also includes a custom index, and is equivalent to the existing fieldOriginLocation__c
.ExceptionSourceActionName__c
ExceptionSourceApiName__c
ExceptionSourceApiVersion__c
ExceptionSourceCreatedById__c
ExceptionSourceCreatedByLink__c
ExceptionSourceCreatedByUsername__c
ExceptionSourceCreatedDate__c
ExceptionSourceId__c
ExceptionSourceLastModifiedById__c
ExceptionSourceLastModifiedByLink__c
ExceptionSourceLastModifiedByUsername__c
ExceptionSourceLastModifiedDate__c
ExceptionSourceMetadataType__c
ExceptionSourceSnippet__c
HasExceptionSourceSnippet__c
OriginSourceActionName__c
OriginSourceApiName__c
OriginSourceApiVersion__c
OriginSourceCreatedById__c
OriginSourceCreatedByLink__c
OriginSourceCreatedByUsername__c
OriginSourceCreatedDate__c
OriginSourceId__c
OriginSourceLastModifiedById__c
OriginSourceLastModifiedByLink__c
OriginSourceLastModifiedByUsername__c
OriginSourceLastModifiedDate__c
OriginSourceMetadataType__c
OriginSourceSnippet__c
HasOriginSourceSnippet__c
New Apex Classes
LoggerStackTrace
- this new class centralizes stack trace parsing for Apex & JavaScript stack traces, and makes it easy to reuse this logic for both the backend & frontendLogEntryMetadataViewerController
- this is a new controller class for the new LWClogEntryMetadataViewer
, used to see code snippets for Apex classes & triggersUpdated Apex Classes
LogEntryEventBuilder
now usesLoggerStackTrace
for Apex stack trace parsingComponentLogger
now usesLoggerStackTrace
for JavaScript stack trace parsingLogManagementDataSelector
- Updated methodgetApexClasses()
to include theBody
field when queryingApexClass
- Added new methodgetApexTriggers()
to queryApexTrigger
dataLogEntryHandler
LoggerStackTrace
to reconstitute a stack trace string into an instance ofLoggerStackTrace
to help with generating Apex code snippetsprivate
inner classSourceMetadataSnippet
to query a snippet of theApexClass
orApexTrigger
source that generated theLogEntry__c
, as well as a snippet of the source that generated theLogEntry__c
record's exception fields (ExceptionType__c
,ExceptionMessage__c
, andExceptionStackTrace__c
)New
LoggerParameter__mdt
RecordLoggerParameter__mdt
recordQueryApexTriggerData
.true
(default), theApexTrigger
object is queried to get additional details about your Apex triggersfalse
, theApexTrigger
will not be queried - any relevant fields onLogEntry__c
will benull
New Static Resource
LoggerResources
LoggerResources
, that contains the JS & CSS files for PrismJS. If/when other files are needed in future releases, they'll be included in this same static resource.Installation Info
Core Unlocked Package - no namespace
Full Changelog: v4.13.0...v4.13.1
sf package install --wait 20 --security-type AdminsOnly --package 04t5Y000001MkE3QAK
sfdx force:package:install --wait 20 --securitytype AdminsOnly --package 04t5Y000001MkE3QAK
This discussion was created from the release Apex Oberservability Enhancements.
Beta Was this translation helpful? Give feedback.
All reactions