Azure App Service Java Profiler
For application deployment to be supportable we need to have a clear visibility and insight into application performance and behavior.
For .NET stack Azure provides great tools to trace and visualize application performance. Now Java developers can also enjoy application profiler capabilities in Azure.
Enable java profiler
First the application needs to be instrumented with application insights. For details on this you can refer to "Azure App Service - logging and monitoring made easy"
Once you application is connected to Application Insights you can add profiler capabilities.
To enable Java profiler in Azure include application insights agent jar, profiler dll and agent config file AI-Agent.xml in your application deployment. I placed them all into "wwwroot\agent\" folder.
Note: Please use Application Insights Java SDK 2.4.0 or later.
Once we have agent files ready for deployment we need to update application deployment configuration as described below. Please align application insights packages (e.g. applicationinsights-web) to 2.4.0 as well. The complete example is available in GitHub
1.1. profiler repository...
1.3. Application Settings
1.4. Configure deployment of agent files to target application
<!-- Relative path to /site/wwwroot/ -->
Create a file named AI-Agent.xml and place it in the same folder as the agent JAR file.
Microsoft provides Application Insights Java Agent documentation. Snippet below shows how to configure profiler for a specific class inside "AI-Agent.xml".
<Class name="ca.ontario.gocloud.controller.JavaAIExampleController" type="Service" enabled="true">
Start Profiling application
We can start with Application Map and drill down into application performance and encountered exceptions.
On Application Map select the dependency and click on "Investigate Performance".
You can enable profiler from "Configure Profiler" menu.
In "Performance" blade you can see the average duration and can dill into samples
Once found interesting sample by scrolling through samples - click on it to get further details
Then you can see the executing SQL statement and other details such as timestamp and actual duration of this execution.
We only touched on Azure Java profiler capabilities. Hope you got interested, will explore it further and leverage to your benefit.
Happy profiling :)