You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-monitor/app/java-agent.md
+45-67Lines changed: 45 additions & 67 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,25 +13,32 @@ ms.topic: conceptual
13
13
ms.date: 01/10/2019
14
14
ms.author: mbullwin
15
15
---
16
-
# Monitor dependencies, caught exceptions and method execution times in Java web apps
16
+
# Monitor dependencies, caught exceptions, and method execution times in Java web apps
17
17
18
18
19
19
If you have [instrumented your Java web app with Application Insights][java], you can use the Java Agent to get deeper insights, without any code changes:
20
20
21
21
***Dependencies:** Data about calls that your application makes to other components, including:
22
-
***REST calls** made via HttpClient, OkHttp, and RestTemplate (Spring) are captured.
23
-
***Redis** calls made via the Jedis client are captured.
24
-
***[JDBC calls](https://docs.oracle.com/javase/7/docs/technotes/guides/jdbc/)** - MySQL, SQL Server and Oracle DB commands are automatically captured. For MySQL, if the call takes longer than 10s, the agent reports the query plan.
25
-
***Caught exceptions:** Information about exceptions that are handled by your code.
26
-
***Method execution time:** Information about the time it takes to execute specific methods.
22
+
***Outgoing HTTP calls** made via Apache HttpClient, OkHttp, and `java.net.HttpURLConnection` are captured.
23
+
***Redis calls** made via the Jedis client are captured.
24
+
***JDBC queries** - For MySQL and PostgreSQL, if the call takes longer than 10 seconds, the agent reports the query plan.
25
+
26
+
***Application logging:** Capture and correlate your application logs with HTTP requests and other telemetry
27
+
***Log4j 1.2**
28
+
***Log4j2**
29
+
***Logback**
30
+
31
+
***Better operation naming:** (used for aggregation of requests in the portal)
32
+
***Spring** - based on `@RequestMapping`.
33
+
***JAX-RS** - based on `@Path`.
27
34
28
35
To use the Java agent, you install it on your server. Your web apps must be instrumented with the [Application Insights Java SDK][java].
29
36
30
37
## Install the Application Insights agent for Java
31
38
1. On the machine running your Java server, [download the agent](https://github.com/Microsoft/ApplicationInsights-Java/releases/latest). Please ensure to download the same version of Java Agent as Application Insights Java SDK core and web packages.
32
-
2. Edit the application server startup script, and add the following JVM:
39
+
2. Edit the application server startup script, and add the following JVM arg:
33
40
34
-
`javaagent:`*full path to the agent JAR file*
41
+
`-javaagent:<full path to the agent JAR file>`
35
42
36
43
For example, in Tomcat on a Linux machine:
37
44
@@ -44,58 +51,46 @@ Create a file named `AI-Agent.xml` and place it in the same folder as the agent
44
51
Set the content of the xml file. Edit the following example to include or omit the features you want.
45
52
46
53
```XML
54
+
<?xml version="1.0" encoding="utf-8"?>
55
+
<ApplicationInsightsAgent>
56
+
<Instrumentation>
57
+
<BuiltInenabled="true">
47
58
48
-
<?xml version="1.0" encoding="utf-8"?>
49
-
<ApplicationInsightsAgent>
50
-
<Instrumentation>
51
-
52
-
<!-- Collect remote dependency data -->
53
-
<BuiltInenabled="true">
54
-
<!-- Disable Redis or alter threshold call duration above which arguments are sent.
55
-
Defaults: enabled, 10000 ms -->
56
-
<Jedisenabled="true"thresholdInMS="1000"/>
57
-
58
-
<!-- Set SQL query duration above which query plan is reported (MySQL, PostgreSQL). Default is 10000 ms. -->
For the latest version of the Java agent check the releases [here](https://github.com/Microsoft/ApplicationInsights-Java/releases
93
+
For the latest version of the Java agent, check the releases [here](https://github.com/Microsoft/ApplicationInsights-Java/releases
99
94
).
100
95
101
96
The agent must be packaged as a resource in your project such that it ends up in the D:/home/site/wwwroot/ directory. You can confirm that your agent is in the correct App Service directory by going to **Development Tools** > **Advanced Tools** > **Debug Console** and examining the contents of the site directory.
@@ -105,33 +100,16 @@ The agent must be packaged as a resource in your project such that it ends up in
105
100
> [!NOTE]
106
101
> AI-Agent.xml and the agent jar file should be in the same folder. They are often placed together in the `/resources` folder of the project.
107
102
108
-
### Spring Rest Template
109
-
110
-
In order for Application Insights to successfully instrument HTTP calls made with Spring's Rest Template, use of the Apache HTTP Client is required. By default Spring's Rest Template is not configured to use the Apache HTTP Client. By specifying [HttpComponentsClientHttpRequestfactory](https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.html) in the constructor of a Spring Rest Template, it will use Apache HTTP.
111
-
112
-
Here's an example of how to do this with Spring Beans. This is a very simple example which uses the default settings of the factory class.
0 commit comments