-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document Java HttpClient instrumentation
The instrumentation has existed for longer, but it was recently moved to the micrometer-java11 module. This adds documentation for it with the new module. Resolves gh-4752
- Loading branch information
Showing
5 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../micrometer-java11/src/test/java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
= Java HttpClient instrumentation | ||
|
||
Since Java 11, an `HttpClient` is provided as part of the JDK. See https://openjdk.org/groups/net/httpclient/intro.html[this introduction] to it. Micrometer provides instrumentation of this via a `micrometer-java11` module. This module requires Java 11 or later. | ||
|
||
For Gradle, add the following implementation: | ||
|
||
[source,groovy,subs=+attributes] | ||
---- | ||
implementation 'io.micrometer:micrometer-java11' | ||
---- | ||
|
||
For Maven, add the following dependency: | ||
|
||
[source,xml,subs=+attributes] | ||
---- | ||
<dependency> | ||
<groupId>io.micrometer</groupId> | ||
<artifactId>micrometer-java11</artifactId> | ||
</dependency> | ||
---- | ||
|
||
Create an `HttpClient` as you normally would. For example: | ||
|
||
[source,java,subs=+attributes] | ||
---- | ||
include::{include-micrometer-java11-test}/io/micrometer/java11/instrument/binder/jdk/MicrometerHttpClientTests.java[tags=setupClient,indent=0] | ||
---- | ||
|
||
You can instrument this `HttpClient` as follows with an `ObservationRegistry`: | ||
|
||
[source,java,subs=+attributes] | ||
---- | ||
include::{include-micrometer-java11-test}/io/micrometer/java11/instrument/binder/jdk/MicrometerHttpClientTests.java[tags=observationInstrumentation,indent=0] | ||
---- | ||
|
||
Alternatively, if you are not using an `ObservationRegistry`, you can instrument with only a `MeterRegistry` as follows: | ||
|
||
[source,java,subs=+attributes] | ||
---- | ||
include::{include-micrometer-java11-test}/io/micrometer/java11/instrument/binder/jdk/MicrometerHttpClientTests.java[tags=meterRegistryInstrumentation,indent=0] | ||
---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters