tracing

Tracing records the life cycle of a request execution in the system, including the request and its sub-procedure call links, execution time and statistics, which can be used for slow query location, performance bottleneck analysis, etc.

Principle

doris is responsible for collecting traces and exporting them to a third-party tracing analysis system, which is responsible for the presentation and storage of traces.

Quick Start

doris currently supports exporting traces directly to zipkin.

Deploy zipkin

  1. curl -sSL https://zipkin.io/quickstart.sh | bash -s
  2. java -jar zipkin.jar

Configuring and starting Doris

Add configuration to fe.conf

  1. enable_tracing = true
  2. # Configure traces to export to zipkin
  3. trace_export_url = http://127.0.0.1:9411/api/v2/spans

Add configuration to be.conf

  1. enable_tracing = true
  2. # Configure traces to export to zipkin
  3. trace_export_url = http://127.0.0.1:9411/api/v2/spans
  4. # Queue size for caching spans. span export will be triggered once when the number of spans reaches half of the queue capacity. spans arriving in the queue will be discarded when the queue is full.
  5. max_span_queue_size=2048
  6. # The maximum number of spans to export in a single pass.
  7. max_span_export_batch_size=512
  8. # Maximum interval for exporting span
  9. export_span_schedule_delay_millis=500

Start fe and be

  1. sh fe/bin/start_fe.sh --daemon
  2. sh be/bin/start_be.sh --daemon

Executing a query

  1. ...

View zipkin UI

The browser opens http://127.0.0.1:9411/zipkin/ to view the query tracing.

Using opentelemetry collector

Use the opentelemetry collector to export traces to other systems such as zipkin, jaeger, skywalking, or to database systems and files. For more details, refer to collector exporter.

Meanwhile, opentelemetry collector provides a rich set of operators to process traces. For example, filterprocessor , tailsamplingprocessor. For more details, refer to collector processor.

traces export path: doris->collector->zipkin etc.

Deploy opentelemetry collector

opentelemetry has released collector core and contrib, contrib provides richer features, here is an example of contrib version.

Download collector

Download otelcol-contrib, available on the official website more precompiled versions for more platforms

  1. wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.55.0/otelcol-contrib_0.55.0_linux_amd64.tar.gz
  2. tar -zxvf otelcol-contrib_0.55.0_linux_amd64.tar.gz

Generate configuration file

The collector configuration file is divided into 5 parts: receivers, processors, exporters, extensions, and service. Among them, receivers, processors and exporters define the way to receive, process and export data respectively; extensions are optional and are used to extend tasks that do not involve processing telemetry data; service specifies which components are used in the collector. See collector configuration.

The following configuration file uses the otlp (OpenTelemetry Protocol) protocol to receive traces data, perform batch processing and filter out traces longer than 50ms, and finally export them to zipkin and file.

  1. cat > otel-collector-config.yaml << EOF
  2. receivers:
  3. otlp:
  4. protocols:
  5. http:
  6. exporters:
  7. zipkin:
  8. endpoint: "http://10.81.85.90:8791/api/v2/spans"
  9. file:
  10. path: ./filename.json
  11. processors:
  12. batch:
  13. tail_sampling:
  14. policies:
  15. {
  16. name: duration_policy,
  17. type: latency,
  18. latency: {threshold_ms: 50}
  19. }
  20. extensions:
  21. service:
  22. pipelines:
  23. traces:
  24. receivers: [otlp]
  25. processors: [batch, tail_sampling]
  26. exporters: [zipkin, file]
  27. EOF

Start collector

  1. nohup ./otelcol-contrib --config=otel-collector-config.yaml &

Configuring and starting Doris

Add configuration to fe.conf

  1. enable_tracing = true
  2. # enable opentelemetry collector
  3. trace_exporter = collector
  4. # Configure traces export to collector, 4318 is the default port for collector otlp http
  5. trace_export_url = http://127.0.0.1:4318/v1/traces

Add configuration to be.conf

  1. enable_tracing = true
  2. # enable opentelemetry collector
  3. trace_exporter = collector
  4. # Configure traces export to collector, 4318 is the default port for collector otlp http
  5. trace_export_url = http://127.0.0.1:4318/v1/traces
  6. # Queue size for caching spans. span export will be triggered once when the number of spans reaches half of the queue capacity. spans arriving in the queue will be discarded when the queue is full.
  7. max_span_queue_size=2048
  8. # The maximum number of spans to export in a single pass.
  9. max_span_export_batch_size=512
  10. # Maximum interval for exporting span
  11. export_span_schedule_delay_millis=500

Start fe and be

  1. sh fe/bin/start_fe.sh --daemon
  2. sh be/bin/start_be.sh --daemon

Executing a query

  1. ...

View zipkin UI

  1. ...