-
-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apex Observability Enhancements (#636)
* Added new Apex class LoggerStackTrace to manage stack trace parsing for Apex & JavaScript. This includes updating several classes to use LoggerStackTrace (instead of the old parsing logic that was scattered throughout the codebase). * Added new LogEntryEvent__e & LogEntry__c fields to track more stack trace-related data * Added more fields to the existing ApexClass query in the instance method LogManagementDataSelector.getApexClasses() * Updated the instance method LogManagementDataSelector.getApexClasses()to use Set<String> instead of List<String> as the parameter * Added new instance method LogManagementDataSelector.getApexTriggers() & LoggerParameter__mdt record to control querying of ApexTrigger data * Updated LogEntryHandler to generate & store snippets of ApexClass & ApexTrigger code for each log entry's origin & exception (when supplied) * Updated LogEntryHandler to set the new 'origin source' fields for Flow (where possible). The FlowDefinitionView and FlowVersionView objects don't have some of the typical audit fields for created by/date and last modified by, so not all 'origin source' fields are consistently set for Flows * Created new LWC logEntryMetadataViewer to display origin & exception snippets for Apex classes & triggers. This also includes 2 new helper LWCs - loggerCodeViewer & loggerPageSection - and a new static resource LoggerResources, containing PrismJS for formatting code blocks * Updated LWCs loggerHomeHeader and loggerSettings to use loggerPageSection * Updated LWC logViewer to use loggerCodeViewer * Performance improvements - cache network/organization/auth session/user usages in LogEntryEventBuilder * Fixed a testing issue where some tests were passing for the wrong reason due to a bug in LoggerMockDataCreator. Previously, it generated the same string value for every string field, resulting in an inaccurate assert in LogEntryEventHandler_Tests passing, even though the field mapping was wrong in the prod code. Now, the generated string starts with the field's API name, which should at least greatly reduce this issue (though with truncation, etc, there's still a chance it could happen again... good enough, for now) * Fixed .prettierrc for cls and xml files and re-formatted several files * Updated to new version of bummer plugin v0.0.20 to fix some issues with additional properties being unintentionally added to sfdx-project.json * Made some changes to some sample Apex classes for demo purposes
- Loading branch information
Showing
119 changed files
with
7,725 additions
and
2,905 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ yarn.lock | |
# Files to exclude | ||
*.log | ||
**/lwc/jsconfig.json | ||
.config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
docs/apex/Log-Management/LogEntryMetadataViewerController.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
layout: default | ||
--- | ||
|
||
## LogEntryMetadataViewerController class | ||
|
||
Controller class for the LWC `logEntryMetadataViewer` | ||
|
||
--- | ||
|
||
### Methods | ||
|
||
#### `getMetadata(Id recordId, String sourceMetadata)` → `LogEntryMetadata` | ||
|
||
Returns an instance of the inner class `LogEntryMetadataViewerController.LogEntryMetadata`, which contains information about the log entry's origin and exception Apex classes | ||
|
||
##### Parameters | ||
|
||
| Param | Description | | ||
| ---------------- | ---------------------------------------- | | ||
| `recordId` | The `ID` of the `LogEntry__c` record | | ||
| `sourceMetadata` | Either the value `Origin` or `Exception` | | ||
|
||
##### Return | ||
|
||
**Type** | ||
|
||
LogEntryMetadata | ||
|
||
**Description** | ||
|
||
An instance of `LogEntryMetadataViewerController.LogEntryMetadata` | ||
|
||
--- | ||
|
||
### Inner Classes | ||
|
||
#### LogEntryMetadataViewerController.LogEntryMetadata class | ||
|
||
--- | ||
|
||
##### Properties | ||
|
||
###### `Code` → `String` | ||
|
||
###### `HasCodeBeenModified` → `Boolean` | ||
|
||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
--- | ||
layout: default | ||
--- | ||
|
||
## LoggerStackTrace class | ||
|
||
Class used for tracking & parsing stack traces | ||
|
||
### Related | ||
|
||
[Logger](Logger) | ||
|
||
LogEntryBuilder | ||
|
||
--- | ||
|
||
### Constructors | ||
|
||
#### `LoggerStackTrace()` | ||
|
||
Constructor that automatically generates & parses stack trace information based on the calling code | ||
|
||
#### `LoggerStackTrace(Exception apexException)` | ||
|
||
Constructor that parses stack trace information from the provided `Exception` | ||
|
||
##### Parameters | ||
|
||
| Param | Description | | ||
| --------------- | ------------------------------------ | | ||
| `apexException` | An instance of any `Exception` class | | ||
|
||
#### `LoggerStackTrace(String apexStackTraceString)` | ||
|
||
Constructor that parses stack trace information from the provided `String` | ||
|
||
##### Parameters | ||
|
||
| Param | Description | | ||
| ---------------------- | -------------------------------------------------------- | | ||
| `apexStackTraceString` | The original stack trace value generated by the platform | | ||
|
||
#### `LoggerStackTrace(SourceLanguage language, String sourceStackTraceString)` | ||
|
||
--- | ||
|
||
### Enums | ||
|
||
#### SourceLanguage | ||
|
||
#### SourceMetadataType | ||
|
||
--- | ||
|
||
### Properties | ||
|
||
#### `Language` → `Source` | ||
|
||
#### `Location` → `String` | ||
|
||
#### `ParsedStackTraceString` → `String` | ||
|
||
#### `Source` → `public` | ||
|
||
--- | ||
|
||
### Methods | ||
|
||
#### `AnonymousBlock()` → `public` | ||
|
||
#### `ApexClass()` → `public` | ||
|
||
#### `ApexTrigger()` → `public` | ||
|
||
#### `AuraDefinitionBundle()` → `public` | ||
|
||
#### `LightningComponentBundle()` → `public` | ||
|
||
#### `ignoreOrigin(System.Type apexType)` → `void` | ||
|
||
Adds the specified Apex type to the the current transaction's list of ignored origin locations. Any ignored types will be removed from the StackTrace\_\_c field, and will be skipped when determining the log entry's origin location | ||
|
||
##### Parameters | ||
|
||
| Param | Description | | ||
| ---------- | ------------------------------------ | | ||
| `apexType` | The Apex type of the class to ignore | | ||
|
||
#### `ignoreOrigin(SourceLanguage language, String origin)` → `void` | ||
|
||
Adds the specified string-based origin to the the current transaction's list of ignored origin locations for the specified source language. Any ignored types will be removed from the StackTrace\_\_c field, and will be skipped when determining the log entry's origin location | ||
|
||
##### Parameters | ||
|
||
| Param | Description | | ||
| ---------- | ---------------------------------------------------------------------------- | | ||
| `language` | The source language (Apex or JavaScript) | | ||
| `origin` | The string-based name of the Apex type or lightning component name to ignore | | ||
|
||
#### `ignoreOrigins(Set<System.Type> apexTypes)` → `void` | ||
|
||
Adds the specified Apex types to the list of ignored origin locations for the current transaction. Any ignored types will be removed from the StackTrace\_\_c field, and will be skipped when determining the log entry's origin location | ||
|
||
##### Parameters | ||
|
||
| Param | Description | | ||
| ----------- | ---------------------------------------------------------- | | ||
| `apexTypes` | A `Set` containing the Apex types of the classes to ignore | | ||
|
||
--- | ||
|
||
### Inner Classes | ||
|
||
#### LoggerStackTrace.SourceMetadata class | ||
|
||
--- | ||
|
||
##### Properties | ||
|
||
###### `ActionName` → `String` | ||
|
||
###### `ApiName` → `String` | ||
|
||
###### `LineNumber` → `Integer` | ||
|
||
###### `MetadataType` → `Source` | ||
|
||
--- |
Oops, something went wrong.