通过依赖项spring-cloud-starter-zipkin,当侦探触发时,App应该连接到zipkin服务器。我没有启动zipkin服务器,因此它应该引发连接异常。但是什么也没发生。当我启动zipkin服务器时,它什么也收不到。
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>bj.demo</groupId>
<artifactId>hellozipin</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>hellozipin</name>
<url>http://maven.apache.org</url>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.13.RELEASE</version>
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Edgware.SR3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>
App.java
package bj.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@RestController
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
@RequestMapping("/")
public Object index() {
return "hello world";
}
}
application.properties
logging.level.org.springframework.web.servlet.DispatcherServlet=debug
spring.sleuth.sampler.percentage=1
和日志
2018-06-08 12:27:06.104 DEBUG [-,8e644cefdea9d09c,8e644cefdea9d09c,true] 5454 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/]
2018-06-08 12:27:06.104 DEBUG [-,8e644cefdea9d09c,8e644cefdea9d09c,true] 5454 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : Last-Modified value for [/] is: -1
2018-06-08 12:27:06.105 DEBUG [-,8e644cefdea9d09c,8e644cefdea9d09c,true] 5454 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
2018-06-08 12:27:06.105 DEBUG [-,8e644cefdea9d09c,8e644cefdea9d09c,true] 5454 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : Successfully completed request
最佳答案
当我将项目根日志级别更改为“调试”时,我看到了zipkin的一些错误报告。然后我意识到我使用的zipkin服务器非常老。 zipkin API调用返回404。
当我将zipkin服务器更新为最新版本时。有效。