How do I enable Jaeger JDBC tracing in Quarkus

六眼飞鱼酱① 提交于 2020-01-15 10:21:52

问题


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.

  1. Add the dependency to your pom.xml:

    <dependency>
      <groupId>io.opentracing.contrib</groupId>
      <artifactId>opentracing-jdbc</artifactId>
      <version>0.0.12</version>
    </dependency>
    
  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!