dtry54612 2019-07-02 07:38
浏览 212

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

I have distribute application that consists of several Go services. Some of those use Kafka as data bus. I was able trace down calls between services using opentracing with Jaeger. I have problem plotting Kafka spans on graph, them appear as gaps.

Here is what i was able to do. Initial spans been created by gRPC middleware. Producer side:

...    
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
...

Consumer side:

...
// 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()
...

How should i modify this to plot span on graph when message was in Kafka?

  • 写回答

1条回答 默认 最新

  • dtby67541 2019-07-08 01:26
    关注

    So, answering my own question. Jaeger does not support cross system spans. Every sub-system is responsible for its own span in the whole system. For reference, check this answer https://github.com/opentracing/specification/issues/143

    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向