From 71ca109ccd1b65a50c780a16f10a8914c94aa4a8 Mon Sep 17 00:00:00 2001 From: Jonathan Halliday Date: Mon, 28 Mar 2022 13:24:37 +0100 Subject: [PATCH] Add JDBC tracing info to the OpenTelemetry guide. (cherry picked from commit d08dac68b0e8bd042b26dc928725134adb507fe0) --- docs/src/main/asciidoc/opentelemetry.adoc | 32 +++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/docs/src/main/asciidoc/opentelemetry.adoc b/docs/src/main/asciidoc/opentelemetry.adoc index 9b5a68613c949..d8e4d18c948f0 100644 --- a/docs/src/main/asciidoc/opentelemetry.adoc +++ b/docs/src/main/asciidoc/opentelemetry.adoc @@ -204,6 +204,38 @@ Then visit the http://localhost:16686[Jaeger UI] to see the tracing information. Hit `CTRL+C` to stop the application. +=== JDBC + +The https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/jdbc/library[JDBC instrumentation] will add a span for each JDBC queries done by your application, to enable it, add the following dependency to your build file: + +[source,xml,role="primary asciidoc-tabs-target-sync-cli asciidoc-tabs-target-sync-maven"] +.pom.xml +---- + + io.opentelemetry.instrumentation + opentelemetry-jdbc + +---- + +[source,gradle,role="secondary asciidoc-tabs-target-sync-gradle"] +.build.gradle +---- +implementation("io.opentelemetry.instrumentation:opentelemetry-jdbc") +---- + +As it uses a dedicated JDBC driver, you must configure your datasource and Hibernate ORM to use it. + +[source, properties] +---- +quarkus.datasource.db-kind=postgresql +# add ':otel' to your database URL +quarkus.datasource.jdbc.url=jdbc:otel:postgresql://localhost:5432/mydatabase +# use the 'OpenTelemetryDriver' instead of the one for your database +quarkus.datasource.jdbc.driver=io.opentelemetry.instrumentation.jdbc.OpenTelemetryDriver +# configure Hibernate ORM dialect +quarkus.hibernate-orm.dialect=org.hibernate.dialect.PostgreSQLDialect +---- + == Additional configuration Some use cases will require custom configuration of OpenTelemetry. These sections will outline what is necessary to properly configure it.