Skip to content

Commit daf2a04

Browse files
jaydelucalaurit
andauthored
Quarkus r2dbc and rediscala metadata (#15738)
Co-authored-by: Lauri Tulmin <ltulmin@splunk.com>
1 parent f509921 commit daf2a04

9 files changed

Lines changed: 244 additions & 4 deletions

File tree

docs/instrumentation-list.yaml

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10510,6 +10510,12 @@ libraries:
1051010510
type: LONG
1051110511
quarkus:
1051210512
- name: quarkus-resteasy-reactive
10513+
display_name: Quarkus RESTEasy Reactive
10514+
description: |
10515+
This instrumentation enriches HTTP server spans with route information for Quarkus RESTEasy Reactive, it does not emit any telemetry on its own.
10516+
library_link: https://quarkus.io/guides/resteasy-reactive/
10517+
features:
10518+
- HTTP_ROUTE
1051310519
source_path: instrumentation/quarkus-resteasy-reactive
1051410520
scope:
1051510521
name: io.opentelemetry.quarkus-resteasy-reactive
@@ -10528,6 +10534,13 @@ libraries:
1052810534
- org.quartz-scheduler:quartz:2.0.0
1052910535
r2dbc:
1053010536
- name: r2dbc-1.0
10537+
display_name: R2DBC
10538+
description: |
10539+
This instrumentation enables database client spans and database client metrics for R2DBC (Reactive Relational Database Connectivity).
10540+
semantic_conventions:
10541+
- DATABASE_CLIENT_SPANS
10542+
- DATABASE_CLIENT_METRICS
10543+
library_link: https://r2dbc.io/
1053110544
source_path: instrumentation/r2dbc-1.0
1053210545
scope:
1053310546
name: io.opentelemetry.r2dbc-1.0
@@ -10536,6 +10549,87 @@ libraries:
1053610549
- io.r2dbc:r2dbc-spi:[1.0.0.RELEASE,)
1053710550
library:
1053810551
- io.r2dbc:r2dbc-spi:1.0.0.RELEASE
10552+
configurations:
10553+
- name: otel.instrumentation.r2dbc.statement-sanitizer.enabled
10554+
description: |
10555+
Enables statement sanitization for database queries. Takes precedence over otel.instrumentation.common.db-statement-sanitizer.enabled.
10556+
type: boolean
10557+
default: true
10558+
- name: otel.instrumentation.common.db-statement-sanitizer.enabled
10559+
description: Enables statement sanitization for database queries.
10560+
type: boolean
10561+
default: true
10562+
- name: otel.instrumentation.r2dbc.experimental.sqlcommenter.enabled
10563+
description: |
10564+
Enables augmenting queries with a comment containing the tracing information. See [sqlcommenter](https://google.github.io/sqlcommenter/) for more info. WARNING: augmenting queries with tracing context will make query texts unique, which may have adverse impact on database performance.
10565+
type: boolean
10566+
default: false
10567+
- name: otel.instrumentation.common.peer-service-mapping
10568+
description: Used to specify a mapping from host names or IP addresses to peer
10569+
services.
10570+
type: map
10571+
default: ''
10572+
telemetry:
10573+
- when: default
10574+
spans:
10575+
- span_kind: CLIENT
10576+
attributes:
10577+
- name: db.connection_string
10578+
type: STRING
10579+
- name: db.name
10580+
type: STRING
10581+
- name: db.operation
10582+
type: STRING
10583+
- name: db.sql.table
10584+
type: STRING
10585+
- name: db.statement
10586+
type: STRING
10587+
- name: db.system
10588+
type: STRING
10589+
- name: db.user
10590+
type: STRING
10591+
- name: peer.service
10592+
type: STRING
10593+
- name: server.address
10594+
type: STRING
10595+
- name: server.port
10596+
type: LONG
10597+
- when: otel.semconv-stability.opt-in=database
10598+
metrics:
10599+
- name: db.client.operation.duration
10600+
description: Duration of database client operations.
10601+
type: HISTOGRAM
10602+
unit: s
10603+
attributes:
10604+
- name: db.namespace
10605+
type: STRING
10606+
- name: db.operation.name
10607+
type: STRING
10608+
- name: db.system.name
10609+
type: STRING
10610+
- name: server.address
10611+
type: STRING
10612+
- name: server.port
10613+
type: LONG
10614+
spans:
10615+
- span_kind: CLIENT
10616+
attributes:
10617+
- name: db.collection.name
10618+
type: STRING
10619+
- name: db.namespace
10620+
type: STRING
10621+
- name: db.operation.name
10622+
type: STRING
10623+
- name: db.query.text
10624+
type: STRING
10625+
- name: db.system.name
10626+
type: STRING
10627+
- name: peer.service
10628+
type: STRING
10629+
- name: server.address
10630+
type: STRING
10631+
- name: server.port
10632+
type: LONG
1053910633
rabbitmq:
1054010634
- name: rabbitmq-2.7
1054110635
display_name: RabbitMQ
@@ -10781,6 +10875,13 @@ libraries:
1078110875
type: STRING
1078210876
rediscala:
1078310877
- name: rediscala-1.8
10878+
display_name: Rediscala
10879+
description: |
10880+
This instrumentation enables database client spans and database client metrics for Rediscala.
10881+
semantic_conventions:
10882+
- DATABASE_CLIENT_SPANS
10883+
- DATABASE_CLIENT_METRICS
10884+
library_link: https://github.com/rediscala/rediscala
1078410885
source_path: instrumentation/rediscala-1.8
1078510886
scope:
1078610887
name: io.opentelemetry.rediscala-1.8
@@ -10793,6 +10894,33 @@ libraries:
1079310894
- io.github.rediscala:rediscala_2.13:[1.10.0,)
1079410895
- com.github.etaty:rediscala_2.13:[1.9.0,)
1079510896
- com.github.Ma27:rediscala_2.12:[1.8.1,)
10897+
telemetry:
10898+
- when: default
10899+
spans:
10900+
- span_kind: CLIENT
10901+
attributes:
10902+
- name: db.operation
10903+
type: STRING
10904+
- name: db.system
10905+
type: STRING
10906+
- when: otel.semconv-stability.opt-in=database
10907+
metrics:
10908+
- name: db.client.operation.duration
10909+
description: Duration of database client operations.
10910+
type: HISTOGRAM
10911+
unit: s
10912+
attributes:
10913+
- name: db.operation.name
10914+
type: STRING
10915+
- name: db.system.name
10916+
type: STRING
10917+
spans:
10918+
- span_kind: CLIENT
10919+
attributes:
10920+
- name: db.operation.name
10921+
type: STRING
10922+
- name: db.system.name
10923+
type: STRING
1079610924
redisson:
1079710925
- name: redisson-3.0
1079810926
source_path: instrumentation/redisson/redisson-3.0

instrumentation-docs/instrumentations.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,14 @@ readonly INSTRUMENTATIONS=(
202202
"powerjob-4.0:javaagent:testExperimental"
203203
"pulsar:pulsar-2.8:javaagent:test"
204204
"pulsar:pulsar-2.8:javaagent:testExperimental"
205+
"r2dbc-1.0:javaagent:test"
206+
"r2dbc-1.0:javaagent:testStableSemconv"
205207
"rabbitmq-2.7:javaagent:test"
206208
"rabbitmq-2.7:javaagent:testExperimental"
207209
"reactor:reactor-netty:reactor-netty-0.9:javaagent:test"
208210
"reactor:reactor-netty:reactor-netty-1.0:javaagent:test"
211+
"rediscala-1.8:javaagent:test"
212+
"rediscala-1.8:javaagent:testStableSemconv"
209213
"spring:spring-batch-3.0:javaagent:test"
210214
"spring:spring-data:spring-data-1.8:javaagent:test"
211215
"spring:spring-integration-4.1:javaagent:test"
@@ -222,14 +226,11 @@ readonly INSTRUMENTATIONS=(
222226
"spring:spring-web:spring-web-3.1:library:test"
223227
"spring:spring-web:spring-web-6.0:javaagent:test"
224228
"spring:spring-webflux:spring-webflux-5.0:javaagent:test"
225-
"spring:spring-webflux:spring-webflux-5.0:javaagent:test"
226229
"spring:spring-webflux:spring-webflux-5.3:library:test"
227230
"spring:spring-webmvc:spring-webmvc-3.1:javaagent:test"
228231
"spring:spring-webmvc:spring-webmvc-3.1:javaagent:testExperimental"
229-
"spring:spring-webmvc:spring-webmvc-3.1:javaagent:testExperimental"
230232
"spring:spring-webmvc:spring-webmvc-5.3:library:test"
231233
"spring:spring-webmvc:spring-webmvc-6.0:javaagent:test"
232-
"spring:spring-webmvc:spring-webmvc-6.0:javaagent:test"
233234
"spring:spring-webmvc:spring-webmvc-6.0:javaagent:testExperimental"
234235
"tomcat:tomcat-jdbc:javaagent:test"
235236
"tomcat:tomcat-jdbc:javaagent:testStableSemconv"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
display_name: Quarkus RESTEasy Reactive
2+
description: >
3+
This instrumentation enriches HTTP server spans with route information for Quarkus
4+
RESTEasy Reactive, it does not emit any telemetry on its own.
5+
features:
6+
- HTTP_ROUTE
7+
library_link: https://quarkus.io/guides/resteasy-reactive/

instrumentation/r2dbc-1.0/javaagent/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@ dependencies {
3333
tasks {
3434
withType<Test>().configureEach {
3535
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
36+
systemProperty("collectMetadata", findProperty("collectMetadata")?.toString() ?: "false")
3637
}
3738

3839
val testStableSemconv by registering(Test::class) {
3940
testClassesDirs = sourceSets.test.get().output.classesDirs
4041
classpath = sourceSets.test.get().runtimeClasspath
4142
jvmArgs("-Dotel.semconv-stability.opt-in=database")
43+
systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database")
4244
}
4345

4446
check {
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
display_name: R2DBC
2+
description: >
3+
This instrumentation enables database client spans and database client metrics for R2DBC
4+
(Reactive Relational Database Connectivity).
5+
semantic_conventions:
6+
- DATABASE_CLIENT_SPANS
7+
- DATABASE_CLIENT_METRICS
8+
library_link: https://r2dbc.io/
9+
configurations:
10+
- name: otel.instrumentation.r2dbc.statement-sanitizer.enabled
11+
description: >
12+
Enables statement sanitization for database queries. Takes precedence over
13+
otel.instrumentation.common.db-statement-sanitizer.enabled.
14+
type: boolean
15+
default: true
16+
- name: otel.instrumentation.common.db-statement-sanitizer.enabled
17+
description: Enables statement sanitization for database queries.
18+
type: boolean
19+
default: true
20+
- name: otel.instrumentation.r2dbc.experimental.sqlcommenter.enabled
21+
description: >
22+
Enables augmenting queries with a comment containing the tracing information. See
23+
[sqlcommenter](https://google.github.io/sqlcommenter/) for more info. WARNING: augmenting
24+
queries with tracing context will make query texts unique, which may have adverse impact on
25+
database performance.
26+
type: boolean
27+
default: false
28+
- name: otel.instrumentation.common.peer-service-mapping
29+
description: Used to specify a mapping from host names or IP addresses to peer services.
30+
type: map
31+
default: ""

instrumentation/r2dbc-1.0/testing/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/AbstractR2dbcStatementTest.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
package io.opentelemetry.instrumentation.r2dbc.v1_0;
77

88
import static io.opentelemetry.instrumentation.api.internal.SemconvStability.emitStableDatabaseSemconv;
9+
import static io.opentelemetry.instrumentation.testing.junit.db.DbClientMetricsTestUtil.assertDurationMetric;
910
import static io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil.maybeStable;
1011
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
12+
import static io.opentelemetry.semconv.DbAttributes.DB_NAMESPACE;
13+
import static io.opentelemetry.semconv.DbAttributes.DB_OPERATION_NAME;
1114
import static io.opentelemetry.semconv.ServerAttributes.SERVER_ADDRESS;
1215
import static io.opentelemetry.semconv.ServerAttributes.SERVER_PORT;
1316
import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_CONNECTION_STRING;
@@ -16,6 +19,7 @@
1619
import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_SQL_TABLE;
1720
import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_STATEMENT;
1821
import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_SYSTEM;
22+
import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_SYSTEM_NAME;
1923
import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_USER;
2024
import static io.opentelemetry.semconv.incubating.PeerIncubatingAttributes.PEER_SERVICE;
2125
import static io.r2dbc.spi.ConnectionFactoryOptions.CONNECT_TIMEOUT;
@@ -38,6 +42,7 @@
3842
import java.util.Map;
3943
import java.util.stream.Stream;
4044
import org.junit.jupiter.api.AfterAll;
45+
import org.junit.jupiter.api.Test;
4146
import org.junit.jupiter.api.TestInstance;
4247
import org.junit.jupiter.params.ParameterizedTest;
4348
import org.junit.jupiter.params.provider.Arguments;
@@ -238,6 +243,41 @@ private static Stream<Arguments> provideParameters() {
238243
"SELECT")))));
239244
}
240245

246+
@Test
247+
@SuppressWarnings("deprecation") // uses deprecated semconv
248+
void testMetrics() {
249+
DbSystemProps props = SYSTEMS.get(MARIADB.system);
250+
startContainer(props);
251+
ConnectionFactory connectionFactory =
252+
createProxyConnectionFactory(
253+
ConnectionFactoryOptions.builder()
254+
.option(DRIVER, props.system)
255+
.option(HOST, container.getHost())
256+
.option(PORT, port)
257+
.option(USER, USER_DB)
258+
.option(PASSWORD, PW_DB)
259+
.option(DATABASE, DB)
260+
.option(CONNECT_TIMEOUT, Duration.ofSeconds(30))
261+
.build());
262+
263+
Mono.from(connectionFactory.create())
264+
.flatMapMany(
265+
connection ->
266+
Mono.from(connection.createStatement("SELECT 3").execute())
267+
.flatMapMany(result -> result.map((row, metadata) -> ""))
268+
.concatWith(Mono.from(connection.close()).cast(String.class)))
269+
.blockLast(Duration.ofMinutes(1));
270+
271+
assertDurationMetric(
272+
getTesting(),
273+
"io.opentelemetry.r2dbc-1.0",
274+
DB_SYSTEM_NAME,
275+
DB_NAMESPACE,
276+
DB_OPERATION_NAME,
277+
SERVER_ADDRESS,
278+
SERVER_PORT);
279+
}
280+
241281
private static class Parameter {
242282

243283
final String system;

instrumentation/rediscala-1.8/javaagent/build.gradle.kts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,23 @@ dependencies {
6161
}
6262

6363
tasks {
64-
test {
64+
withType<Test>().configureEach {
65+
systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean)
6566
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
67+
68+
systemProperty("collectMetadata", findProperty("collectMetadata")?.toString() ?: "false")
69+
}
70+
71+
val testStableSemconv by registering(Test::class) {
72+
testClassesDirs = sourceSets.test.get().output.classesDirs
73+
classpath = sourceSets.test.get().runtimeClasspath
74+
75+
jvmArgs("-Dotel.semconv-stability.opt-in=database")
76+
systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database")
77+
}
78+
79+
check {
80+
dependsOn(testStableSemconv)
6681
}
6782

6883
if (findProperty("denyUnsafe") as Boolean) {

instrumentation/rediscala-1.8/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaClientTest.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ package rediscala
88
import io.opentelemetry.api.trace.SpanKind.CLIENT
99
import io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil
1010
import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension
11+
import io.opentelemetry.instrumentation.testing.junit.db.DbClientMetricsTestUtil.assertDurationMetric
1112
import io.opentelemetry.instrumentation.testing.util.ThrowingSupplier
1213
import io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo
1314
import io.opentelemetry.sdk.testing.assertj.{SpanDataAssert, TraceAssert}
1415
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_OPERATION
1516
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_SYSTEM
1617
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DbSystemIncubatingValues.REDIS
18+
import io.opentelemetry.semconv.DbAttributes.{DB_OPERATION_NAME, DB_SYSTEM_NAME}
1719
import org.assertj.core.api.Assertions.assertThat
1820
import org.junit.jupiter.api.{AfterAll, BeforeAll, Test, TestInstance}
1921
import org.junit.jupiter.api.extension.RegisterExtension
@@ -127,6 +129,13 @@ class RediscalaClientTest {
127129
}
128130
)
129131
})
132+
133+
assertDurationMetric(
134+
testing,
135+
"io.opentelemetry.rediscala-1.8",
136+
DB_SYSTEM_NAME,
137+
DB_OPERATION_NAME
138+
)
130139
}
131140

132141
@Test def testGetCommand(): Unit = {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
display_name: Rediscala
2+
description: >
3+
This instrumentation enables database client spans and database client metrics for Rediscala.
4+
semantic_conventions:
5+
- DATABASE_CLIENT_SPANS
6+
- DATABASE_CLIENT_METRICS
7+
library_link: https://github.com/rediscala/rediscala

0 commit comments

Comments
 (0)