brave icon indicating copy to clipboard operation
brave copied to clipboard

Trace ID is not passed down in Dubbo application

Open liunancun opened this issue 2 years ago • 3 comments

This is a Dubbo application, which consists of three parts: demo-consumer, demo-provider, and demo-test.

The calling process is demo-consumer -> demo-provider -> demo-test

demo-consumer Configuration and code

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=20883
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";
	}
}

demo-provider Configuration and code

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;
	}

}

demo-test Configuration and code

dubbo.application.name=demo-test
dubbo.scan.basePackages=com.example.demo
dubbo.registry.address=zookeeper://192.168.99.214:2181
dubbo.protocol.port=20881
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;
	}

}

result

Three Trace IDs appear image

There are only two calls to consumer. Normally, there should be three calls image

liunancun avatar Feb 24 '23 09:02 liunancun

Ping @shakuzen

On Fri, 24 Feb 2023, 10:07 liunancun, @.***> wrote:

This is a Dubbo application, which consists of three parts: demo-consumer, demo-provider, and demo-test.

The calling process is demo-consumer -> demo-provider -> demo-test

demo-consumer Configuration and code

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=20883 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";

} }

demo-provider Configuration and code

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;

}

}

demo-test Configuration and code

dubbo.application.name=demo-test dubbo.scan.basePackages=com.example.demo dubbo.registry.address=zookeeper://192.168.99.214:2181 dubbo.protocol.port=20881 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;

}

}

result

Three Trace IDs appear [image: image] https://user-images.githubusercontent.com/12378933/221137548-a3bb4665-02d6-45b8-82a2-6db4ebc670e1.png

There are only two calls to consumer. Normally, there should be three calls [image: image] https://user-images.githubusercontent.com/12378933/221137748-a4182bd9-121e-422b-9100-5b79a363880e.png

— Reply to this email directly, view it on GitHub https://github.com/openzipkin/brave/issues/1363, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXOYAUCVCPHVWUSTXE3TETWZB24LANCNFSM6AAAAAAVGUWPDI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

jcchavezs avatar Feb 25 '23 16:02 jcchavezs

It is normal in version 2.7, but there is a problem in version 3 or above. Does it still not support Dubbo3?

liunancun avatar Mar 01 '23 01:03 liunancun

Dubbo has support for micrometer observation and micrometer tracing that has a bridge for brave. You can use that

marcingrzejszczak avatar Aug 24 '23 19:08 marcingrzejszczak