应用程序无法从 istio 容器向 jaeger 报告
Application can not report to jaeger from istio container
我的java代码:
Class.forName("com.mysql.jdbc.Driver");
HikariConfig config = new HikariConfig();
config.setJdbcUrl("jdbc:tracing:mysql://my-db:3306/my-db");
config.setUsername("user");
config.setPassword("pwd");
config.setDriverClassName("io.opentracing.contrib.jdbc.TracingDriver");
HikariDataSource ds = new HikariDataSource(config);
// some db operation
我的 gradle 依赖项:
compile('io.opentracing.contrib:opentracing-jdbc:0.0.7')
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework:spring-jdbc:5.0.8.RELEASE')
compile group: 'io.opentracing.contrib', name: 'opentracing-jdbc', version: '0.0.7'
compile('io.jaegertracing:jaeger-client:0.30.4')
compile group: 'org.springframework.boot', name: 'spring-boot-starter-logging', version: '2.0.4.RELEASE'
compile('com.zaxxer:HikariCP:3.1.0')
runtime('mysql:mysql-connector-java')
providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
testCompile('org.springframework.boot:spring-boot-starter-test')
此代码适用于本地主机。
我已经将 JAEGER_AGENT_HOST
和 JAEGER_AGENT_PORT
环境传递给容器。
而且我可以在远程看到 Jaeger Initialized 日志:
Using the UDP Sender to send spans to the agent.
Using sender UdpSender(udpTransport=ThriftUdpTransport(socket=java.net.DatagramSocket@27e16046, receiveBuf=null, receiveOffSet=-1, receiveLength=0))
Using sender UdpSender(udpTransport=ThriftUdpTransport(socket=java.net.DatagramSocket@27e16046, receiveBuf=null, receiveOffSet=-1, receiveLength=0))
2018-08-16 13:24:32.809 INFO 1 --- [http-nio-8080-exec-1] io.jaegertracing.Configuration : Initialized tracer=JaegerTracer(version=Java-0.30.4, serviceName=
但我可以在 Jaeger 中看到它 UI。
我试过tcpdump
,找不到udp包。
我解决了这个问题。
它与采样率有关。
我配置了JAEGER_SAMPLER_TYPE
和JAEGER_SAMPLER_PARAM
后,就可以看到数据了。
我的java代码:
Class.forName("com.mysql.jdbc.Driver");
HikariConfig config = new HikariConfig();
config.setJdbcUrl("jdbc:tracing:mysql://my-db:3306/my-db");
config.setUsername("user");
config.setPassword("pwd");
config.setDriverClassName("io.opentracing.contrib.jdbc.TracingDriver");
HikariDataSource ds = new HikariDataSource(config);
// some db operation
我的 gradle 依赖项:
compile('io.opentracing.contrib:opentracing-jdbc:0.0.7')
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework:spring-jdbc:5.0.8.RELEASE')
compile group: 'io.opentracing.contrib', name: 'opentracing-jdbc', version: '0.0.7'
compile('io.jaegertracing:jaeger-client:0.30.4')
compile group: 'org.springframework.boot', name: 'spring-boot-starter-logging', version: '2.0.4.RELEASE'
compile('com.zaxxer:HikariCP:3.1.0')
runtime('mysql:mysql-connector-java')
providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
testCompile('org.springframework.boot:spring-boot-starter-test')
此代码适用于本地主机。
我已经将 JAEGER_AGENT_HOST
和 JAEGER_AGENT_PORT
环境传递给容器。
而且我可以在远程看到 Jaeger Initialized 日志:
Using the UDP Sender to send spans to the agent. Using sender UdpSender(udpTransport=ThriftUdpTransport(socket=java.net.DatagramSocket@27e16046, receiveBuf=null, receiveOffSet=-1, receiveLength=0)) Using sender UdpSender(udpTransport=ThriftUdpTransport(socket=java.net.DatagramSocket@27e16046, receiveBuf=null, receiveOffSet=-1, receiveLength=0)) 2018-08-16 13:24:32.809 INFO 1 --- [http-nio-8080-exec-1] io.jaegertracing.Configuration : Initialized tracer=JaegerTracer(version=Java-0.30.4, serviceName=
但我可以在 Jaeger 中看到它 UI。
我试过tcpdump
,找不到udp包。
我解决了这个问题。
它与采样率有关。
我配置了JAEGER_SAMPLER_TYPE
和JAEGER_SAMPLER_PARAM
后,就可以看到数据了。