Skip to content

Commit 7485adc

Browse files
committed
Add Micrometer Observation generated documentation
References #379
1 parent cedff4d commit 7485adc

File tree

6 files changed

+58
-11
lines changed

6 files changed

+58
-11
lines changed

ci/publish-documentation-to-github-pages.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22

33
. $(pwd)/release-versions.txt
44

5+
./mvnw clean test-compile exec:java \
6+
-Dexec.mainClass=io.micrometer.docs.DocsGeneratorCommand \
7+
-Dexec.classpathScope="test" \
8+
-Dexec.args='src/main/java/com/rabbitmq/stream/observation/micrometer .* target/micrometer-observation-docs'
9+
510
MESSAGE=$(git log -1 --pretty=%B)
6-
./mvnw clean buildnumber:create pre-site --no-transfer-progress
11+
./mvnw buildnumber:create pre-site --no-transfer-progress
712

813
./mvnw javadoc:javadoc -Dmaven.javadoc.skip=false --no-transfer-progress
914

pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
<vavr.version>0.10.4</vavr.version>
7676
<paho.version>1.2.5</paho.version>
7777
<micrometer-tracing-test.version>1.1.3</micrometer-tracing-test.version>
78+
<micrometer-docs-generator.version>1.0.2</micrometer-docs-generator.version>
7879
<maven.compiler.plugin.version>3.11.0</maven.compiler.plugin.version>
7980
<maven-surefire-plugin.version>3.1.2</maven-surefire-plugin.version>
8081
<spring-boot-maven-plugin.version>2.7.6</spring-boot-maven-plugin.version>
@@ -320,6 +321,13 @@
320321
<scope>test</scope>
321322
</dependency>
322323

324+
<dependency>
325+
<groupId>io.micrometer</groupId>
326+
<artifactId>micrometer-docs-generator</artifactId>
327+
<version>${micrometer-docs-generator.version}</version>
328+
<scope>test</scope>
329+
</dependency>
330+
323331
<dependency>
324332
<groupId>org.openjdk.jmh</groupId>
325333
<artifactId>jmh-core</artifactId>
@@ -468,6 +476,7 @@
468476
<idseparator>-</idseparator>
469477
<source-highlighter>coderay</source-highlighter>
470478
<test-examples>../../test/java/com/rabbitmq/stream/docs</test-examples>
479+
<build-directory>${project.build.directory}</build-directory>
471480
</attributes>
472481

473482
</configuration>

src/docs/asciidoc/appendixes.adoc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
ifndef::build-directory[:build-directory: ../../../target]
2+
:test-examples: ../../test/java/com/rabbitmq/stream/docs
3+
4+
[appendix]
5+
== Micrometer Observation
6+
7+
It is possible to use https://micrometer.io/docs/observation[Micrometer Observation] to instrument publishing and consuming in the stream Java client.
8+
Micrometer Observation provides https://spring.io/blog/2022/10/12/observability-with-spring-boot-3[metrics, tracing, and log correlation with one single API].
9+
10+
The following snippet shows how to create and set up the Micrometer `ObservationCollector` from an existing `ObservationRegistry`:
11+
12+
.Configuring Micrometer Observation
13+
[source,java,indent=0]
14+
--------
15+
include::{test-examples}/EnvironmentUsage.java[tag=micrometer-observation]
16+
--------
17+
<1> Create the Micrometer `ObservationCollector`
18+
19+
The next sections document the conventions, spans, and metrics made available by the instrumentation.
20+
They are automatically generated from the source code with the https://github.com/micrometer-metrics/micrometer-docs-generator[Micrometer documentation generator].
21+
22+
include::{build-directory}/micrometer-observation-docs/_conventions.adoc[]
23+
include::{build-directory}/micrometer-observation-docs/_spans.adoc[]
24+
include::{build-directory}/micrometer-observation-docs/_metrics.adoc[]

src/docs/asciidoc/index.adoc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
= RabbitMQ Stream Java Client
22
:revnumber: {project-version}
33
:revremark: ({build-number})
4+
:appendix-caption: Appendix
45
ifndef::imagesdir[:imagesdir: images]
56
ifndef::sourcedir[:sourcedir: ../../main/java]
67
:source-highlighter: prettify
@@ -28,4 +29,6 @@ include::advanced-topics.adoc[]
2829

2930
include::building.adoc[]
3031

31-
include::performance-tool.adoc[]
32+
include::performance-tool.adoc[]
33+
34+
include::appendixes.adoc[]

src/main/java/com/rabbitmq/stream/observation/micrometer/StreamObservationDocumentation.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public String asString() {
7676
}
7777
},
7878

79-
/** A string identifying the protocol (AMQP). */
79+
/** A string identifying the protocol (RabbitMQ Stream). */
8080
NET_PROTOCOL_NAME {
8181

8282
@Override
@@ -85,7 +85,7 @@ public String asString() {
8585
}
8686
},
8787

88-
/** A string identifying the protocol version (0.9.1). */
88+
/** A string identifying the protocol version (1.0). */
8989
NET_PROTOCOL_VERSION {
9090

9191
@Override

src/test/java/com/rabbitmq/stream/docs/EnvironmentUsage.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@
1414

1515
package com.rabbitmq.stream.docs;
1616

17-
import com.rabbitmq.stream.Address;
18-
import com.rabbitmq.stream.ByteCapacity;
19-
import com.rabbitmq.stream.Environment;
17+
import com.rabbitmq.stream.*;
2018

21-
import com.rabbitmq.stream.EnvironmentBuilder;
22-
import io.netty.channel.Channel;
19+
import com.rabbitmq.stream.observation.micrometer.MicrometerObservationCollectorBuilder;
20+
import io.micrometer.observation.ObservationRegistry;
2321
import io.netty.channel.EventLoopGroup;
2422
import io.netty.channel.epoll.EpollEventLoopGroup;
2523
import io.netty.channel.epoll.EpollSocketChannel;
@@ -30,8 +28,6 @@
3028
import java.security.cert.X509Certificate;
3129
import java.time.Duration;
3230
import java.util.Arrays;
33-
import java.util.Set;
34-
import java.util.concurrent.ConcurrentHashMap;
3531

3632
public class EnvironmentUsage {
3733

@@ -153,4 +149,14 @@ void nativeEpoll() {
153149
// end::native-epoll[]
154150
}
155151

152+
void micrometerObservation() {
153+
ObservationRegistry observationRegistry = ObservationRegistry.NOOP;
154+
// tag::micrometer-observation[]
155+
Environment environment = Environment.builder()
156+
.observationCollector(new MicrometerObservationCollectorBuilder() // <1>
157+
.registry(observationRegistry).build()) // <1>
158+
.build();
159+
// end::micrometer-observation[]
160+
}
161+
156162
}

0 commit comments

Comments
 (0)