Skip to content

Set value

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.

Example

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.

Warning

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.

Prerequisites

To use the plugin, make sure:

  • 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
  1. Go to the line of your source code at which you'd like to set a value.

  2. Right-click to open the context menu:

    Context Menu -half

  3. Hover over Metrics and then click Set Value.

  4. 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.

  5. In the right-side field, enter the assigned value. Valid values include any Java expression, including a method invocation.

  6. Use + to add additional variables.

  7. Click Ok to set the action.

Warning

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:

Plugin gutter -quarter

  1. Hover over the relevant icon to read summary information from its tooltip.

  2. Click the log icon or right-click any icon in the gutter to edit, delete and view details.

    Edit actions -quarter

View values

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
  1. Navigate to the Lightrun right-hand sidebar:

    Sidebar -quarter

  2. From the relevant agent, click Sidebar -icon to open the Piping menu:

    Log Piping -ten

  3. Set the Plugin or the Both option to view dynamic logs from the IDE.

Note

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.

{#view}

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

Once you configure piping for the plugin and add at least one action to the code, dynamic logs and metrics start updating in real time in the Lightrun Console at the bottom sidebar in IntelliJ:

Lightrun Console

  1. Use the filters at the top right of the Console data to filter for the dynamic logs relevant to your investigation.

  2. Use the search bar at the top left to start typing and search dynamically for dynamic logs by name.

  3. To free memory or remove items already viewed, click Clear.


Last update: May 5, 2021