1
votes

With dependency spring-cloud-starter-zipkin, App should connect to zipkin server when sleuth triggered. I did not started zipkin server, so it should throw a connection exception. But nothing happened. And when I start zipkin server, it can not receive anything.

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

And logs

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
how are you searching for an application in zipkin? - Antariksh
@Antariksh no any application shown - BaiJiFeiLong
Did you set application name in your application.properties? spring.application.name - Antariksh
@Antariksh set or not set. neither worked. - BaiJiFeiLong
Please just copy the code from github.com/openzipkin/sleuth-webmvc-example and try again. Of course adjust it to boot 1.5 - Marcin Grzejszczak

1 Answers

0
votes

When I change the project root log level to "debug", I saw some error report from zipkin. Then I realized that the zipkin server I used was very very old. And the zipkin API call returned 404.

When I updated my zipkin server to latest version. It worked.