SpringBoot集成Zipkin的问题
来源:10-15 业务系统集成Zipkin 01

Moss1105
2019-12-11
老师,我看完zipkin相关的视频之后,自己搭了个demo来用下Zipkin,但是Zipkin没有显示调用,下面是我的demo的大概的代码。
在父工程的pom.xml引入Zipkin相关的依赖如下:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-bom</artifactId>
<version>5.5.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.zipkin.reporter2</groupId>
<artifactId>zipkin-reporter-bom</artifactId>
<version>2.7.9</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
分别在服务提供者、服务消费者引入Zipkin相关的依赖如下:
<!--zipkin start-->
<dependency>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-instrumentation-dubbo-rpc</artifactId>
</dependency>
<dependency>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-spring-beans</artifactId>
</dependency>
<dependency>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-context-slf4j</artifactId>
</dependency>
<dependency>
<groupId>io.zipkin.reporter2</groupId>
<artifactId>zipkin-sender-okhttp3</artifactId>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
<version>4.0.1</version>
</dependency>
<!--zipkin end-->
配置类
HelloServiceImpl.java
@Component
@Service(interfaceClass = HelloService.class, filter = "tracing")
public class HelloServiceImpl implements HelloService {
@Override
public String sayHello(String name) {
try {
// 通过 sleep 模拟业务逻辑处理时间
Thread.sleep(new Random(System.currentTimeMillis()).nextInt(1000));
} catch (InterruptedException e) {
// no op
}
return "hello, " + name;
}
}
GreetServiceImpl.java,在GreetServiceImpl中调用helloService.sayHello(name)。
@Component
@Service(interfaceClass = GreetService.class, filter = "tracing")
public class GreetServiceImpl implements GreetService {
@Reference(interfaceClass = HelloService.class, check = false)
private HelloService helloService;
@Override
public String greeting(String name) {
try {
// 通过 sleep 模拟业务逻辑处理时间
Thread.sleep(new Random(System.currentTimeMillis()).nextInt(1000));
} catch (InterruptedException e) {
// no op
}
return "greeting, " + helloService.sayHello(name);
}
}
GreetController.java
@RestController
public class GreetController {
@Reference(interfaceClass = GreetService.class,filter="tracing")
private GreetService greetService;
@RequestMapping("/greet")
public String greet() {
String greeting = greetService.greeting("moss");
return greeting;
}
}
启动工程之后,能成功访问页面
但是在Zipkin没有显示刚刚的调用
不知道问题出在哪里,请老师帮忙看下。
写回答
1回答
-
Allen
2019-12-13
后端没有报错或者上报Zipkin的日志内容, 如果没有的话, 把日志级别调低再看看
00
相似问题