apache / apache/dubbo

A应用调用B应用,B应用再调用C应用,使用Zipkin追踪调用链的时候,怎么样才能只生成一个Trace ID,Trace ID好像不能传递

Open
#11,650 16 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
41.6k
Forks
26.4k
Avg merge
15h 13m
Merged PRs (30d)
4

Description

A应用代码和配置
```
dubbo.application.name=demo-consumer
dubbo.scan.basePackages=com.example.demo
dubbo.registry.address=zookeeper://192.168.99.214:2181
dubbo.application.qos-enable=false
dubbo.protocol.port=20881
dubbo.consumer.filter=tracing
```
```
@Configuration
@Import({ DelegatingTracingFilter.class, SpanCustomizingAsyncHandlerInterceptor.class })
public class WebZipkinConfig implements WebMvcConfigurer {

@Resource
private SpanCustomizingAsyncHandlerInterceptor interceptor;

@Resource
private Tracing tracing;

@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(interceptor);
}

@Bean
public HttpTracing httpTracing() {
return HttpTracing.create(tracing);
}
}
```
```
@Configuration
public class ZipkinConfig {
@Bean
public Tracing tracing() {
return Tracing.newBuilder().localServiceName("consumer")
.addSpanHandler(
AsyncZipkinSpanHandler.create(OkHttpSender.create("http://192.168.99.214:9411/api/v2/spans")))
.build();
}
}
```
```
@SpringBootApplication
@RestController
public class DemoApplication {

public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}

@DubboReference
private DemoService demoService;

@GetMapping("hello")
public String hello() {

demoService.hello("liunancun");

return "hello";
}
}
```

B应用配置和代码
```
dubbo.application.name=demo-provider
dubbo.scan.basePackages=com.example.demo
dubbo.registry.address=zookeeper://192.168.99.214:2181
dubbo.protocol.port=20882
dubbo.provider.filter=tracing
dubbo.consumer.filter=tracing
```
```
@Configuration
public class ZipkinConfig {
@Bean
public Tracing tracing() {
return Tracing.newBuilder().localServiceName("provider")
.addSpanHandler(
AsyncZipkinSpanHandler.create(OkHttpSender.create("http://192.168.99.214:9411/api/v2/spans")))
.build();
}
}
```
```
@DubboService
public class DemoServiceImpl implements DemoService {

@DubboReference
private TestService testService;

@Override
public String hello(String name) {

System.out.println("hello " + name);

testService.test(name);

return "hello " + name;
}

}
```

C应用配置和代码
```
dubbo.application.name=demo-test
dubbo.scan.basePackages=com.example.demo
dubbo.registry.address=zookeeper://192.168.99.214:2181
dubbo.protocol.port=20883
dubbo.provider.filter=tracing
```
```
@Configuration
public class ZipkinConfig {
@Bean
public Tracing tracing() {
return Tracing.newBuilder().localServiceName("test")
.addSpanHandler(
AsyncZipkinSpanHandler.create(OkHttpSender.create("http://192.168.99.214:9411/api/v2/spans")))
.build();
}
}
```
```
@DubboService
public class TestServiceImpl implements TestService {

@Override
public String test(String name) {

System.out.println("test, " + name);

return "test, " + name;
}

}
```

生成了3个Trace ID
![image](https://user-images.githubusercontent.com/12378933/221202456-9383a81e-9876-4958-8f14-0198254cf231.png)

第1个Trace ID只追踪到B应用,没有追踪到C应用
![image](https://user-images.githubusercontent.com/12378933/221202641-9c9df6d5-1e8d-48af-8f73-27293c235e1f.png)

Contributor guide

Open the contributing guide

Research direction

Reproduce the A→B→C call using the shown Dubbo tracing-filter settings and the ZipkinConfig classes. Start by reviewing how the tracing filter handles propagation between the @DubboReference and @DubboService calls, then verify the result in Zipkin. Done means one trace ID links all three applications without breaking the existing spans.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
distributed-systems, observability-sre
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.