You can instrument WSO2 API Microgateway by adding the Java Agent to JVM arguments in the executable file of the gateway. Perform the following steps based on your environment to attach the Java Agent:
- Open the executable file named "gateway" at
<MGW_HOME>/bin
in a text editor. In java_cmd_gateway () under $JAVA_OPTS, add :
-javaagent:/path_to_appagent/javaagent.jar
- Save the executable and start the gateway.
Navigate to the docker container in which the microgateway is running using the following command:
docker exec -it <container_id> /bin/bash
- Open the executable file named "gateway" at wso2/bin inside the docker container in a text editor.
In java_cmd_gateway () under $JAVA_OPTS, add :
-javaagent:/path_to_appagent/javaagent.jar
- Save the gateway file.
Fetch the process id of Java process running inside the container using the following command:
ps -eaf | grep java
Kill the process <process_ID>:
kill -9 <process_ID>
Start the gateway again by running the jar:
wso2/bin/gateway <executable_jar>
Open the executable file named "gateway" at <MGW_HOME>/bin in a text editor.
In
runTools
under "SET JAVA_CMD", after "%JAVA_OPTS% ^" add the following:-javaagent:/path_to_appagent/javaagent.jar
- Save the executable and start the gateway.