Skip to content

Commit bac9c94

Browse files
committed
Changing formatting
1 parent 12cc9b4 commit bac9c94

File tree

1 file changed

+61
-61
lines changed

1 file changed

+61
-61
lines changed

articles/azure-monitor/app/opentelemetry-add-modify.md

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,70 +1376,70 @@ using (var activity = activitySource.StartActivity("CustomActivity"))
13761376

13771377
**Use the OpenTelemetry annotation**
13781378

1379-
The simplest way to add your own spans is by using OpenTelemetry's `@WithSpan` annotation.
1380-
1381-
Spans populate the `requests` and `dependencies` tables in Application Insights.
1382-
1383-
1. Add `opentelemetry-instrumentation-annotations-1.32.0.jar` (or later) to your application:
1384-
1385-
```xml
1386-
<dependency>
1387-
<groupId>io.opentelemetry.instrumentation</groupId>
1388-
<artifactId>opentelemetry-instrumentation-annotations</artifactId>
1389-
<version>1.32.0</version>
1390-
</dependency>
1391-
```
1392-
1393-
1. Use the `@WithSpan` annotation to emit a span each time your method is executed:
1394-
1395-
```java
1396-
import io.opentelemetry.instrumentation.annotations.WithSpan;
1397-
1398-
@WithSpan(value = "your span name")
1399-
public void yourMethod() {
1400-
}
1401-
```
1402-
1403-
By default, the span ends up in the `dependencies` table with dependency type `InProc`.
1404-
1405-
For methods representing a background job not captured by autoinstrumentation, we recommend applying the attribute `kind = SpanKind.SERVER` to the `@WithSpan` annotation to ensure they appear in the Application Insights `requests` table.
1379+
The simplest way to add your own spans is by using OpenTelemetry's `@WithSpan` annotation.
1380+
1381+
Spans populate the `requests` and `dependencies` tables in Application Insights.
1382+
1383+
1. Add `opentelemetry-instrumentation-annotations-1.32.0.jar` (or later) to your application:
1384+
1385+
```xml
1386+
<dependency>
1387+
<groupId>io.opentelemetry.instrumentation</groupId>
1388+
<artifactId>opentelemetry-instrumentation-annotations</artifactId>
1389+
<version>1.32.0</version>
1390+
</dependency>
1391+
```
1392+
1393+
1. Use the `@WithSpan` annotation to emit a span each time your method is executed:
1394+
1395+
```java
1396+
import io.opentelemetry.instrumentation.annotations.WithSpan;
1397+
1398+
@WithSpan(value = "your span name")
1399+
public void yourMethod() {
1400+
}
1401+
```
1402+
1403+
By default, the span ends up in the `dependencies` table with dependency type `InProc`.
1404+
1405+
For methods representing a background job not captured by autoinstrumentation, we recommend applying the attribute `kind = SpanKind.SERVER` to the `@WithSpan` annotation to ensure they appear in the Application Insights `requests` table.
14061406

14071407
**Use the OpenTelemetry API**
14081408

1409-
If the preceding OpenTelemetry `@WithSpan` annotation doesn't meet your needs,
1410-
you can add your spans by using the OpenTelemetry API.
1411-
1412-
1. Add `opentelemetry-api-1.0.0.jar` (or later) to your application:
1413-
1414-
```xml
1415-
<dependency>
1416-
<groupId>io.opentelemetry</groupId>
1417-
<artifactId>opentelemetry-api</artifactId>
1418-
<version>1.0.0</version>
1419-
</dependency>
1420-
```
1421-
1422-
1. Use the `GlobalOpenTelemetry` class to create a `Tracer`:
1423-
1424-
```java
1425-
import io.opentelemetry.api.GlobalOpenTelemetry;
1426-
import io.opentelemetry.api.trace.Tracer;
1427-
1428-
static final Tracer tracer = GlobalOpenTelemetry.getTracer("com.example");
1429-
```
1430-
1431-
1. Create a span, make it current, and then end it:
1432-
1433-
```java
1434-
Span span = tracer.spanBuilder("my first span").startSpan();
1435-
try (Scope ignored = span.makeCurrent()) {
1436-
// do stuff within the context of this
1437-
} catch (Throwable t) {
1438-
span.recordException(t);
1439-
} finally {
1440-
span.end();
1441-
}
1442-
```
1409+
If the preceding OpenTelemetry `@WithSpan` annotation doesn't meet your needs,
1410+
you can add your spans by using the OpenTelemetry API.
1411+
1412+
1. Add `opentelemetry-api-1.0.0.jar` (or later) to your application:
1413+
1414+
```xml
1415+
<dependency>
1416+
<groupId>io.opentelemetry</groupId>
1417+
<artifactId>opentelemetry-api</artifactId>
1418+
<version>1.0.0</version>
1419+
</dependency>
1420+
```
1421+
1422+
1. Use the `GlobalOpenTelemetry` class to create a `Tracer`:
1423+
1424+
```java
1425+
import io.opentelemetry.api.GlobalOpenTelemetry;
1426+
import io.opentelemetry.api.trace.Tracer;
1427+
1428+
static final Tracer tracer = GlobalOpenTelemetry.getTracer("com.example");
1429+
```
1430+
1431+
1. Create a span, make it current, and then end it:
1432+
1433+
```java
1434+
Span span = tracer.spanBuilder("my first span").startSpan();
1435+
try (Scope ignored = span.makeCurrent()) {
1436+
// do stuff within the context of this
1437+
} catch (Throwable t) {
1438+
span.recordException(t);
1439+
} finally {
1440+
span.end();
1441+
}
1442+
```
14431443

14441444
#### [Java native](#tab/java-native)
14451445

0 commit comments

Comments
 (0)