问题
How do I enable Jaeger jdbc
tracing in Quarkus
? I've followed the Quarkus
guides for Opentracing
and didn't see any info about this.
I'm using Quarkus
v0.21.2 with the following extensions:
-quarkus-smallrye-opentracing
-quarkus-resteasy
-quarkus-resteasy-jackson
-quarkus-hibernate-orm-panache
-quarkus-jdbc-postgresql
-quarkus-smallrye-openapi
And my code is just a basic Rest endpoint which calls my entity's Panache CRUD operation.
Any help is appreciated.
I've tried the following and it didn't work:
- added @Traced to my entity
- changed quarkus.jaeger.sampler-type=const into quarkus.jaeger.sampler-type=remote
What I expect in Jaeger
is, 2 spans for 1 trace, one for the REST call and another one for the JDBC
call.
But what I see is just 1 span for the REST call.
回答1:
You can use opentracing java-jdbc extension it will works in Quarkus (I didn't test the native mode).
You need to use the version 0.0.12 as the latest one is based on Opentracing 0.33 but Quarkus use the version 0.31.
Add the dependency to your pom.xml:
<dependency> <groupId>io.opentracing.contrib</groupId> <artifactId>opentracing-jdbc</artifactId> <version>0.0.12</version> </dependency>
Update your application.properties to use the opentracing-jdbc driver, the following are for a Postgres database:
quarkus.datasource.url = jdbc:tracing:postgresql://localhost:5433/mydatabase quarkus.datasource.driver = io.opentracing.contrib.jdbc.TracingDriver quarkus.hibernate-orm.dialect = org.hibernate.dialect.PostgreSQLDialect
You will then saw the SQL queries in Jaeger as spans.
来源:https://stackoverflow.com/questions/57854200/how-do-i-enable-jaeger-jdbc-tracing-in-quarkus