2017-02-22 14 views
0

2つの非常に単純なSpring-Cloud-Streamアプリケーションがあります。メッセージプロデューサであるService3はバインダーカフカを介してコンシューマであるService4にメッセージを送信します。spring-cloud-streamの追跡ができませんSpring-cloud-sleuthのListener

そして、私は春 - 雲 - 竜を使用してそれらのスパンをトレースします。 Zipkinサーバーでは、Service3のスパンのみが利用可能です。 Service4のスパンは表示されません。

  1. Service3

    dependencies { 
    compile('org.springframework.boot:spring-boot-starter-web') 
    compile('org.springframework.boot:spring-boot-starter-thymeleaf') 
    
    compile('org.springframework.cloud:spring-cloud-starter-sleuth') 
    
    // Marshal spans over a Spring cloud stream binder 
    compile('org.springframework.cloud:spring-cloud-sleuth-stream') 
    compile('org.springframework.cloud:spring-cloud-stream-binder-kafka') 
    
    testCompile group: 'junit', name: 'junit', version: '4.11' 
    } 
    
    
    @SpringBootApplication 
    public class Service3 { 
        public static void main(String[] args) { 
         SpringApplication.run(Service3.class, args); 
        } 
    } 
    
    
    @Controller 
    @EnableBinding(Source.class) 
    public class WebController { 
    
        @Autowired 
        private Source source; 
    
    
        @GetMapping("/srv4") 
        private String getSrv4Info(){ 
         String msg = "Hello Service 4"; 
         this.source.output().send(MessageBuilder.withPayload(msg).build()); 
    
         return "srv4"; 
        } 
    } 
    
  2. Service4

    dependencies { 
        compile('org.springframework.boot:spring-boot-starter-web') 
    
        compile('org.springframework.cloud:spring-cloud-starter-sleuth') 
    
        // Marshal spans over a Spring cloud stream binder 
        compile('org.springframework.cloud:spring-cloud-sleuth-stream') 
        compile('org.springframework.cloud:spring-cloud-sleuth-zipkin-stream') 
        compile('org.springframework.cloud:spring-cloud-stream-binder-kafka') 
    
        runtime('io.zipkin.java:zipkin-autoconfigure-ui') 
    
        testCompile group: 'junit', name: 'junit', version: '4.11' 
    } 
    
    @SpringBootApplication 
    @EnableZipkinStreamServer 
    public class Service4 { 
        public static void main(String[] args) { 
         SpringApplication.run(Service4.class, args); 
        } 
    } 
    
    @EnableBinding(Sink.class) 
    public class MsgReceiver { 
        @StreamListener(Sink.INPUT) 
        private void listen(Message<String> msg){ 
         System.out.println(msg.getPayload()); 
        } 
    } 
    

Servic4 (message consumer) is not traced

私は何を逃したのですか?

+0

は最後に、私は自分のアプリケーションに関連する2の問題を発見しました。 1. @EnalbeZipkinStreamServerのアプリケーションをトレースできませんでした。これは設計上のように見えます。 – RocWay

+0

ええ、それはトレーサをトレースしたくないために設計されています –

答えて

0

これは推測です。

カフカにはメッセージヘッダー(スパンが格納されている場所)の概念はありません。

したがって、SCStはペイロードにメッセージヘッダーを埋め込む必要があります。

現在のバージョンでは、この方法で転送するヘッダーを「オプトイン」する必要があります。

Documentation here

spring.cloud.stream.kafka.binder.headers

バインダーによって輸送されるカスタムヘッダーのリスト。

デフォルト:空。

残念ながらパターンは現在サポートされていません。ヘッダーは個別にリストする必要があります。私たちはconsidering adding support for patternsであり、デフォルトですべてのヘッダーを転送しています。

+0

あなたの提案をありがとう。 @ russell、あなたは正しいです。私はこの質問に関連するgithub問題を発見しました。 https://github.com/spring-cloud/spring-cloud-sleuth/issues/282。 – RocWay

+0

今日、必要なすべてのヘッダが自動的に伝播されるように修正しました。 –

+0

これは非常に役に立ち、掘削時間を大幅に節約できます。 :) – RocWay

0

最後に、私のアプリケーションに関連する2つの問題が見つかりました。 1. @EnalbeZipkinStreamServerのアプリケーションをトレースできませんでした。これは設計上のように見えます。カフカがバインダーとして使用されている場合 2.アプリケーションは、次のようにヘッダを指定する必要があります。

spring.cloud.stream.kafka.binder.headers[0]=spanId 
    spring.cloud.stream.kafka.binder.headers[1]=spanSampled 
    spring.cloud.stream.kafka.binder.headers[2]=spanProcessId 
    spring.cloud.stream.kafka.binder.headers[3]=spanParentSpanId 
    spring.cloud.stream.kafka.binder.headers[4]=spanTraceId 
    spring.cloud.stream.kafka.binder.headers[5]=spanName 
    spring.cloud.stream.kafka.binder.headers[6]=spanFlags 
+0

私が今日行った変更でこれはもはや必要ではありません –

関連する問題