gpt4 book ai didi

Spring Boot 3 Webflux with Micrometer Tracing not showing as a one trace in the zipkin dashboard(在Zipkin仪表板中,带有千分尺跟踪的Spring Boot 3 Webflow未显示为一条跟踪)

转载 作者:bug小助手 更新时间:2023-10-24 17:54:31 39 4
gpt4 key购买 nike



My Microservices application has 3 different Microservices. many of them have been created with just spring boot (imperative way) but those application's tracings are shown in the dashboard correctly. but I created one Microservice application by using spring boot 3 with webflux. because of using spring boot 3 I had to use micrometer instead of sleuth.

我的微服务应用程序有3个不同的微服务。它们中的许多都是使用Spring Boot(命令式方式)创建的,但这些应用程序的轨迹在仪表板中显示正确。但我创建了一个微服务应用程序,使用的是带有WebFlux的Spring Boot3。因为我用的是弹簧靴3,所以我不得不用千分尺而不是探头。


My 3rd application does make a http request to the webflux application. but that trace details I can't see in the dashboard under the same trace. that trace (webflux one) is shown as a separate one in the dashboard. other 3 Microservices' tracing details are available under one trace. but webflux's trace is not.

我的第三个应用程序确实向WebFlux应用程序发出了一个http请求。但我在仪表板上同样的痕迹下看不到这些痕迹的细节。该跟踪(Webflow One)在仪表板中显示为单独的跟踪。在一个跟踪下可以找到其他3个微服务的跟踪详细信息。但WebFlux的踪迹却并非如此。


the pom.xml file and configuration like below.

Pom.xml文件和如下所示的配置。


<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>service-abc</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>service-6</name>
<description>service-abc</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</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>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-exporter-zipkin</artifactId>
</dependency>


<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-instrumentation</artifactId>
<version>3.1.8</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>

</project>

spring.application.name=service-abc
management.tracing.sampling.probability=1.0
logging.pattern.level=%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]
server.port=5054
logging.level.org.springframework=debug

Main class (according to the doc https://github.com/micrometer-metrics/tracing/wiki/Spring-Cloud-Sleuth-3.1-Migration-Guide )

主类(根据文档https://github.com/micrometer-metrics/tracing/wiki/Spring-Cloud-Sleuth-3.1-Migration-Guide)



package com.example.service6;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import reactor.core.publisher.Hooks;

@SpringBootApplication
public class Service6Application {

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

I tried lots of examples in the website but I was unable to do that. please help me to solve this problem.

我在网站上尝试了很多例子,但我做不到。请帮我解决这个问题。


更多回答
优秀答案推荐

For webflux Please make sure your reactor-core is >= 3.5.7 and micrometer context-propagation library which should be >=1.0.4

对于网络流量,请确保您的反应堆核心>=3.5.7,微米上下文传播库应>=1.0.4


you can get more information about this bug here

您可以在此处获取有关此错误的更多信息


Also please add this in your main class

另外,请在您的主类中添加此内容


Hooks.enableAutomaticContextPropagation();

Hooks.enableAutomaticContextPropagation();



Add propagation type in your properties file as b3. because zipkin does support B3.

在属性文件中将传播类型添加为b3。因为Zipkin确实支持B3。


management.tracing.propagation.type=b3

更多回答

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com