I am following all the instructions mentioned here: https://github.com/opentracing-contrib/java-jdbc
I assumed that with these steps the traces related to JDBC operations will automatically start getting reported. However, in the logs, I only see this below and nothing in Jaeger UI.
[main] INFO io.jaegertracing.Configuration - Initialized tracer=JaegerTracer(version=Java-0.35.4, serviceName=my-svc, reporter=CompositeReporter(reporters=[RemoteReporter(sender=HttpSender(), closeEnqueueTimeout=1000), LoggingReporter(logger=org.slf4j.impl.SimpleLogger(io.jaegertracing.internal.reporters.LoggingReporter))]), sampler=ConstSampler(decision=true, tags={sampler.type=const, sampler.param=true}), tags={hostname=mypc.local, jaeger.version=Java-0.35.4, ip=127.0.0.1}, zipkinSharedRpcSpan=false, expandExceptionLogs=false, useTraceId128Bit=false)
Can someone please show an example of how to achieve this? I am using below versions:
opentracing-api-0.33.0 opentracing-jdbc-0.2.10 opentracing-util-0.33.0 jaeger-core-0.35.4
Here's the abstract that I have attempted. Is there anything else I need to do?
// Jaeger Tracer
private static Tracer tracer = initTracer();
…
public static Tracer initTracer() {
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.setProperty("JAEGER_ENDPOINT", "http://collector-hostt:14268/api/traces");
TracingDriver.load();
TracingDriver.setInterceptorMode(true);
TracingDriver.setInterceptorProperty(true);
TracingDriver.setTraceEnabled(true);
SamplerConfiguration samplerConfig = SamplerConfiguration
.fromEnv()
.withType(ConstSampler.TYPE)
.withParam(1);
ReporterConfiguration reporterConfig = ReporterConfiguration
.fromEnv()
.withLogSpans(true);
Configuration config = new Configuration("my-svc")
.withSampler(samplerConfig)
.withReporter(reporterConfig);
tracer = config.getTracer();
GlobalTracer.registerIfAbsent(tracer);
return tracer;
}
And then this is the code around database call:
Span span = tracer.buildSpan("getAuthAccount").start();
span.setTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT);
this.accountDao.getAccount(username, password);
span.finish();
The database config is:
<Context>
<Resource name="jdbc/myDB"
type="javax.sql.DataSource" auth="Container"
maxActive="100" maxIdle="30" maxWait="10000"
username="tcuser" password="quality"
driverClassName="io.opentracing.contrib.jdbc.TracingDriver"
url="jdbc:tracing:mysql://localhost:3306/mydb?autoReconnect=true&traceWithActiveSpanOnly=true"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
minEvictableIdleTimeMillis="60000"
timeBetweenEvictionRunsMillis="60000"
testOnBorrow="true" testOnReturn="false" testWhileIdle="true"
validationInterval="1800000" validationQuery="SELECT 1"/>
</Context>