Skip to content

Commit f509921

Browse files
authored
RabbitMQ metadata (#15748)
1 parent 4c717cb commit f509921

7 files changed

Lines changed: 397 additions & 371 deletions

File tree

docs/instrumentation-list.yaml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10538,12 +10538,142 @@ libraries:
1053810538
- io.r2dbc:r2dbc-spi:1.0.0.RELEASE
1053910539
rabbitmq:
1054010540
- name: rabbitmq-2.7
10541+
display_name: RabbitMQ
10542+
description: This instrumentation enables messaging spans for RabbitMQ message
10543+
producers and consumers.
10544+
semantic_conventions:
10545+
- MESSAGING_SPANS
10546+
library_link: https://www.rabbitmq.com/client-libraries/java-api-guide
1054110547
source_path: instrumentation/rabbitmq-2.7
1054210548
scope:
1054310549
name: io.opentelemetry.rabbitmq-2.7
1054410550
target_versions:
1054510551
javaagent:
1054610552
- com.rabbitmq:amqp-client:[2.7.0,)
10553+
configurations:
10554+
- name: otel.instrumentation.rabbitmq.experimental-span-attributes
10555+
description: |
10556+
Enables experimental span attributes `rabbitmq.command`, `rabbitmq.delivery_mode`, `rabbitmq.queue`, and `rabbitmq.record.queue_time_ms`.
10557+
type: boolean
10558+
default: false
10559+
- name: otel.instrumentation.common.messaging.experimental.receive-telemetry.enabled
10560+
description: |
10561+
Enables the creation of consumer spans on messaging receive operations. These spans will measure the time between receiving a message and the consumer processing that message.
10562+
type: boolean
10563+
default: false
10564+
- name: otel.instrumentation.common.messaging.capture-headers
10565+
description: List of messaging headers to capture.
10566+
type: list
10567+
default: ''
10568+
telemetry:
10569+
- when: default
10570+
spans:
10571+
- span_kind: CLIENT
10572+
attributes:
10573+
- name: messaging.system
10574+
type: STRING
10575+
- name: network.peer.address
10576+
type: STRING
10577+
- name: network.peer.port
10578+
type: LONG
10579+
- name: network.type
10580+
type: STRING
10581+
- span_kind: CONSUMER
10582+
attributes:
10583+
- name: messaging.destination.name
10584+
type: STRING
10585+
- name: messaging.message.body.size
10586+
type: LONG
10587+
- name: messaging.operation
10588+
type: STRING
10589+
- name: messaging.rabbitmq.destination.routing_key
10590+
type: STRING
10591+
- name: messaging.system
10592+
type: STRING
10593+
- name: network.peer.address
10594+
type: STRING
10595+
- name: network.peer.port
10596+
type: LONG
10597+
- name: network.type
10598+
type: STRING
10599+
- span_kind: PRODUCER
10600+
attributes:
10601+
- name: messaging.destination.name
10602+
type: STRING
10603+
- name: messaging.message.body.size
10604+
type: LONG
10605+
- name: messaging.operation
10606+
type: STRING
10607+
- name: messaging.rabbitmq.destination.routing_key
10608+
type: STRING
10609+
- name: messaging.system
10610+
type: STRING
10611+
- name: network.peer.address
10612+
type: STRING
10613+
- name: network.peer.port
10614+
type: LONG
10615+
- name: network.type
10616+
type: STRING
10617+
- when: otel.instrumentation.rabbitmq.experimental-span-attributes=true
10618+
spans:
10619+
- span_kind: CLIENT
10620+
attributes:
10621+
- name: messaging.system
10622+
type: STRING
10623+
- name: network.peer.address
10624+
type: STRING
10625+
- name: network.peer.port
10626+
type: LONG
10627+
- name: network.type
10628+
type: STRING
10629+
- name: rabbitmq.command
10630+
type: STRING
10631+
- span_kind: CONSUMER
10632+
attributes:
10633+
- name: messaging.destination.name
10634+
type: STRING
10635+
- name: messaging.message.body.size
10636+
type: LONG
10637+
- name: messaging.operation
10638+
type: STRING
10639+
- name: messaging.rabbitmq.destination.routing_key
10640+
type: STRING
10641+
- name: messaging.system
10642+
type: STRING
10643+
- name: network.peer.address
10644+
type: STRING
10645+
- name: network.peer.port
10646+
type: LONG
10647+
- name: network.type
10648+
type: STRING
10649+
- name: rabbitmq.command
10650+
type: STRING
10651+
- name: rabbitmq.queue
10652+
type: STRING
10653+
- name: rabbitmq.record.queue_time_ms
10654+
type: LONG
10655+
- span_kind: PRODUCER
10656+
attributes:
10657+
- name: messaging.destination.name
10658+
type: STRING
10659+
- name: messaging.message.body.size
10660+
type: LONG
10661+
- name: messaging.operation
10662+
type: STRING
10663+
- name: messaging.rabbitmq.destination.routing_key
10664+
type: STRING
10665+
- name: messaging.system
10666+
type: STRING
10667+
- name: network.peer.address
10668+
type: STRING
10669+
- name: network.peer.port
10670+
type: LONG
10671+
- name: network.type
10672+
type: STRING
10673+
- name: rabbitmq.command
10674+
type: STRING
10675+
- name: rabbitmq.delivery_mode
10676+
type: LONG
1054710677
ratpack:
1054810678
- name: ratpack-1.4
1054910679
source_path: instrumentation/ratpack/ratpack-1.4

instrumentation-docs/instrumentations.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ readonly INSTRUMENTATIONS=(
202202
"powerjob-4.0:javaagent:testExperimental"
203203
"pulsar:pulsar-2.8:javaagent:test"
204204
"pulsar:pulsar-2.8:javaagent:testExperimental"
205+
"rabbitmq-2.7:javaagent:test"
206+
"rabbitmq-2.7:javaagent:testExperimental"
205207
"reactor:reactor-netty:reactor-netty-0.9:javaagent:test"
206208
"reactor:reactor-netty:reactor-netty-1.0:javaagent:test"
207209
"spring:spring-batch-3.0:javaagent:test"

instrumentation/rabbitmq-2.7/javaagent/build.gradle.kts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,25 @@ dependencies {
2626
testLibrary("io.projectreactor.rabbitmq:reactor-rabbitmq:1.0.0.RELEASE")
2727
}
2828

29-
tasks.withType<Test>().configureEach {
30-
// TODO run tests both with and without experimental span attributes
31-
jvmArgs("-Dotel.instrumentation.rabbitmq.experimental-span-attributes=true")
32-
jvmArgs("-Dotel.instrumentation.messaging.experimental.receive-telemetry.enabled=true")
29+
tasks {
30+
withType<Test>().configureEach {
31+
systemProperty("collectMetadata", findProperty("collectMetadata")?.toString() ?: "false")
32+
systemProperty("testLatestDeps", findProperty("testLatestDeps") ?: "false")
3333

34-
systemProperty("testLatestDeps", findProperty("testLatestDeps") ?: "false")
34+
jvmArgs("-Dotel.instrumentation.messaging.experimental.receive-telemetry.enabled=true")
3535

36-
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
36+
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
37+
}
38+
39+
val testExperimental by registering(Test::class) {
40+
testClassesDirs = sourceSets.test.get().output.classesDirs
41+
classpath = sourceSets.test.get().runtimeClasspath
42+
43+
jvmArgs("-Dotel.instrumentation.rabbitmq.experimental-span-attributes=true")
44+
systemProperty("metadataConfig", "otel.instrumentation.rabbitmq.experimental-span-attributes=true")
45+
}
46+
47+
check {
48+
dependsOn(testExperimental)
49+
}
3750
}

instrumentation/rabbitmq-2.7/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/AbstractRabbitMqTest.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.net.InetAddress;
1010
import java.net.UnknownHostException;
1111
import java.time.Duration;
12+
import javax.annotation.Nullable;
1213
import org.junit.jupiter.api.AfterAll;
1314
import org.junit.jupiter.api.BeforeAll;
1415
import org.slf4j.Logger;
@@ -17,7 +18,15 @@
1718
import org.testcontainers.containers.output.Slf4jLogConsumer;
1819
import org.testcontainers.containers.wait.strategy.Wait;
1920

20-
public abstract class AbstractRabbitMqTest {
21+
abstract class AbstractRabbitMqTest {
22+
protected static final boolean EXPERIMENTAL_ATTRIBUTES_ENABLED =
23+
Boolean.getBoolean("otel.instrumentation.rabbitmq.experimental-span-attributes");
24+
25+
@Nullable
26+
static <T> T experimental(T value) {
27+
return EXPERIMENTAL_ATTRIBUTES_ENABLED ? value : null;
28+
}
29+
2130
private static final Logger logger =
2231
LoggerFactory.getLogger("io.opentelemetry.testing.rabbitmq-container");
2332

0 commit comments

Comments
 (0)