Add maven/gradle documentation to manual instrumentation instructions. (#1034)

* Add maven/gradle documentation to manual instrumentation instructions.

* Run :spotlessApply on the README

* Also add dependency description about the auto annotation
This commit is contained in:
John Bley 2020-08-17 11:33:01 -04:00 committed by GitHub
parent c9887ec048
commit 969a7c6c51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 45 additions and 1 deletions

View File

@ -257,7 +257,29 @@ only supports manual instrumentation using the `opentelemetry-api` version with
number as the Java agent you are using. Starting with 1.0.0, the Java agent will start supporting
multiple (1.0.0+) versions of `opentelemetry-api`.
You can use the OpenTelemetry `getTracer` or the `@WithSpan` annotation to
You'll need to add a dependency on the `opentelemetry-api` library to get started.
### Maven
```xml
<dependencies>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-api</artifactId>
<version>0.7.0</version>
</dependency>
</dependencies>
```
### Gradle
```groovy
dependencies {
compile('io.opentelemetry:opentelemetry-api:0.7.0')
}
```
Now you can use the OpenTelemetry `getTracer` or the `@WithSpan` annotation to
manually instrument your Java application.
### Configure the OpenTelemetry getTracer
@ -284,6 +306,28 @@ public class MyClass {
}
```
You'll also need to add a dependency for this annotation:
### Maven
```xml
<dependencies>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-extension-auto-annotations</artifactId>
<version>0.7.0</version>
</dependency>
</dependencies>
```
### Gradle
```groovy
dependencies {
compile('io.opentelemetry:opentelemetry-extension-auto-annotations:0.7.0')
}
```
Each time the application invokes the annotated method, it creates a span
that denote its duration and provides any thrown exceptions.