• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

springboot 项目添加jaeger调用链监控

java 来源:dianjiejian4745 5次浏览
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();

}

转载于:https://www.cnblogs.com/jiuchongxiao/p/9044444.html


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)