如何通过kafka发送跟踪ID [英] How to send trace ID through kafka

查看:325
本文介绍了如何通过kafka发送跟踪ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

微服务1-> kafka->微服务2传输数据时如何传递跟踪ID?我正在使用弹簧侦探制作跟踪ID.我正在使用"compile('org.springframework.kafka:spring-kafka:2.1.2.RELEASE')"

Microservice1 -> kafka -> Microservice2 How do I pass the trace ID when transferring data? and i'm using spring sleuth for makeing trace ID. and i'm using "compile('org.springframework.kafka:spring-kafka:2.1.2.RELEASE')"

推荐答案

请阅读文档

48.3.3通过RabbitMQ或Kafka与Zipkin一起侦查如果要使用RabbitMQ或Kafka而不是HTTP,请添加spring-rabbit或spring-kafka依赖性.默认目标名称是zipkin.

48.3.3 Sleuth with Zipkin over RabbitMQ or Kafka If you want to use RabbitMQ or Kafka instead of HTTP, add the spring-rabbit or spring-kafka dependency. The default destination name is zipkin.

如果使用Kafka,则必须设置属性spring.zipkin.sender.type相应的属性:

If using Kafka, you must set the property spring.zipkin.sender.type property accordingly:

spring.zipkin.sender.type:kafka [注意]注意spring-cloud-sleuth-stream已被弃用并且与这些不兼容目的地.

spring.zipkin.sender.type: kafka [Caution] Caution spring-cloud-sleuth-stream is deprecated and incompatible with these destinations.

如果要让Sleuth优于RabbitMQ,请添加spring-cloud-starter-zipkin和spring-rabbit依赖性.

If you want Sleuth over RabbitMQ, add the spring-cloud-starter-zipkin and spring-rabbit dependencies.

以下示例显示了如何对Gradle进行操作:

The following example shows how to do so for Gradle:

行家.

<dependencyManagement> 1
       <dependencies>
           <dependency>
               <groupId>org.springframework.cloud</groupId>
               <artifactId>spring-cloud-dependencies</artifactId>
               <version>${release.train.version}</version>
               <type>pom</type>
               <scope>import</scope>
           </dependency>
       </dependencies> </dependencyManagement>

 <dependency> 2
     <groupId>org.springframework.cloud</groupId>
     <artifactId>spring-cloud-starter-zipkin</artifactId> </dependency> <dependency> 3
     <groupId>org.springframework.amqp</groupId>
     <artifactId>spring-rabbit</artifactId> </dependency> 1

我们建议您通过Spring添加依赖项管理BOM,因此您无需自己管理版本.

We recommend that you add the dependency management through the Spring BOM so that you need not manage versions yourself.

2

将依赖项添加到spring-cloud-starter-zipkin.这样,所有嵌套的依赖项将被下载.

Add the dependency to spring-cloud-starter-zipkin. That way, all nested dependencies get downloaded.

3

要自动配置RabbitMQ,请添加spring-rabbit依赖项.

To automatically configure RabbitMQ, add the spring-rabbit dependency.

等级.

dependencyManagement { 1
     imports {
         mavenBom "org.springframework.cloud:spring-cloud-dependencies:${releaseTrainVersion}"
     } }

 dependencies {
     compile "org.springframework.cloud:spring-cloud-starter-zipkin" 2
     compile "org.springframework.amqp:spring-rabbit" 3 } 1

我们建议您通过Spring添加依赖项管理BOM,因此您无需自己管理版本.

We recommend that you add the dependency management through the Spring BOM so that you need not manage versions yourself.

2

将依赖项添加到spring-cloud-starter-zipkin.这样,所有嵌套的依赖项将被下载.

Add the dependency to spring-cloud-starter-zipkin. That way, all nested dependencies get downloaded.

3

要自动配置RabbitMQ,请添加spring-rabbit依赖项.

To automatically configure RabbitMQ, add the spring-rabbit dependency.

这篇关于如何通过kafka发送跟踪ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆