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:


Java Agent supports only the HTTP1 protocol for entry and exit.

  1. Open the executable file named "gateway" at <MGW_HOME>/bin in a text editor.
  2. In java_cmd_gateway () under $JAVA_OPTS, add :

    -javaagent:/path_to_appagent/javaagent.jar
    CODE
  3. Save the executable and start the gateway.
  1. Navigate to the docker container in which the microgateway is running using the following command:

    docker exec -it <container_id> /bin/bash 
    CODE
  2. Open the executable file named "gateway" at wso2/bin inside the docker container in a text editor.
  3. In java_cmd_gateway () under $JAVA_OPTS, add :

    -javaagent:/path_to_appagent/javaagent.jar
    CODE
  4. Save the gateway file.
  5. Fetch the process id of Java process running inside the container using the following command:

    ps -eaf | grep java
    CODE
  6. Kill the process <process_ID>:

    kill -9 <process_ID>
    CODE
  7. Start the gateway again by running the jar:

    wso2/bin/gateway <executable_jar>
    CODE
  1. Open the executable file named "gateway" at <MGW_HOME>/bin in a text editor.


  2. In runTools under "SET JAVA_CMD", after "%JAVA_OPTS% ^" add the following:

    -javaagent:/path_to_appagent/javaagent.jar
    CODE
  3. Save the executable and start the gateway.