TracesMetricsApp LogsCustom LogsProfiling


  • To monitor APM data on dashboard, Middleware Host agent needs to be installed.
  • You can refer this demo project to refer use cases of APM.

Distributed Tracing

For recording the traces you will need to download JAR files given below. middleware-javaagent-1.3.0.jar

And then run your project with command given below

MW_API_KEY={MW_API_KEY} java -javaagent:/PATH/TO/middleware-javaagent-{version}.jar \{APM-SERVICE-NAME} \{APM-PROJECT-NAME} \
    -jar <YOUR_APP>.jar

Clojure/Ring Demo

Add custom logs

Add this dependency in pom.xml



Refer the latest APM version from the link given below:

Then run

mvn install

Import logger package

import io.github.middlewarelabs.agentapmjava.Logger;

Use these functions for logging with different severity levels"info message");
Logger.debug("debug message");
Logger.warn("warn message");
Logger.error("error message");

Note for APM inside Kubernetes

If you are using APM in a Kubernetes cluster make sure to follow these 2 steps:

Step 1 : Find your Middleware Service namespace

For older setup, your “mw-service” can be inside mw-agent-ns-{FIRST-5-LETTERS-OF-API-KEY} namespace For newer setup, we simplified the namespace name to mw-agent-ns

Step 2 : Set this ENV variable in your application deployment YAML

Please replace “NAMESPACE” with the correct value that you found from Step 1.

Error Handling

If you want to record exception in traces then you can use Logger.recordError(e) method.

import io.github.middlewarelabs.agentapmjava.Logger;
try {
       int[] myNumbers = {1, 2, 3};
     } catch (Throwable  e) {
       System.out.println("Something went wrong.");