springboot 项目添加jaeger调用链监控

Posted 九重霄

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了springboot 项目添加jaeger调用链监控相关的知识,希望对你有一定的参考价值。

1.添加maven依赖
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-spring-cloud-starter</artifactId>
<version>0.1.8</version>
</dependency>

<dependency>
<groupId>com.uber.jaeger</groupId>
<artifactId>jaeger-core</artifactId>
<version>0.26.0</version>
</dependency>

<dependency>
<groupId>com.uber.jaeger</groupId>
<artifactId>jaeger-b3</artifactId>
<version>0.26.0</version>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.5</version>
</dependency>
2.启动类 application添加bean

注意:http://192.168.181.99:30668/api/traces 为对应的jaeger collector地址
service-c 为服务名称

@Bean
public io.opentracing.Tracer jaegerTracer() {

Reporter reporter = new RemoteReporter.Builder().withFlushInterval(10)
.withMaxQueueSize(65000)
.withSender(new HttpSender("http://192.168.181.99:30668/api/traces"))
.withMetrics(new Metrics(new NoopMetricsFactory()))
.build();

Builder builder = new Builder("service-c")
.withReporter(reporter)
.withSampler(new ConstSampler(true))
.registerInjector(Format.Builtin.HTTP_HEADERS, new B3TextMapCodec())
.registerExtractor(Format.Builtin.HTTP_HEADERS, new B3TextMapCodec());

return builder.build();

}














































以上是关于springboot 项目添加jaeger调用链监控的主要内容,如果未能解决你的问题,请参考以下文章

将 JDBC 查询信息添加到 opentracing/Jaeger 跨度

调用链监控

Jaeger-2.客户端使用 (Java版本)

微服务全链路跟踪:jaeger集成grpc

[系列] go-gin-api 路由中间件 - Jaeger 链路追踪

分布式调用链跟踪工具Jaeger?两分钟极速体验