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
Uh oh!
There was an error while loading. Please reload this page.
-
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__cto 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__cpage, using PrismJSLogEntry__crecord.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__crecord 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__cwas generated, making it easy to know if the snippet on theLogEntry__cis 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__cFields 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__cthat are specific to each metadata type. For example:ApexClassName__candApexMethodName__cFlowActiveVersionId__cComponentApiName__candComponentFunctionName__cThese 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__cUI ChangesOverhauled the
LogEntry__cflexipageLogEntryRecordPageAs the number of fields on
LogEntry__chas grown, the complexity of theLogEntryRecordPagehas 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 (
FlexiPagemetadata) 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__cpage.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__cLighting Web Components (LWC)logEntryMetadataViewer- Added a new component built specifically for theLogEntry__cobject'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 LWCloggerPageSectionto provide collapsible page sections in theView Environment DetailsmodalloggerSettings- Updated to use the new helper LWCloggerPageSectionto provide collapsible page sections in theNew/Editsettings modallogViewer- Updated to use the new helper LWCloggerCodeViewerto display theLog__crecord's JSON dataNew
LogEntryEvent__ePlatform Event FieldsExceptionLocation__cExceptionSourceActionName__cExceptionSourceApiName__cExceptionSourceMetadataType__cOriginSourceActionName__cOriginSourceApiName__cOriginSourceMetadataType__cNew
LogEntry__cFieldsThe 3 permission sets
LoggerLogViewer, andLoggerEndUserhave 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__cExceptionSourceApiName__cExceptionSourceApiVersion__cExceptionSourceCreatedById__cExceptionSourceCreatedByLink__cExceptionSourceCreatedByUsername__cExceptionSourceCreatedDate__cExceptionSourceId__cExceptionSourceLastModifiedById__cExceptionSourceLastModifiedByLink__cExceptionSourceLastModifiedByUsername__cExceptionSourceLastModifiedDate__cExceptionSourceMetadataType__cExceptionSourceSnippet__cHasExceptionSourceSnippet__cOriginSourceActionName__cOriginSourceApiName__cOriginSourceApiVersion__cOriginSourceCreatedById__cOriginSourceCreatedByLink__cOriginSourceCreatedByUsername__cOriginSourceCreatedDate__cOriginSourceId__cOriginSourceLastModifiedById__cOriginSourceLastModifiedByLink__cOriginSourceLastModifiedByUsername__cOriginSourceLastModifiedDate__cOriginSourceMetadataType__cOriginSourceSnippet__cHasOriginSourceSnippet__cNew 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
LogEntryEventBuildernow usesLoggerStackTracefor Apex stack trace parsingComponentLoggernow usesLoggerStackTracefor JavaScript stack trace parsingLogManagementDataSelector- Updated methodgetApexClasses()to include theBodyfield when queryingApexClass- Added new methodgetApexTriggers()to queryApexTriggerdataLogEntryHandlerLoggerStackTraceto reconstitute a stack trace string into an instance ofLoggerStackTraceto help with generating Apex code snippetsprivateinner classSourceMetadataSnippetto query a snippet of theApexClassorApexTriggersource that generated theLogEntry__c, as well as a snippet of the source that generated theLogEntry__crecord's exception fields (ExceptionType__c,ExceptionMessage__c, andExceptionStackTrace__c)New
LoggerParameter__mdtRecordLoggerParameter__mdtrecordQueryApexTriggerData.true(default), theApexTriggerobject is queried to get additional details about your Apex triggersfalse, theApexTriggerwill not be queried - any relevant fields onLogEntry__cwill benullNew Static Resource
LoggerResourcesLoggerResources, 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 04t5Y000001MkE3QAKsfdx force:package:install --wait 20 --securitytype AdminsOnly --package 04t5Y000001MkE3QAKThis discussion was created from the release Apex Oberservability Enhancements.
Beta Was this translation helpful? Give feedback.
All reactions