Skip to content

Commit d019354

Browse files
committed
Add observation documentation generation
1 parent 25855cf commit d019354

File tree

6 files changed

+71
-45
lines changed

6 files changed

+71
-45
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
./mvnw -q -P '!setup-test-cluster' test-compile exec:java \
4+
-Dexec.mainClass=io.micrometer.docs.DocsGeneratorCommand \
5+
-Dexec.classpathScope="test" \
6+
-Dexec.args='src/main/java/com/rabbitmq/client/observation/micrometer .* target/micrometer-observation-docs'

src/main/java/com/rabbitmq/client/observation/micrometer/DefaultDeliverObservationConvention.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,14 @@
2525
* @since 5.19.0
2626
* @see DeliverObservationConvention
2727
*/
28-
public class DefaultDeliverObservationConvention implements DeliverObservationConvention {
28+
abstract class DefaultDeliverObservationConvention implements DeliverObservationConvention {
2929

30-
private final String name;
3130
private final String operation;
3231

33-
public DefaultDeliverObservationConvention(String name, String operation) {
34-
this.name = name;
32+
public DefaultDeliverObservationConvention(String operation) {
3533
this.operation = operation;
3634
}
3735

38-
// TODO: If the name is not fixed we won't be able to parse it to automatically document the name
39-
@Override
40-
public String getName() {
41-
return name;
42-
}
43-
4436
@Override
4537
public String getContextualName(DeliverContext context) {
4638
return source(context.getQueue()) + " " + operation;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright (c) 2023 VMware, Inc. or its affiliates. All rights reserved.
2+
//
3+
// This software, the RabbitMQ Java client library, is triple-licensed under the
4+
// Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2
5+
// ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see
6+
// LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL,
7+
// please see LICENSE-APACHE2.
8+
//
9+
// This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
10+
// either express or implied. See the LICENSE file for specific language governing
11+
// rights and limitations of this software.
12+
//
13+
// If you have any questions regarding licensing, please contact us at
14+
15+
package com.rabbitmq.client.observation.micrometer;
16+
17+
public class DefaultProcessObservationConvention extends DefaultDeliverObservationConvention {
18+
19+
public DefaultProcessObservationConvention(String operation) {
20+
super(operation);
21+
}
22+
23+
@Override
24+
public String getName() {
25+
return "rabbitmq.process";
26+
}
27+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright (c) 2023 VMware, Inc. or its affiliates. All rights reserved.
2+
//
3+
// This software, the RabbitMQ Java client library, is triple-licensed under the
4+
// Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2
5+
// ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see
6+
// LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL,
7+
// please see LICENSE-APACHE2.
8+
//
9+
// This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
10+
// either express or implied. See the LICENSE file for specific language governing
11+
// rights and limitations of this software.
12+
//
13+
// If you have any questions regarding licensing, please contact us at
14+
15+
package com.rabbitmq.client.observation.micrometer;
16+
17+
public class DefaultReceiveObservationConvention extends DefaultDeliverObservationConvention {
18+
19+
public DefaultReceiveObservationConvention(String operation) {
20+
super(operation);
21+
}
22+
23+
@Override
24+
public String getName() {
25+
return "rabbitmq.receive";
26+
}
27+
}

src/main/java/com/rabbitmq/client/observation/micrometer/MicrometerObservationCollectorBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ public class MicrometerObservationCollectorBuilder {
3131
new DefaultPublishObservationConvention();
3232
private DeliverObservationConvention customProcessObservationConvention;
3333
private DeliverObservationConvention defaultProcessObservationConvention =
34-
new DefaultDeliverObservationConvention("rabbitmq.process", "process");
34+
new DefaultProcessObservationConvention("process");
3535
private DeliverObservationConvention customReceiveObservationConvention;
3636
private DeliverObservationConvention defaultReceiveObservationConvention =
37-
new DefaultDeliverObservationConvention("rabbitmq.receive", "receive");
37+
new DefaultReceiveObservationConvention("receive");
3838

3939
public MicrometerObservationCollectorBuilder registry(ObservationRegistry registry) {
4040
this.registry = registry;

src/main/java/com/rabbitmq/client/observation/micrometer/RabbitMqObservationDocumentation.java

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
* @since 5.19.0
2626
*/
2727
public enum RabbitMqObservationDocumentation implements ObservationDocumentation {
28+
/** Observation for publishing a message. */
2829
PUBLISH_OBSERVATION {
2930

3031
@Override
@@ -39,12 +40,13 @@ public KeyName[] getLowCardinalityKeyNames() {
3940
}
4041
},
4142

43+
/** Observation for processing a message. */
4244
PROCESS_OBSERVATION {
4345

4446
@Override
4547
public Class<? extends ObservationConvention<? extends Observation.Context>>
4648
getDefaultConvention() {
47-
return DefaultDeliverObservationConvention.class;
49+
return DefaultProcessObservationConvention.class;
4850
}
4951

5052
@Override
@@ -53,12 +55,13 @@ public KeyName[] getLowCardinalityKeyNames() {
5355
}
5456
},
5557

58+
/** Observation for polling for a message with <code>basic.get</code>. */
5659
RECEIVE_OBSERVATION {
5760

5861
@Override
5962
public Class<? extends ObservationConvention<? extends Observation.Context>>
6063
getDefaultConvention() {
61-
return DefaultDeliverObservationConvention.class;
64+
return DefaultReceiveObservationConvention.class;
6265
}
6366

6467
@Override
@@ -67,37 +70,6 @@ public KeyName[] getLowCardinalityKeyNames() {
6770
}
6871
};
6972

70-
// SPAN NAME
71-
// <destination name> <operation name>
72-
// topic with spaces process
73-
// (anonymous) publish ((anonymous) being a stable identifier for an unnamed destination)
74-
// (anonymous) receive ((anonymous) being a stable identifier for an unnamed destination)
75-
76-
// LOW CARDINALITY
77-
// messaging.system = rabbitmq
78-
// messaging.operation = publish
79-
80-
// HIGH CARDINALITY
81-
82-
// messaging.rabbitmq.destination.routing_key
83-
// messaging.destination.anonymous
84-
// messaging.destination.name
85-
// messaging.destination.template
86-
// messaging.destination.temporary
87-
// messaging.batch.message_count
88-
// messaging.message.conversation_id
89-
// messaging.message.id
90-
// messaging.message.payload_compressed_size_bytes
91-
// messaging.message.payload_size_bytes
92-
93-
// net.peer.name
94-
// net.protocol.name
95-
// net.protocol.version
96-
// net.sock.family
97-
// net.sock.peer.addr
98-
// net.sock.peer.name
99-
// net.sock.peer.port
100-
10173
/** Low cardinality tags. */
10274
public enum LowCardinalityTags implements KeyName {
10375

@@ -119,6 +91,7 @@ public String asString() {
11991
}
12092
},
12193

94+
/** A string identifying the protocol (AMQP). */
12295
NET_PROTOCOL_NAME {
12396

12497
@Override
@@ -127,6 +100,7 @@ public String asString() {
127100
}
128101
},
129102

103+
/** A string identifying the protocol version (0.9.1). */
130104
NET_PROTOCOL_VERSION {
131105

132106
@Override

0 commit comments

Comments
 (0)