为什么我的zipkin客户端没有连接到我的zipkin服务器

时间:2018-06-08 04:28:47

标签: java spring spring-cloud zipkin spring-cloud-sleuth

使用依赖spring-cloud-starter-zipkin,应该在侦听触发时连接到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

1 个答案:

答案 0 :(得分:0)

当我将项目根日志级别更改为“调试”时,我看到了zipkin的一些错误报告。然后我意识到我使用的zipkin服务器非常老。 zipkin API调用返回404。

当我将zipkin服务器更新为最新版本时。奏效了。