top of page

WELCOME TO CLOUD MATTER

Search
  • Writer's pictureRoman Guoussev-Donskoi

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.


Profiler Agent

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.


Application Configuration

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. pom.xml


1.1. profiler repository...

<repository>

<id>javaprofiler-repo</id>

<url>https://www.myget.org/F/profiler-maven/maven</url>

</repository>


1.2. dependencies

<dependency>

<groupId>com.microsoft.azure</groupId>

<artifactId>applicationinsights-profiler-spring</artifactId>

<version>0.2.2</version>

</dependency>

<dependency>

<groupId>com.microsoft.azure</groupId>

<artifactId>applicationinsights-profiler-telemetrymodule</artifactId>

<version>0.2.2</version>

</dependency>


1.3. Application Settings

<appSettings>

<property>

<name>JAVA_OPTS</name>

<value>-javaagent:D:\home\site\wwwroot\agent\applicationinsights-agent-2.4.0.jar -agentpath:D:\home\site\wwwroot\agent\javaprofileragent.dll</value>

</property>

</appSettings>


1.4. Configure deployment of agent files to target application

<resource>

<directory>${project.basedir}/agent</directory>

<!-- Relative path to /site/wwwroot/ -->

<targetPath>agent</targetPath>

<includes>

<include>*</include>

</includes>

</resource>


2. agent\AI-Agent.xml

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">

<!--Method name="slow"

reportCaughtExceptions="true"

reportExecutionTime="true"

/>-->

</Class>


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 :)


1,008 views0 comments

Recent Posts

See All

Query SQL using OpenAI and Langchain

LLMs (such as OpenAI) are good for reasoning but they lack capability interface with outside world. This is where Langchain agents step in: agents provide LLMs with tools to perform actions (for examp

Comments


Home: Blog2

Subscribe

Home: GetSubscribers_Widget

CONTACT

Your details were sent successfully!

Computers
Home: Contact
bottom of page