One trick in debugging is to set a variable to a different value, thereby forcing a specific code path. This can be particularly useful when patching broken behavior.
If a feature fails and it's surrounded by an
if statement, you might be able to disable that feature by forcing the value of a variable.
This is an extremely risky action, and as such only users with the
ROLE_SET_VALUE role can execute it.
Once you've added the value, view the outuput 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 set value action¶
Go to the line of your source code at which you'd like to set a value.
Right-click to open the context menu:
Hover over Metrics and then click Set Value.
Enter the relevant variable name for the left-side argument. The left hand side must be a variable in context and cannot be a method.
In the right-side field, enter the assigned value. Valid values include any Java expression, including a method invocation.
+to add additional variables.
Click Ok to set the action.
Quotas aren't imposed on set-value operations and as such the performance impact can be significant.
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 web interface, or your integrated logging tools depending on how you've configured piping.
By default, all output is piped to the web interface in the web interface. To view data from the IDE, you must first configure the piping accordingly.
There are three levels of log piping:
- App - the dynamic logs appear only in the Lightrun web interface, as they do by default.
- Plugin - that dynamic logs won't appear in the web interface. Instead they appear in the Lightrun Console of your IDE, the CLI, or your integrated logging tools.
- Both - that dynamic logs wll appear both in the web interface and in any integrations you're using.
To configure piping¶
Navigate to the Lightrun right-hand sidebar:
From the relevant agent, click to open the Piping menu:
Set the Plugin or the Both option to view dynamic logs from the IDE.
In order to pipe the dynamic logs they need to go from the agent to the Management server and to the plugin. This process is batched so dynamic logs appear in batches and with some delay.
Lightrun dynamic logs and metrics are normally printed into the standard logging framework. This is quite valuable as dynamic logs can be seen in the context of pre-existing log statements, which might provide further clues towards solving issues.
At the same time, a developer might want to see the log output and search and filter directly from the IDE as they work. To do this, first configure log piping per-agent. Once configured, all relevant information from any Lightrun actions that are added to the agents appears in the developers' consoles.
To view log data from IntelliJ¶
Use the filters at the top right of the Console data to filter for the dynamic logs relevant to your investigation.
Use the search bar at the top left to start typing and search dynamically for dynamic logs by name.
To free memory or remove items already viewed, click Clear.