我的目的是将每个请求跟踪到我的系统.我在YouTube上看了下面的两个视频,以配置测微器和Zipkin进行跟踪.

但是,当我访问http://localhost:9411/zipkin/的时候,它的工作异常,让我感到困惑.

enter image description here

所以我对此有几个问题:

  1. 起初,我从来没有执行过任何请求,为什么Zipkin仪表盘上有这么多请求?
  2. I use Postman to perform three requests (1 from order-service, 2 from product-service), why it only show the requests from order-service like this enter image description here
  3. 为什么跨度(Zipkin仪表板)总是1.虽然每个请求都必须先通过api-gateway service,但它与视频1不同.

对于千分尺配置,我引用Micrometer and Zipkin: How to Trace HTTP Requests in Spring Boot 3

我在每个application.properties文件中插入management.tracing.sampling.probability=1.0,在每个pom.xml中插入以下依赖项

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-observation</artifactId>
        </dependency>
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-tracing-bridge-brave</artifactId>
        </dependency>
        <dependency>
            <groupId>io.zipkin.reporter2</groupId>
            <artifactId>zipkin-reporter-brave</artifactId>
        </dependency>

这是我的架构系统:

enter image description here

推荐答案

首先,我try 判断management.tracing.sampling.probability=1.0,它会引发一个错误:

Cannot resolve configuration property 'management.tracing.sampling.probability' 

我真的不明白为什么会是这样,之后我发现了不同的,有两个独立的,他们看起来很相似:

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-actuator</artifactId>
        </dependency>

        ...................
        ...................
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>弹簧靴-启动器-执行器</artifactId>
        </dependency>

我try 联系Spring文档:actuator.micrometer-tracing.tracer-implementations,我意识到我实际需要的依赖项是弹簧靴-启动器-执行器

我从文档中插入了三个新依赖项:

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>弹簧靴-启动器-执行器</artifactId>
        </dependency>
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>千分尺-示踪-电桥-电位器</artifactId>
        </dependency>
        <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>开放测光-出口商-Zipkin</artifactId>
        </dependency>

总之,我们将使用这些依赖项通过microeter&;Zipkin跟踪http请求.

  • 弹簧靴-启动器-执行器
  • 千分尺-示踪-电桥-电位器
  • 开放测光-出口商-Zipkin

Java相关问答推荐

Gmail Javi API批量处理太多请求

如何使用CSS为选定但未聚焦的表格行设置背景 colored颜色 ?

是否需要关闭Executors返回的执行器.newVirtualThreadPerTaskExecutor()?

将linkedHashMap扩展到Java中的POJO类

当一个链表中间有一个循环时,它的松散部分会发生什么?

为什么如果数组列表中有重复项,我的代码SOMETIMES不返回true?

为什么Java的代码工作(if condition内部的实例)

SpringBoot+Java 17@Valid未验证POJO

Java中的死锁及其重入锁和锁

安装Java Jar应用程序的Install4j遇到ClassNotFoundException的运行时错误

JDK 21-为什么线程局部随机S nextInt不直接用Super.nextInt实现?

如何在JavaFX中制作鼠标透明stage

JNI:将代码打包成自包含的二进制文件

Cordova Android Gradle内部版本组件不兼容

Java组件项目中的JavaFX对话框国际化

通过Java列表中的某些字段搜索值

用于Java的Visual Studio代码完成不起作用

如何使用Rascal Evaluator从编译的JAR访问Rascal函数?

在数组中查找素数时出现逻辑错误

获取401未经授权,即使在标头中设置了浏览器名称和cookie