Skip to content

Commit 7281ec4

Browse files
authored
Merge pull request #109447 from MS-jgol/java-3.0-new-doc
Added a new java file to codeless, changed TOC
2 parents 4d0f20a + 84e6410 commit 7281ec4

File tree

3 files changed

+199
-5
lines changed

3 files changed

+199
-5
lines changed
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
---
2+
title: Monitor Java applications on any environment - Azure Monitor Application Insights
3+
description: Application performance monitoring for Java applications running in any environment without instrumenting the app. Distributed tracing and application map.
4+
ms.topic: conceptual
5+
ms.date: 03/29/2020
6+
7+
---
8+
9+
# Java codeless application monitoring Azure Monitor Application Insights - public preview
10+
11+
Java codeless application monitoring is all about simplicity - there are no code changes, the Java agent can be enabled through just a couple of configuration changes.
12+
13+
The Java agent works in any environment, and allows you to monitor all of your Java applications. In other words, whether you are running your Java apps on VMs, on-premises, in AKS, on Windows, Linux - you name it, the Java 3.0 agent will monitor your app.
14+
15+
Adding the Application Insights Java SDK to your application is no longer required, as the 3.0 agent autocollects requests, dependencies and logs all on its own.
16+
17+
You can still send custom telemetry from your application. The 3.0 agent will track and correlate it along with all of the autocollected telemetry.
18+
19+
## Quickstart
20+
21+
**1. Download the agent**
22+
23+
Download [applicationinsights-agent-3.0.0-PREVIEW.jar](https://github.com/microsoft/ApplicationInsights-Java/releases/download/3.0.0-PREVIEW/applicationinsights-agent-3.0.0-PREVIEW.jar)
24+
25+
**2. Point the JVM to the agent**
26+
27+
Add `-javaagent:path/to/applicationinsights-agent-3.0.0-PREVIEW.jar` to your application's JVM args
28+
29+
Typical JVM args include `-Xmx512m` and `-XX:+UseG1GC`. So if you know where to add these, then you already know where to add this.
30+
31+
For additional help with configuring your application's JVM args, please see [3.0 Preview: Tips for updating your JVM args](https://github.com/microsoft/ApplicationInsights-Java/wiki/3.0-Preview:-Tips-for-updating-your-JVM-args).
32+
33+
**3. Point the agent to your Application Insights resource**
34+
35+
If you do not already have an Application Insights resource, you can create a new one by following the steps in the [resource creation guide](https://docs.microsoft.com/azure/azure-monitor/app/create-new-resource).
36+
Create a configuration file named `ApplicationInsights.json`, and place it in the same directory as `applicationinsights-agent-3.0.0-PREVIEW.jar`, with the following content:
37+
38+
```json
39+
{
40+
"instrumentationSettings": {
41+
"connectionString": "InstrumentationKey=00000000-0000-0000-0000-000000000000"
42+
}
43+
}
44+
```
45+
46+
You can find your connection string in your Application Insights resource:
47+
48+
:::image type="content" source="media/java-ipa/connection-string.png" alt-text="Application Insights Connection String":::
49+
50+
**4. That's it!**
51+
52+
Now start up your application and go to your Application Insights resource in the Azure portal to see your monitoring data.
53+
54+
> [!NOTE]
55+
> It may take a couple of minutes for your monitoring data to show up in the portal.
56+
57+
58+
## Configuration options
59+
60+
In the `ApplicationInsights.json` file, you can additionally configure:
61+
62+
* Cloud role name
63+
* Cloud role instance
64+
* JMX metrics
65+
* Sampling
66+
* Logging capture threshold
67+
* HTTP Proxy
68+
* Heartbeat interval
69+
* Self diagnostics
70+
71+
See details at [3.0 Public Preview: Configuration Options](https://github.com/microsoft/ApplicationInsights-Java/wiki/3.0-Preview:-Configuration-Options).
72+
73+
## Autocollected requests, dependencies, and logs
74+
75+
### Requests
76+
77+
* JMS Consumers
78+
* Kafka Consumers
79+
* Netty/WebFlux
80+
* Servlets
81+
* Spring Scheduling
82+
83+
### Dependencies with distributed trace propagation
84+
85+
* Apache HttpClient and HttpAsyncClient
86+
* gRPC
87+
* java.net.HttpURLConnection
88+
* JMS
89+
* Kafka
90+
* Netty client
91+
* OkHttp
92+
93+
### Other dependencies
94+
95+
* Cassandra
96+
* JDBC
97+
* MongoDB (async and sync)
98+
* Redis (Lettuce and Jedis)
99+
100+
### Logs
101+
102+
* java.util.logging
103+
* Log4j
104+
* SLF4J/Logback
105+
106+
## Sending custom telemetry from your application
107+
108+
Our goal in 3.0+ is to allow you to send your custom telemetry using standard APIs.
109+
110+
We support Micrometer, OpenTelemetry API, and the popular logging frameworks. Application Insights Java 3.0 will automatically capture the telemetry, and correlate it along with all of the autocollected telemetry.
111+
112+
For this reason, we're not planning to release an SDK with Application Insights 3.0 at this time.
113+
114+
Application Insights Java 3.0 is already listening for telemetry that is sent to the Application Insights Java SDK 2.x. This functionality is an important part of the upgrade story for existing 2.x users, and it fills an important gap in our custom telemetry support until the OpenTelemetry API is GA.
115+
116+
## Sending custom telemetry using Application Insights Java SDK 2.x
117+
118+
Add `applicationinsights-core-2.6.0.jar` to your application (all 2.x versions are supported by Application Insights Java 3.0, but it's worth using the latest if you have a choice):
119+
120+
```xml
121+
<dependency>
122+
<groupId>com.microsoft.azure</groupId>
123+
<artifactId>applicationinsights-core</artifactId>
124+
<version>2.6.0</version>
125+
</dependency>
126+
```
127+
128+
Create a TelemetryClient:
129+
130+
```java
131+
private static final TelemetryClient telemetryClient = new TelemetryClient();
132+
```
133+
134+
and use that for sending custom telemetry.
135+
136+
### Events
137+
138+
```java
139+
telemetryClient.trackEvent("WinGame");
140+
```
141+
### Metrics
142+
143+
```java
144+
telemetryClient.trackMetric("queueLength", 42.0);
145+
```
146+
147+
### Dependencies
148+
149+
```java
150+
boolean success = false;
151+
long startTime = System.currentTimeMillis();
152+
try {
153+
success = dependency.call();
154+
} finally {
155+
long endTime = System.currentTimeMillis();
156+
RemoteDependencyTelemetry telemetry = new RemoteDependencyTelemetry();
157+
telemetry.setTimestamp(new Date(startTime));
158+
telemetry.setDuration(new Duration(endTime - startTime));
159+
telemetryClient.trackDependency(telemetry);
160+
}
161+
```
162+
163+
### Logs
164+
You can send custom log telemetry via your favorite logging framework.
165+
166+
Or you can also use Application Insights Java SDK 2.x:
167+
168+
```java
169+
telemetryClient.trackTrace(message, SeverityLevel.Warning, properties);
170+
```
171+
172+
### Exceptions
173+
You can send custom exception telemetry via your favorite logging framework.
174+
175+
Or you can also use Application Insights Java SDK 2.x:
176+
177+
```java
178+
try {
179+
...
180+
} catch (Exception e) {
181+
telemetryClient.trackException(e);
182+
}
183+
```
184+
185+
## Upgrading from Application Insights Java SDK 2.x
186+
187+
If you're already using Application Insights Java SDK 2.x in your application, there is no need to remove it. The Java 3.0 agent will detect it, and capture and correlate any custom telemetry you're sending via the Java SDK 2.x, while suppressing any autocollection performed by the Java SDK 2.x to prevent duplicate capture.
188+
189+
> [!NOTE]
190+
> Note: Java SDK 2.x TelemetryInitializers and TelemetryProcessors will not be run when using the 3.0 agent.
48.3 KB
Loading

articles/azure-monitor/toc.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,13 @@
161161
- name: Code-based monitoring
162162
items:
163163
- name: ASP.NET Core
164-
displayname: Core, .NET Core, services.add, dotnetcore, c#, csharp
165-
href: app/asp-net-core.md
164+
items:
165+
- name: ASP.NET Core App Monitoring
166+
displayname: Core, .NET Core, services.add, dotnetcore, c#, csharp
167+
href: app/asp-net-core.md
168+
- name: ILogger
169+
displayname: ilogger, logging, log
170+
href: app/ilogger.md
166171
- name: ASP.NET
167172
displayname: ASP.NET, c#, csharp, .NET, NET, dotnet
168173
href: app/asp-net.md
@@ -172,9 +177,6 @@
172177
- name: .NET Console
173178
displayname: console, .NET, dotnet console, dotnet, c#, csharp, NET
174179
href: app/console.md
175-
- name: ILogger
176-
displayname: ilogger, logging, log
177-
href: app/ilogger.md
178180
- name: Java
179181
items:
180182
- name: Web apps
@@ -224,6 +226,8 @@
224226
href: app/remove-application-insights.md
225227
- name: Codeless monitoring
226228
items:
229+
- name: Any environment - Java (preview)
230+
href: app/java-in-process-agent.md
227231
- name: Azure VM and scale set
228232
href: app/azure-vm-vmss-apps.md
229233
- name: Azure App Service

0 commit comments

Comments
 (0)