Skip to content

Commit 570dab1

Browse files
committed
edit pass: app-articles-batch-16
1 parent e0cdcda commit 570dab1

File tree

2 files changed

+91
-88
lines changed

2 files changed

+91
-88
lines changed

articles/azure-monitor/app/java-in-process-agent.md

Lines changed: 48 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Azure Monitor Application Insights Java
3-
description: Application performance monitoring for Java applications running in any environment without requiring code modification. Distributed tracing and application map.
3+
description: Application performance monitoring for Java applications running in any environment without requiring code modification. The article also discusses distributed tracing and the application map.
44
ms.topic: conceptual
55
ms.date: 12/14/2022
66
ms.devlang: java
@@ -10,19 +10,21 @@ ms.reviewer: mmcc
1010

1111
# Azure Monitor OpenTelemetry-based auto-instrumentation for Java applications
1212

13-
This article describes how to enable and configure the OpenTelemetry-based Azure Monitor Java offering. It can be used for any environment, including on-premises. After you finish the instructions in this article, you'll be able to use Azure Monitor Application Insights to monitor your application.
13+
This article describes how to enable and configure the OpenTelemetry-based Azure Monitor Java offering. It can be used for any environment, including on-premises. After you finish the instructions in this article, you can use Azure Monitor Application Insights to monitor your application.
1414

1515
[!INCLUDE [azure-monitor-log-analytics-rebrand](../../../includes/azure-monitor-instrumentation-key-deprecation.md)]
1616

1717
## Get started
1818

19-
Java auto-instrumentation is enabled through configuration changes; no code changes are required.
19+
Java auto-instrumentation is enabled through configuration changes. No code changes are required.
2020

2121
### Prerequisites
2222

23-
- Java application using Java 8+
24-
- Azure subscription: [Create an Azure subscription for free](https://azure.microsoft.com/free/)
25-
- Application Insights resource: [Create an Application Insights resource](create-workspace-resource.md#create-a-workspace-based-resource)
23+
You need:
24+
25+
- A Java application using Java 8+.
26+
- An Azure subscription: [Create an Azure subscription for free](https://azure.microsoft.com/free/).
27+
- An Application Insights resource: [Create an Application Insights resource](create-workspace-resource.md#create-a-workspace-based-resource).
2628

2729
### Enable Azure Monitor Application Insights
2830

@@ -34,32 +36,31 @@ Download the [applicationinsights-agent-3.4.7.jar](https://github.com/microsoft/
3436

3537
> [!WARNING]
3638
>
37-
> If you are upgrading from an earlier 3.x version,
39+
> If you're upgrading from an earlier 3.x version:
3840
>
3941
> Starting from 3.4.0:
4042
>
41-
> - Rate-limited sampling is now the default (if you have not configured a fixed percentage previously). By default, it will capture at most around 5 requests per second (along with their dependencies, traces and custom events). See [fixed-percentage sampling](./java-standalone-config.md#fixed-percentage-sampling) if you wish to revert to the previous behavior of capturing 100% of requests.
43+
> - Rate-limited sampling is now the default, if you haven't configured a fixed percentage previously. By default, it will capture at most around five requests per second, along with their dependencies, traces, and custom events. See [fixed-percentage sampling](./java-standalone-config.md#fixed-percentage-sampling) if you want to revert to the previous behavior of capturing 100% of requests.
4244
>
4345
> Starting from 3.3.0:
4446
>
45-
> - `LoggingLevel` is not captured by default as part of Traces' custom dimension since that data is already captured in the `SeverityLevel` field. For details on how to re-enable this if needed, please see the [config options](./java-standalone-config.md#logging-level-as-a-custom-dimension)
46-
> - Exception records are no longer recorded for failed dependencies, they are only recorded for failed requests.
47+
> - `LoggingLevel` isn't captured by default as part of Traces' custom dimension because that data is already captured in the `SeverityLevel` field. For information on how to reenable it, see the [config options](./java-standalone-config.md#logging-level-as-a-custom-dimension).
48+
> - Exception records are no longer recorded for failed dependencies. They're only recorded for failed requests.
4749
>
4850
> Starting from 3.2.0:
49-
>
50-
> - Controller "InProc" dependencies are no longer captured by default. For details on how to re-enable these, please see the [config options](./java-standalone-config.md#autocollect-inproc-dependencies-preview).
51+
>
52+
> - Controller `InProc` dependencies are no longer captured by default. For information on how to reenable these dependencies, see the [config options](./java-standalone-config.md#autocollect-inproc-dependencies-preview).
5153
> - Database dependency names are now more concise with the full (sanitized) query still present in the `data` field. HTTP dependency names are now more descriptive.
5254
> This change can affect custom dashboards or alerts if they relied on the previous values.
53-
> For details, see the [3.2.0 release notes](https://github.com/microsoft/ApplicationInsights-Java/releases/tag/3.2.0).
54-
>
55+
> For more information, see the [3.2.0 release notes](https://github.com/microsoft/ApplicationInsights-Java/releases/tag/3.2.0).
56+
>
5557
> Starting from 3.1.0:
56-
>
58+
>
5759
> - The operation names and request telemetry names are now prefixed by the HTTP method, such as `GET` and `POST`.
5860
> This change can affect custom dashboards or alerts if they relied on the previous values.
59-
> For details, see the [3.1.0 release notes](https://github.com/microsoft/ApplicationInsights-Java/releases/tag/3.1.0).
61+
> For more information, see the [3.1.0 release notes](https://github.com/microsoft/ApplicationInsights-Java/releases/tag/3.1.0).
6062
>
6163
62-
6364
#### Point the JVM to the jar file
6465

6566
Add `-javaagent:"path/to/applicationinsights-agent-3.4.7.jar"` to your application's JVM args.
@@ -68,7 +69,7 @@ Add `-javaagent:"path/to/applicationinsights-agent-3.4.7.jar"` to your applicati
6869
> For help with configuring your application's JVM args, see [Tips for updating your JVM args](./java-standalone-arguments.md).
6970
7071
> [!TIP]
71-
> If you develop a Spring Boot application, you can replace the JVM argument by a programmatic configuration. More [here](./java-spring-boot.md).
72+
> If you develop a Spring Boot application, you can replace the JVM argument by a programmatic configuration. For more information, see [Using Azure Monitor Application Insights with Spring Boot](./java-spring-boot.md).
7273
7374
#### Set the Application Insights connection string
7475

@@ -90,8 +91,8 @@ Add `-javaagent:"path/to/applicationinsights-agent-3.4.7.jar"` to your applicati
9091

9192
1. Find the connection string on your Application Insights resource.
9293

93-
:::image type="content" source="media/migrate-from-instrumentation-keys-to-connection-strings/migrate-from-instrumentation-keys-to-connection-strings.png" alt-text="Screenshot displaying Application Insights overview and connection string." lightbox="media/migrate-from-instrumentation-keys-to-connection-strings/migrate-from-instrumentation-keys-to-connection-strings.png":::
94-
94+
:::image type="content" source="media/migrate-from-instrumentation-keys-to-connection-strings/migrate-from-instrumentation-keys-to-connection-strings.png" alt-text="Screenshot that shows Application Insights overview and connection string." lightbox="media/migrate-from-instrumentation-keys-to-connection-strings/migrate-from-instrumentation-keys-to-connection-strings.png":::
95+
9596
#### Confirm data is flowing
9697

9798
Run your application and open your **Application Insights Resource** tab in the Azure portal. It can take a few minutes for data to show up in the portal.
@@ -108,7 +109,7 @@ As part of using Application Insights instrumentation, we collect and send diagn
108109

109110
## Configuration options
110111

111-
In the `applicationinsights.json` file, you can also configure these settings:
112+
In the *applicationinsights.json* file, you can also configure these settings:
112113

113114
* Cloud role name
114115
* Cloud role instance
@@ -117,14 +118,14 @@ In the `applicationinsights.json` file, you can also configure these settings:
117118
* Custom dimensions
118119
* Telemetry processors (preview)
119120
* Autocollected logging
120-
* Autocollected Micrometer metrics, which include Spring Boot Actuator metrics
121+
* Autocollected Micrometer metrics, including Spring Boot Actuator metrics
121122
* Heartbeat
122123
* HTTP proxy
123124
* Self-diagnostics
124125

125126
For more information, see [Configuration options](./java-standalone-config.md).
126127

127-
## Auto-Instrumentation
128+
## Auto-instrumentation
128129

129130
Java 3.x includes the following auto-instrumentation.
130131

@@ -138,8 +139,7 @@ Java 3.x includes the following auto-instrumentation.
138139
* Spring scheduling
139140

140141
> [!NOTE]
141-
> Servlet and Netty auto-instrumentation covers the majority of Java HTTP services
142-
> including Java EE, Jakarta EE, Spring Boot, Quarkus, and Micronaut.
142+
> Servlet and Netty auto-instrumentation covers the majority of Java HTTP services, including Java EE, Jakarta EE, Spring Boot, Quarkus, and Micronaut.
143143

144144
### Autocollected dependencies
145145

@@ -175,7 +175,7 @@ Autocollected dependencies without downstream distributed trace propagation:
175175

176176
### Autocollected metrics
177177

178-
* Micrometer, which includes Spring Boot Actuator metrics
178+
* Micrometer, including Spring Boot Actuator metrics
179179
* JMX Metrics
180180

181181
### Azure SDKs
@@ -233,9 +233,9 @@ Telemetry emitted by these Azure SDKs is automatically collected by default:
233233

234234
This section explains how to modify telemetry.
235235

236-
### Add spans using the OpenTelemetry annotation
236+
### Add spans by using the OpenTelemetry annotation
237237

238-
The simplest way to add your own spans is using OpenTelemetry's `@WithSpan` annotation.
238+
The simplest way to add your own spans is by using OpenTelemetry's `@WithSpan` annotation.
239239

240240
Spans populate the `requests` and `dependencies` tables in Application Insights.
241241

@@ -262,16 +262,15 @@ Spans populate the `requests` and `dependencies` tables in Application Insights.
262262
}
263263
```
264264

265-
By default the span will end up in the dependencies table with dependency type `InProc`.
265+
By default, the span will end up in the `dependencies` table with dependency type `InProc`.
266266

267-
If your method represents a background job that is not already captured by auto-instrumentation,
268-
it is recommended to apply the attribute `kind = SpanKind.SERVER` to the `@WithSpan` annotation
267+
If your method represents a background job that isn't already captured by auto-instrumentation,
268+
we recommend that you apply the attribute `kind = SpanKind.SERVER` to the `@WithSpan` annotation
269269
so that it will end up in the Application Insights `requests` table.
270270

271-
### Add spans using the OpenTelemetry API
271+
### Add spans by using the OpenTelemetry API
272272

273-
If the OpenTelemetry `@WithSpan` annotation above doesn't meet your needs,
274-
then you can add your spans using the OpenTelemetry API.
273+
If the preceding OpenTelemetry `@WithSpan` annotation doesn't meet your needs, you can add your spans by using the OpenTelemetry API.
275274

276275
> [!NOTE]
277276
> This feature is only in 3.2.0 and later.
@@ -286,7 +285,7 @@ then you can add your spans using the OpenTelemetry API.
286285
</dependency>
287286
```
288287

289-
1. Use the `GlobalOpenTelemetry` class to create a `Tracer`
288+
1. Use the `GlobalOpenTelemetry` class to create a `Tracer`:
290289

291290
```java
292291
import io.opentelemetry.api.GlobalOpenTelemetry;
@@ -310,7 +309,7 @@ then you can add your spans using the OpenTelemetry API.
310309

311310
### Add span events
312311

313-
You can use `opentelemetry-api` to create span events, which populate the traces table in Application Insights. The string passed in to `addEvent()` is saved to the _message_ field within the trace.
312+
You can use `opentelemetry-api` to create span events, which populate the `traces` table in Application Insights. The string passed in to `addEvent()` is saved to the `message` field within the trace.
314313

315314
> [!NOTE]
316315
> This feature is only in 3.2.0 and later.
@@ -337,7 +336,7 @@ You can use `opentelemetry-api` to create span events, which populate the traces
337336

338337
You can use `opentelemetry-api` to add attributes to spans. These attributes can include adding a custom business dimension to your telemetry. You can also use attributes to set optional fields in the Application Insights schema, such as User ID or Client IP.
339338

340-
Adding one or more span attributes populates the _customDimensions_ field in the requests, dependencies, traces, or exceptions table.
339+
Adding one or more span attributes populates the `customDimensions` field in the `requests`, `dependencies`, `traces`, or `exceptions` table.
341340

342341
> [!NOTE]
343342
> This feature is only in 3.2.0 and later.
@@ -379,7 +378,7 @@ You can use `opentelemetry-api` to update the status of a span and record except
379378
</dependency>
380379
```
381380

382-
1. Set status to error and record an exception in your code:
381+
1. Set status to `error` and record an exception in your code:
383382

384383
```java
385384
import io.opentelemetry.api.trace.Span;
@@ -392,10 +391,9 @@ You can use `opentelemetry-api` to update the status of a span and record except
392391

393392
#### Set the user ID
394393

395-
Populate the _user ID_ field in the requests, dependencies, or exceptions table.
394+
Populate the `user ID` field in the `requests`, `dependencies`, or `exceptions` table.
396395

397-
> [!IMPORTANT]
398-
> Consult applicable privacy laws before you set Authenticated User ID.
396+
Consult applicable privacy laws before you set the Authenticated User ID.
399397

400398
> [!NOTE]
401399
> This feature is only in 3.2.0 and later.
@@ -455,7 +453,7 @@ We currently support Micrometer, popular logging frameworks, and the Application
455453

456454
The following table represents currently supported custom telemetry types that you can enable to supplement the Java 3.x agent. To summarize:
457455

458-
- Custom metrics are supported through micrometer.
456+
- Custom metrics are supported through Micrometer.
459457
- Custom exceptions and traces are supported through logging frameworks.
460458
- Custom requests, dependencies, metrics, and exceptions are supported through the OpenTelemetry API.
461459
- The remaining telemetry types are supported through the [Application Insights Classic SDK](#send-custom-telemetry-by-using-the-application-insights-classic-sdk).
@@ -482,32 +480,31 @@ The following table represents currently supported custom telemetry types that y
482480
</dependency>
483481
```
484482

485-
2. Use the Micrometer [global registry](https://micrometer.io/docs/concepts#_global_registry) to create a meter:
483+
1. Use the Micrometer [global registry](https://micrometer.io/docs/concepts#_global_registry) to create a meter:
486484

487485
```java
488486
static final Counter counter = Metrics.counter("test.counter");
489487
```
490488

491-
3. Use the counter to record metrics:
489+
1. Use the counter to record metrics:
492490

493491
```java
494492
counter.increment();
495493
```
496494

497-
4. The metrics will be ingested into the
495+
1. The metrics will be ingested into the
498496
[customMetrics](/azure/azure-monitor/reference/tables/custommetrics) table, with tags captured in the
499497
`customDimensions` column. You can also view the metrics in the
500-
[Metrics explorer](../essentials/metrics-getting-started.md) under the "Log-based metrics" metric namespace.
498+
[metrics explorer](../essentials/metrics-getting-started.md) under the `Log-based metrics` metric namespace.
501499

502500
> [!NOTE]
503-
> Application Insights Java replaces all non-alphanumeric characters (except dashes) in the Micrometer metric name
504-
> with underscores, so the `test.counter` metric above will show up as `test_counter`.
501+
> Application Insights Java replaces all non-alphanumeric characters (except dashes) in the Micrometer metric name with underscores. As a result, the preceding `test.counter` metric will show up as `test_counter`.
505502

506503
### Send custom traces and exceptions by using your favorite logging framework
507504

508505
Logback, Log4j, and java.util.logging are auto-instrumented. Logging performed via these logging frameworks is autocollected as trace and exception telemetry.
509506

510-
By default, logging is only collected when that logging is performed at the INFO level or above.
507+
By default, logging is only collected when that logging is performed at the INFO level or higher.
511508
To change this level, see the [configuration options](./java-standalone-config.md#auto-collected-logging).
512509

513510
Structured logging (attaching custom dimensions to your logs) can be accomplished in these ways:
@@ -528,7 +525,7 @@ Structured logging (attaching custom dimensions to your logs) can be accomplishe
528525
</dependency>
529526
```
530527

531-
1. Create a TelemetryClient:
528+
1. Create a `TelemetryClient` instance:
532529

533530
```java
534531
static final TelemetryClient telemetryClient = new TelemetryClient();
@@ -605,7 +602,7 @@ To provide feedback:
605602

606603
- Fill out the OpenTelemetry community's [customer feedback survey](https://docs.google.com/forms/d/e/1FAIpQLScUt4reClurLi60xyHwGozgM9ZAz8pNAfBHhbTZ4gFWaaXIRQ/viewform).
607604
- Tell Microsoft about yourself by joining our [OpenTelemetry Early Adopter Community](https://aka.ms/AzMonOTel/).
608-
- Engage with other Azure Monitor users in the [Microsoft Tech Community](https://techcommunity.microsoft.com/t5/azure-monitor/bd-p/AzureMonitor).
605+
- Engage with other Azure Monitor users in the [Microsoft Tech Community](https://techcommunity.microsoft.com/t5/azure-monitor/bd-p/AzureMonitor).
609606
- Make a feature request at the [Azure Feedback Forum](https://feedback.azure.com/d365community/forum/8849e04d-1325-ec11-b6e6-000d3a4f09d0).
610607

611608
## Next steps

0 commit comments

Comments
 (0)