OTlp

This example demonstrates how to use OpenTelemetry as a Tracer in a Dubbo project to report Trace information to the Otlp Collector, which then forwards it to Zipkin and Jagger.

Overview

This example demonstrates how to use OpenTelemetry as a Tracer in a Dubbo project to report Trace information to the Otlp Collector, which then forwards it to Zipkin and Jagger. Code repository

It consists of three parts:

  • dubbo-samples-spring-boot-tracing-otel-oltp-interface
  • dubbo-samples-spring-boot-tracing-otel-oltp-provider
  • dubbo-samples-spring-boot-tracing-otel-oltp-consumer

Case Architecture Diagram

Case Architecture Diagram

Quick Start

Install & Start Otlp Collector

Follow the OpenTelemetry Collector Quick Start to start the otlp collector.

Start Provider

Run org.apache.dubbo.springboot.demo.provider.ProviderApplication directly from the IDE.

Start Consumer

Start org.apache.dubbo.springboot.demo.consumer.ConsumerApplication directly from the IDE.

View Trace Information

Open the Zipkin dashboard in the browser at http://localhost:9411/zipkin/:

zipkin.png

zipkin.png

Open the Jaeger dashboard in the browser at http://localhost:16686/search:

jaeger_search.png

jaeger_detail.png

How to Use in a SpringBoot Project

1. Add Dependencies in Your Project

For SpringBoot projects, you can use dubbo-spring-boot-tracing-otel-otlp-starter:

  1. <!-- OpenTelemetry as Tracer, Otlp as exporter -->
  2. <dependency>
  3. <groupId>org.apache.dubbo</groupId>
  4. <artifactId>dubbo-spring-boot-tracing-otel-otlp-starter</artifactId>
  5. </dependency>

2. Configuration

application.yml

  1. dubbo:
  2. tracing:
  3. enabled: true # default is false
  4. sampling:
  5. probability: 0.5 # sampling rate, default is 0.1
  6. propagation:
  7. type: W3C # W3C/B3 default is W3C
  8. tracing-exporter:
  9. otlp-config:
  10. endpoint: http://localhost:4317
  11. timeout: 10s # default is 10s
  12. compression-method: none # none/gzip The method used to compress payloads, default is "none"
  13. headers: # customized added headers, default is empty
  14. auth: admin
  15. # tracing info output to logging
  16. logging:
  17. level:
  18. root: info
  19. pattern:
  20. console: '[%d{dd/MM/yy HH:mm:ss:SSS z}] %t %5p %c{2} [%X{traceId:-}, %X{spanId:-}]: %m%n'

How to Use Based on Dubbo API

1. Add Dependencies in Your Project

  1. <!-- Required, core dependency of dubbo-tracing -->
  2. <dependency>
  3. <groupId>org.apache.dubbo</groupId>
  4. <artifactId>dubbo-tracing</artifactId>
  5. </dependency>
  6. <!-- Opentelemetry as Tracer -->
  7. <dependency>
  8. <groupId>io.micrometer</groupId>
  9. <artifactId>micrometer-tracing-bridge-otel</artifactId>
  10. </dependency>
  11. <!-- OTlp as exporter -->
  12. <dependency>
  13. <groupId>io.opentelemetry</groupId>
  14. <artifactId>opentelemetry-exporter-otlp</artifactId>
  15. </dependency>

2. Configuration

  1. TracingConfig tracingConfig = new TracingConfig();
  2. // Enable dubbo tracing
  3. tracingConfig.setEnabled(true);
  4. // Set sampling rate
  5. tracingConfig.setSampling(new SamplingConfig(1.0f));
  6. // Set Propagation, default is W3C, optional W3C/B3
  7. tracingConfig.setPropagation(new PropagationConfig("W3C"));
  8. // Set trace reporting
  9. ExporterConfig exporterConfig = new ExporterConfig();
  10. // Set to report trace to Zipkin
  11. exporterConfig.setZipkin(new ExporterConfig.OtlpConfig("http://localhost:4317", Duration.ofSeconds(10), "none"));
  12. tracingConfig.setExporter(exporterConfig);

Feedback

Was this page helpful?

Yes No

Last modified September 30, 2024: Update & Translate Overview Docs (#3040) (d37ebceaea7)