【问题标题】:traces are not being shown in zipkin, when sender type is kafka当发件人类型为 kafka 时,zipkin 中未显示跟踪
【发布时间】:2020-01-13 12:31:17
【问题描述】:

我想使用 Kafka 将我的 Spring Boot 日志跟踪发送到 Zipkin 服务器

我启动了我的 Kafka 和 Zipkin 服务器,我启动了一个 Kafka 消费者,它正在收听 Zipkin 主题,我可以在这里看到我的日志,但是当我打开我的 Zipkin 仪表板时,我找不到任何痕迹

Spring boot 版本:- 2.1.7.RELEASE
Spring Cloud 版本:- Greenwich.SR2

依赖管理

    <dependencyManagement>
            <dependencies>
                <dependency>
                    <groupId>org.springframework.cloud</groupId>
                    <artifactId>spring-cloud-dependencies</artifactId>
                    <version>Greenwich.SR2</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
            </dependencies>
        </dependencyManagement>

依赖项

    <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-sleuth</artifactId>
    </dependency>
     <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-zipkin</artifactId>
    </dependency>
    <dependency>
            <groupId>org.springframework.kafka</groupId>
            <artifactId>spring-kafka</artifactId>
    </dependency>

我的 application.properties 文件

        spring.sleuth.sampler.probability=1 

        spring.application.name=dummy

        spring.zipkin.baseUrl=http://localhost:9411

        spring.zipkin.sender.type=kafka

SpringBootApplication 主文件

@SpringBootApplication
public class UserApplication {

    public static void main(String[] args) {
        SpringApplication.run(UserApplication.class, args);
    }

}

我的控制器功能

@GetMapping("/hello")
public String sayHello() {
    log.info("hey im a log");
    return "hello";
}

当我制作 spring.zipkin.sender.type=web 时,Zipkin 仪表板中会显示痕迹 我在这里有什么遗漏吗?

【问题讨论】:

  • 设置 type=kafka 而不是 type:kafka?您可以尝试使用 -Ddebug=true 运行您的应用以获取更多信息
  • 嘿,谢谢您的回复我很抱歉我在写问题时打错了,在我的应用程序中它只是 spring.zipkin.sender.type=kafka 但它仍然没有显示日志
  • 当我运行一个消费主题 zipkin 的消费者时,跟踪将进入 Kafka,每当我点击任何端点时,都会生成日志并显示在消费者 cmd 行中,但是它不会去 Zipkin
  • 感谢您的帮助@MarcinGrzejszczak,我希望我也指定了我的命令行终端,然后也许您会立即弄清楚我的问题是什么。无论如何,我非常感谢您的帮助,并希望在 youtube 上看到有关 Spring Cloud Greenwich.SR2 版本中使用 Spring Cloud 和 Zipkin 进行微服务跟踪的新视频。

标签: spring spring-boot apache-kafka spring-cloud zipkin


【解决方案1】:

好吧,我终于意识到我在使用这个命令启动我的 zipkin 服务器时犯了什么错误

 java -jar zipkin-server-2.16.2-exec.jar

但我没有指定运行 Kafka 的 Zipkin 服务器,所以当我这样做时

 set KAFKA_BOOTSTRAP_SERVERS=localhost:9092
 java -jar zipkin-server-2.16.2-exec.jar 

成功了

【讨论】:

    猜你喜欢
    • 2019-12-02
    • 1970-01-01
    • 2023-03-27
    • 2011-06-04
    • 2020-05-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多