Link Tracing

End-to-End Tracing

Dubbo-go supports end-to-end tracing based on the OpenTelemetry standard, while also supporting export to different tracing backend systems through the following exporters.

Usage

Please note that tracing functionality is only enabled when creating the Dubbo application via dubbo.NewInstance, which is the microservice application mode mentioned in our quick start. The lightweight RPC API does not currently support enabling tracing.

Example Explanation

You can view the full example source code here.

Enable tracing using dubbo.WithTracing(), and you can control tracing behavior with multiple parameters:

  1. package main
  2. import (
  3. "dubbo.apache.org/dubbo-go/v3"
  4. _ "dubbo.apache.org/dubbo-go/v3/imports"
  5. "dubbo.apache.org/dubbo-go/v3/otel/trace"
  6. )
  7. func main() {
  8. instance, err := dubbo.NewInstance(
  9. dubbo.WithTracing(
  10. // add tracing options here
  11. trace.WithEnabled(), // enable tracing feature
  12. trace.WithStdoutExporter(),
  13. trace.WithW3cPropagator(),
  14. trace.WithAlwaysMode(),
  15. trace.WithRatioMode(), // use ratio mode
  16. trace.WithRatio(0.5), // sample ratio, only active when using ratio mode
  17. ),
  18. )
  19. }

If you do not specify any option parameters in the dubbo.WithTracing() call, the default behavior will be used:

  1. # default tracing config
  2. enable: false
  3. exporter: stdout
  4. endpoint: ""
  5. propagator: w3c
  6. sample-mode: ratio
  7. sample-ratio: 0.5

TracingOptions Explained

  • enable: enable tracing or not
    • trace.WithEnabled() means enable tracing
  • exporter: tracing exporter backends, support stdout, jaeger, zipkin, otlp-http, otlp-grpc
    • trace.WithStdoutExporter()
    • trace.WithJaegerExporter()
    • trace.WithZipkinExporter()
    • trace.WithOtlpHttpExporter()
    • trace.WithOtlpGrpcExporter()
  • endpoint: exporter backend endpoint, for example, jaeger exporter’s endpoint is http://localhost:14268/api/traces
    • trace.WithEndpoint(string)
  • propagator: context propagator type, supports w3c, b3; more details you can see here
    • trace.WithW3cPropagator()
    • trace.WithB3Propagator() zipkin exporter defaults to using this
  • sample-mode: sample mode, support ratio, always, never
    • trace.WithAlwaysMode()
    • trace.WithNeverMode()
    • trace.WithRatioMode()
  • sample-ratio: sample ratio, only used when sample-mode is ratio, range between 0 and 1
    • trace.WithRatio(float64)

Feedback

Was this page helpful?

Yes No

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