How do I enable Jaeger JDBC tracing in Quarkus
Asked Answered
C

1

2

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.

Compellation answered 9/9, 2019 at 12:36 Comment(2)
Currently I don't believe we have any OpenTracing JDBC libraries in Quarkus. Please raise an issue to support this: github.com/quarkusio/quarkus/issuesAdley
Did you try to use github.com/opentracing-contrib/java-jdbc ? If it didn't works OOTB, maybe an extension needs to be created in Quarkus tu support itPortly
P
3

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.

Portly answered 9/9, 2019 at 14:2 Comment(3)
thx for the fast reply. This indeed works. I was using version 0.1.8 of opentracing-jdbc and this wasn't working.Compellation
maybe an idea to add this automatically in Quarkus, if the project contains any jdbc/jpa dependencies when also adding quarkus.opentracing in your project ?Compellation
I'm not sure it is a good idea to automatically add it because it creates a lot of spans and not eveybody should need it. What can be done is to write a section in the guide about it and manage the version in the Quarkus bom to avoid a developer to spent time finding the version that works. I can take care of itPortly

© 2022 - 2024 — McMap. All rights reserved.