/debug-log-analyzer

Visual Studio Code extension to aid with Salesforce Apex debug log analysis - Visualize code execution via a Flame chart and identify performance and SOQL/DML problems via Method and Database analysis https://marketplace.visualstudio.com/items?itemName=financialforce.lana

Primary LanguageTypeScriptBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

Apex Log Analyzer for Salesforce

Version Download Installs Ratings

Apex Log Analyzer makes performance analysis of Salesforce debug logs much easier and quicker. It provides visualization of code execution via a Flame chart and Calltree and helps identify performance and SOQL/DML problems via Method and Database Analysis.

preview

WARNING

In general set the APEX_CODE debug flag to be FINE or higher, with a lower level the log will likely not contain enough detail for meaningful analysis.

The quality of data shown depends entirely on the data contained in the log files.
Special care should be taken when looking at log files that have been truncated as you are only seeing a part of the execution and that may lead you to misunderstand what is really happening.

A log level of FINE seems to give a good balance between log detail and execution time.
Higher log levels result in higher reported execution time than would be seen with logging off.
This is due to the over head associated with logging method entry and exit.

Installation

install

  • Search for Apex Log Analyzer in extensions.
  • Click install + then reload VSCode.

Command Pallette

  • Open command pallette (CMD/CTRL + Shift + P), paste ext install financialforce.lana, and press enter.
  • Click reload in the extensions tab.
ext install financialforce.lana

VSCode Marketplace

Usage

Start the analysis either from a log you have already downloaded or by downloading a log from an org to view. On larger logs the analysis window make take a few seconds to appear.

From an Open Log File

With the .log file open in VSCode.

  1. Open command pallette (CMD/CTRL + Shift + P) -> 'Log: Show Apex Log Analysis'
    or
  2. Click the 'Log: Show Apex Log Analysis' code lens at the top of the file
    show analysis lens
    or
  3. Right click -> 'Log: Show Apex Log Analysis'

Download a log

  1. Open command pallette (CMD/CTRL + Shift + P) -> 'Log: Retrieve Apex Log And Show Analysis

Features

Timeline / Flame chart

timeline

The Timeline shows a visualization of code execution during a request’s execution. Each color represents a different Salesforce event type e.g DB, Method, SOQL etc. The length of a bar relates to realtime taken e.g a longer bar means that method took longer.

  • Scroll up and down on the mouse to zoom in and out to an accuracy of 0.001ms, time markers are shown with a ms time value and white line e.g 9600.001 ms.
  • When zooming the mouse pointer position is kept on screen.
  • Scroll left and right on the mouse to move the time line left are right, when zoomed
  • Click the mouse down and drag to move the timeline around both in the x and y direction, when zoomed

tooltip

Hovering over an element provides information on the item. If you click on an item it will take you to the call navigatable stack view.

The tooltip provides the following information.
Event Name e.g METHOD_ENTRY, EXECUTION_STARTED, SOQL_EXECUTION_BEGIN etc
Event Description Addtional information about the event such as method name or SOQL query executed.
Timestamp is the start and end timestamp for the given event which can crossreferenced in the log file.
Duration is made up of Total Time and Self Time.
Self Time represents the time directly spent in that event.
Total Time represents the time spent in that event or any of its children.

Color settings

The default colors shown on the timeline can be changed in the VSCode settings.
Either in the UI preferences -> extensions -> Apex Log Analyzer

color settings

or

settings.json

"lana.timeline.colors": {
  "Code Unit": "#88AE58",
  "Workflow": "#51A16E",
  "Method": "#2B8F81",
  "Flow": "#337986",
  "DML": "#285663",
  "SOQL": "#5D4963",
  "System Method": "#5C3444"
}

Calltree

calltree

Shows the call stack which can be expanded and collapsed. Clicking on a link will take you to that line in the class if it can be found in the current open project.

Each row shows event type, details such as method signature, self and total time as well as line number.

Analysis

analysis

Show analysis on method calls. The table can be sorted ascending or descending by Self Time, Total Time, Count (number of times a method was called) and name.

Database

database

Shows the SOQL and DML that occured the number of rows returned, the time taken and for SOQL the selectivity and number of aggregations. Clicking a row will show the SOQL/DML call stack, clicking on a link will take you to where that SOQL/DML occured in the call tree. The tables can be sorted ascending or descending by DML/SOQL, Row Count and Time Taken and by Selectivity and Aggregations on the SOQL table.

The Selectivity column will have a green tick if the query is selective, a red cross if it is not and will be blank if the selectivity could not be determine. Sorting on this column will sort the rows by relative query cost, this number can be seen by hovering the cell on the selectivity column.

By default rows are grouped by the SOQL/ DML text, grouping can be removed and the rows shows as a flat list using the Group by item in the header menu.

Contributing

Help us to make things better by Contributing
Find out how to Build the extension

Contributors ❤ 🙏

Thanks to the everyone who has contributed


Copyright © Certinia Inc. All rights reserved.