Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Go 使用Jaeger在分布式应用程序中跟踪Kafka总线_Go_Apache Kafka_Opentracing_Jaeger - Fatal编程技术网

Go 使用Jaeger在分布式应用程序中跟踪Kafka总线

Go 使用Jaeger在分布式应用程序中跟踪Kafka总线,go,apache-kafka,opentracing,jaeger,Go,Apache Kafka,Opentracing,Jaeger,我有一个由几个Go服务组成的分布式应用程序。其中一些使用卡夫卡作为数据总线。我能够使用Jaeger的opentracing追踪服务之间的调用。我在图形上绘制卡夫卡跨距时遇到问题,它们显示为间隙 这就是我能做的。 初始跨距由gRPC中间件创建。生产者方面: ... kafkaMsg := kafka.Message{Key: []byte(key), Value: msgBytes} headers:=make(map[string]string) if span := opentraci

我有一个由几个Go服务组成的分布式应用程序。其中一些使用卡夫卡作为数据总线。我能够使用Jaeger的
opentracing
追踪服务之间的调用。我在图形上绘制卡夫卡跨距时遇到问题,它们显示为间隙

这就是我能做的。 初始跨距由gRPC中间件创建。生产者方面:

...    
kafkaMsg := kafka.Message{Key: []byte(key), Value: msgBytes}
headers:=make(map[string]string)
if span := opentracing.SpanFromContext(ctx); span != nil {
    opentracing.GlobalTracer().Inject(
        span.Context(),
        opentracing.TextMap,
        opentracing.TextMapCarrier(headers))
}
for headerKey, headerValue:=range headers{
    msg.Headers = append(msg.Headers, kafka.Header{
        Key: headerKey,
        Value: []byte(headerValue),
    })
}
// Write message to Kafka
...
消费者方面:

...
// read headers from Kafka message
headers := make(map[string]string)
for _, header := range kafkaMessage.Headers{
    headers[header.Key]=string(header.Value)
}
spanContext, _ := opentracing.GlobalTracer().Extract(opentracing.TextMap, opentracing.TextMapCarrier(headers))
span := opentracing.StartSpan(
    "Consumer",
    opentracing.FollowsFrom(spanContext))
defer span.Finish()
...

当消息出现在卡夫卡中时,我应该如何修改它以在图形上绘制跨度?

所以,回答我自己的问题。Jaeger不支持跨系统跨距。每个子系统负责整个系统中自己的跨度。
作为参考,请检查此答案

您用此答案救了我的命。非常感谢。