This example demonstrates the basic usage of tracing in Dubbo application and report tracing information to zipkin. This example contains three parts, dubbo-samples-spring-boot3-tracing-provider
, dubbo-samples-spring-boot3-tracing-consumer
and dubbo-samples-spring-boot3-tracing-interface
.
Apache Dubbo has inbuilt tracing through Micrometer Observations and Micrometer Tracing.
Follow Zipkin's quick start to install zipkin.
Here we use docker to quickly start a zipkin server.
docker run -d -p 9411:9411 --name zipkin openzipkin/zipkin
Then you can verify zipkin server works by access http://localhost:9411
Follow Nacos's quick start to install and start nacos.
Start org.apache.dubbo.springboot.demo.provider.ProviderApplication
directly from IDE.
Start org.apache.dubbo.springboot.demo.consumer.ConsumerApplication
directly from IDE.
Open http://localhost:9411/zipkin/ in browser.
dubbo-spring-boot-observability-starter
To Your ProjectFor the Springboot project, you can use dubbo-spring-boot-observability-starter
to easily have observability, Dubbo provides two types of starters at present, select one to add to pom:
<!-- Opentelemetry as Tracer, Zipkin as exporter --> <dependency> <groupId>org.apache.dubbo</groupId> <artifactId>dubbo-tracing-otel-zipkin-spring-boot-starter</artifactId> </dependency>
<!-- Brave as Tracer, Zipkin as exporter --> <dependency> <groupId>org.apache.dubbo</groupId> <artifactId>dubbo-tracing-brave-zipkin-spring-boot-starter</artifactId> </dependency>
Please note that this Dubbo upgrade has changed the dependency name, which is quite tricky. We recommend visiting the Dubbo version release page to obtain the latest source code updates. For reference, visit https://cn.dubbo.apache.org/en/download/.
Dubbo will support more in the future, such as skywalking, Jagger.
my-address: 127.0.0.1 spring: application: name: dubbo-springboot3-tracing-provider/consumer dubbo: application: name: ${spring.application.name} protocol: name: dubbo port: -1 registry: id: nacos-registry address: nacos://${my-address}:8848 config-center: address: nacos://${my-address}:8848 metadata-report: address: nacos://${my-address}:8848 tracing: enabled: true # default is false sampling: probability: 0.5 # sampling rate, default is 0.1 propagation: type: W3C # W3C/B3 default is W3C tracing-exporter: zipkin-config: endpoint: http://${my-address}:9411/api/v2/spans connect-timeout: 1s # connect timeout, default is 1s read-timeout: 10s # read timeout, default is 10s logging: level: root: info pattern: console: '[%d{dd/MM/yy HH:mm:ss:SSS z}] %t %5p %c{2} [%X{traceId:-}, %X{spanId:-}]: %m%n'
Among these steps, we need to manually configure “my-address” to the addresses where we run Nacos and Zipkin.
To customize the tags present in metrics (low cardinality tags) and in spans (low and high cardinality tags) you should create your own versions of DubboServerObservationConvention
(server side) and DubboClientObservationConvention
( client side) and register them in the ApplicationModel
's BeanFactory
. To reuse the existing ones check DefaultDubboServerObservationConvention
(server side) and DefaultDubboClientObservationConvention
(client side).
An OpenZipkin URL sender dependency to send out spans to Zipkin via a URLConnectionSender
<dependency> <groupId>io.zipkin.reporter2</groupId> <artifactId>zipkin-sender-urlconnection</artifactId> <version>3.3.0</version> </dependency>
or use following code to solve it:
<dependency> <groupId>io.zipkin.reporter2</groupId> <artifactId>zipkin-reporter</artifactId> <version>3.3.0</version> </dependency> <dependency> <groupId>io.zipkin.reporter2</groupId> <artifactId>zipkin-sender-okhttp3</artifactId> <version>3.3.0</version> </dependency>