有人用 Spring Cloud Gateway 实现 Jaeger 吗?

NOr*_*bes 6 java spring-boot jaeger spring-cloud-gateway

我们正在使用微服务架构方法重建我们的软件平台。

其中大部分使用Spring Boot库,对于我们的入口点,我们使用Spring Cloud Gateway,它可以轻松集成以Jaeger在平台中进行跟踪。

我们使用以下 Maven 依赖项来做到这一点:

<dependency>
    <groupId>io.opentracing.contrib</groupId>
    <artifactId>opentracing-spring-jaeger-cloud-starter</artifactId>
    <version>2.0.3</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

它运行良好,我们可以在Jaeger UIWeb 控制台上看到跟踪。

现在的问题是如何将跟踪信息发送到平台中的下一个内部服务,以使每个服务相关联。

有任何想法吗?

我们尝试使用 a 将跟踪信息作为 HTML 标头注入,GlobalFilter但它正在使用传入的请求,我们需要将它们放在下游请求上......任何关于如何覆盖HTTPClient下面使用的线索。

<dependency>
    <groupId>io.opentracing.contrib</groupId>
    <artifactId>opentracing-spring-jaeger-cloud-starter</artifactId>
    <version>2.0.3</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

Kam*_*aii 0

我们的解决方案:

上游过滤器实现 org.springframework.cloud.gateway.filter.headers.HttpHeadersFilter

exchange.getAttributes().put('your_key_here', value);
Run Code Online (Sandbox Code Playgroud)

下游过滤器实现 org.springframework.cloud.gateway.filter.headers.HttpHeadersFilter

Object storedValue = exchange.getAttribute('your_key_here'); // NOTE can be null
Run Code Online (Sandbox Code Playgroud)

并通过 Spring Java 配置(@Bean)注册它们