A snapshot is a one-time "breakpoint" that doesn't block your code from running; as opposed to a traditional breakpoint, snapshots collect the stack trace and variables without interrupting the application at all.
Once you've added the snapshot, view the output directly from the IDE.
To use the plugin, make sure:
- You've attached at least one agent to your app.
- You install the plugin in your local IntelliJ instance).
- You authenticate IntelliJ with your Lightrun account.
- Make sure you have access to the server where the application with the agent is running.
- Be sure to open the source code file for the running application from the IDE.
To add a snapshot¶
Go to the line of your source code at which you'd like to insert the snapshot.
Right-click to open the context menu:
The Create Snapshot dialog opens:
Complete the fields in the dialog as follows:
bind the action to a specific agent or tag from the available options in this dropdown list
this is the source code file into which you're inserting the action; default is to the source code file from which you're already working
variables or method results to be displayed in the stack trace of the snapshot; click + to enter additional expressions
an expression that limits the action; this is the condition of an
ifstatement used to limit the execution of the action
myVar % 7 == 0limits the log so it only prints for variables that are divisible by 7
Click Advanced to configure the following additional fields:
Max Hit Count
the maximum number of times the snapshot should be taken during the lifetime of the action; default == 1.
the quota (rate limit) is configured in the agent configuration file. Ignore Quotas defaults to off. Only users assigned the
IGNORE-QUOTArole can perform this configuration; the checkbox is disabled for other users.
the time after which the action ceases to track code behavior and is automatically disabled; defaults to 1 hour
Click OK to add the log. A marker is also added to the area above the line:
The snapshot is added and displayed in the bottom sidebar:
An icon is added to the margins of the code on the line where it was added:
The Snapshot view is further detailed here
Right-click from the gutter marker to delete or edit the configuration.
Update, edit and delete actions¶
Once you've added an action, you can manipulate it by:
- viewing its details
- editing its configuration
- removing it
To work with exising actions¶
Once you create snapshot or metric, the relevant icon appears in the gutter of your code. When you enter a log, it is represented in line with your code. Icons for all of these options appear the similar to the following:
Hover over the relevant icon to read summary information from its tooltip.
Click the log icon or right-click any icon in the gutter to edit, delete and view details.
Data output is sent to your IDE, the CLI, the Lightrun Management Portal, or your integrated logging tools, depending on how you've configured piping.
By default, all output is piped to the Lightrun Management Portal. To view data from the IDE, you must configure the piping accordingly.
There are three levels of log piping:
- App - the dynamic logs appear only in the Lightrun Management Portal, as they do by default.
- Plugin - that dynamic logs won't appear in the Management Portal. Instead they appear in the Lightrun Console of your IDE, the CLI, or your integrated logging tools.
- Both - that dynamic logs will appear both in the Management Portal and in any integrations you're using.
To configure piping:
In the Lightrun plugin, navigate to the right-hand sidebar:
From the relevant agent, click to open the Piping menu:
To view dynamic logs from the IDE, set either the Plugin or the Both option.
Dynamic logs are sent from the agent to the plugin via the Lightrun management server. As this process is batched, dynamic logs may appear with a slight delay.
Snapshot data - view the stacktrace¶
Every time you add a snapshot to the code, it appears in the bottom sidebar of IntelliJ in the Lightrun Snapshots tab. The layout of the data that prints out is similar to the debugger interface, designed to be familiar to you.
Find these details in the Lightrun Snapshots view:
The name that was assigned to the snapshot when it was added appears at the top of the sidebar. The left column lists all of the stack trace frames from the relevant snapshot. Click the row of a specific frame to view the variables related to the exception that was thrown.