Instrumenting code running in CLI
Last updated
Last updated
When running Java applications using a Run Configuration in the IDE, Digma detects that the code is being executed and automatically adds the necessary variables to instrument the process and send data to Digma. However, If you're running your code via a command line interface and outside the IDE, the Digma plugin is unaware that this is happening and cannot apply this configuration.
Thankfully, you can set everything up before you run your code by running a simple script.
To ensure data is sent to your Digma deployment (locally or centrally) when running your application from a Bash CLI, simply source
the following script:
You can download and source the script locally, or simply run:
Replace or set $YOUR_SERVICE_NAME to the name of your application service. For example: ACME_ORDERS_SERVICE
To set all of the necessary environment variables and download the agent files when running on Windows, you can use the following PS1 script from PowerShell terminal:
Nothing special. It has three parts:
Download the agent files if they are not already present to a TEMP dir
Set up the JAVA_TOOL_OPTIONS
env variables so that the Java app will use the agent when it is started
Set up all of the system properties and env variables so that the data is being sent to the Digma collector port
This is just a convenience script to to help automate this process
If you're running Digma centrally or wish to send data to a shared environment, you need to set some additional flags when you run the script. You can find a full list of the different configuration options using the --help
argument.