@@ -10,18 +10,157 @@ ms.reviewer: mmcc
10
10
11
11
# Upgrading from Application Insights Java 2.x SDK
12
12
13
- If you're already using Application Insights Java 2.x SDK in your application, you can keep using it.
14
- The Application Insights Java 3.x agent will detect it,
15
- and capture and correlate any custom telemetry you're sending via the 2.x SDK,
16
- while suppressing any auto-collection performed by the 2.x SDK to prevent duplicate telemetry.
13
+ ## Step-by-step
17
14
18
- If you were using Application Insights 2.x agent, you need to remove the ` -javaagent: ` JVM arg
19
- that was pointing to the 2.x agent.
15
+ #### Step 1
20
16
21
- The rest of this document describes limitations and changes that you may encounter
22
- when upgrading from 2.x to 3.x, as well as some workarounds that you may find helpful.
17
+ If you are using ` applicationinsights-core ` and/or ` applicationinsights-web ` dependencies, update those to the latest
18
+ 3.x version, e.g.
19
+
20
+ Change
21
+
22
+ ```
23
+ <dependency>
24
+ <groupId>com.microsoft.azure</groupId>
25
+ <artifactId>applicationinsights-core</artifactId>
26
+ <version>2.6.4</version>
27
+ </dependency>
28
+ ```
29
+
30
+ to
31
+
32
+ ```
33
+ <dependency>
34
+ <groupId>com.microsoft.azure</groupId>
35
+ <artifactId>applicationinsights-core</artifactId>
36
+ <version>3.4.0</version>
37
+ </dependency>
38
+ ```
39
+
40
+ #### Step 2
41
+
42
+ If you are using ` applicationinsights-web-auto ` dependency, remove that and replace it with the latest 3.x version of
43
+ ` applicationinsights-web ` , e.g.
44
+
45
+ Change
46
+
47
+ ```
48
+ <dependency>
49
+ <groupId>com.microsoft.azure</groupId>
50
+ <artifactId>applicationinsights-web-auto</artifactId>
51
+ <version>2.6.4</version>
52
+ </dependency>
53
+ ```
54
+
55
+ to
56
+
57
+ ```
58
+ <dependency>
59
+ <groupId>com.microsoft.azure</groupId>
60
+ <artifactId>applicationinsights-web</artifactId>
61
+ <version>3.4.0</version>
62
+ </dependency>
63
+ ```
64
+
65
+ #### Step 3
66
+
67
+ If you have the Application Insights web filter ` com.microsoft.applicationinsights.web.internal.WebRequestTrackingFilter `
68
+ added your web.xml, remove that, since requests are now auto-instrumented in 3.x and this custom web filter is no longer
69
+ needed, e.g.
70
+
71
+ Remove
72
+
73
+ ```
74
+ <filter>
75
+ <filter-name>ApplicationInsightsWebFilter</filter-name>
76
+ <filter-class>com.microsoft.applicationinsights.web.internal.WebRequestTrackingFilter</filter-class>
77
+ </filter>
78
+ <filter-mapping>
79
+ <filter-name>ApplicationInsightsWebFilter</filter-name>
80
+ <url-pattern>/*</url-pattern>
81
+ </filter-mapping>
82
+ ```
83
+
84
+ #### Step 4
85
+
86
+ If you are using ` applicationinsights-logging-log4j1_2 ` , ` applicationinsights-logging-log4j2 ` ,
87
+ and/or ` applicationinsights-logging-logback ` , remove those dependencies, since loggers are now auto-instrumented in 3.x
88
+ and these custom logging appenders are no longer needed, e.g.
89
+
90
+ Remove
91
+
92
+ ```
93
+ <dependency>
94
+ <groupId>com.microsoft.azure</groupId>
95
+ <artifactId>applicationinsights-logging-log4j1_2</artifactId>
96
+ <version>2.6.4</version>
97
+ </dependency>
98
+ ```
99
+
100
+ #### Step 5
101
+
102
+ If you are using ` applicationinsights-spring-boot-starter ` , remove that and replace it with the latest 3.x version of
103
+ ` applicationinsights-web ` , e.g.
23
104
105
+ Change
24
106
107
+ ```
108
+ <dependency>
109
+ <groupId>com.microsoft.azure</groupId>
110
+ <artifactId>applicationinsights-spring-boot-starter</artifactId>
111
+ <version>2.6.4</version>
112
+ </dependency>
113
+ ```
114
+
115
+ to
116
+
117
+ ```
118
+ <dependency>
119
+ <groupId>com.microsoft.azure</groupId>
120
+ <artifactId>applicationinsights-web</artifactId>
121
+ <version>3.4.0</version>
122
+ </dependency>
123
+ ```
124
+
125
+ Note: the cloud role name will no longer default to ` spring.application.name ` , see the
126
+ [ 3.x configuration docs] ( ./java-standalone-config.md#cloud-role-name ) for configuring the cloud role name.
127
+
128
+ #### Step 6
129
+
130
+ If you were using the Application Insights 2.x Javaagent, you need to replace that with the 3.x Javaagent, e.g.
131
+
132
+ Change
133
+
134
+ ```
135
+ -javaagent:path/to/applicationinsights-agent-2.6.4.jar
136
+ ```
137
+
138
+ to
139
+
140
+ ```
141
+ -javaagent:path/to/applicationinsights-agent-3.4.0.jar
142
+ ```
143
+
144
+ #### Step 7
145
+
146
+ If you were not using the Application Insights 2.x Javaagent, you will need to add the Application Insights 3.x
147
+ Javaagent to your JVM args, e.g.
148
+
149
+ ```
150
+ -javaagent:path/to/applicationinsights-agent-3.4.0.jar
151
+ ```
152
+
153
+ Note: if you were using the spring-boot-starter, there is an alternative to using the Javaagent if you prefer, see
154
+ [ 3.x Spring Boot] ( ./java-spring-boot.md ) .
155
+
156
+ #### Step 8
157
+
158
+ [ Configure the connection string] ( ./java-standalone-config.md#connection-string ) .
159
+
160
+ ## Additional notes
161
+
162
+ The rest of this document describes limitations and changes that you may encounter
163
+ when upgrading from 2.x to 3.x, as well as some workarounds that you may find helpful.
25
164
26
165
## TelemetryInitializers and TelemetryProcessors
27
166
@@ -126,21 +265,3 @@ The telemetry processors perform the following actions (in order):
126
265
}
127
266
}
128
267
```
129
-
130
- ## 2.x SDK logging appenders
131
-
132
- Application Insights Java 3.x [ auto-collects logging] ( ./java-standalone-config.md#auto-collected-logging )
133
- without the need for configuring any logging appenders.
134
- If you are using 2.x SDK logging appenders, those can be removed,
135
- as they will be suppressed by the Application Insights Java 3.x anyways.
136
-
137
- ## 2.x SDK spring boot starter
138
-
139
- There is no Application Insights Java 3.x spring boot starter.
140
- 3.x setup and configuration follows the same [ simple steps] ( ./java-in-process-agent.md#get-started )
141
- whether you are using spring boot or not.
142
-
143
- When upgrading from the Application Insights Java 2.x SDK spring boot starter,
144
- note that the cloud role name will no longer default to ` spring.application.name ` .
145
- See the [ 3.x configuration docs] ( ./java-standalone-config.md#cloud-role-name )
146
- for setting the cloud role name in 3.x via json config or environment variable.
0 commit comments