码迷,mamicode.com
首页 > 编程语言 > 详细

springboot 项目添加jaeger调用链监控

时间:2018-05-16 10:51:16      阅读:3521      评论:0      收藏:0      [点我收藏+]

标签:port   mave   pcl   headers   depend   oop   监控   app   factory   

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调用链监控

标签:port   mave   pcl   headers   depend   oop   监控   app   factory   

原文地址:https://www.cnblogs.com/jiuchongxiao/p/9044444.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!