Dubbo-go supports OpenTelemetry tracing.
To use the tracing feature, you need to use dubbo.NewInstance to create a Dubbo instance.
If you create server and client directly, only basic RPC feature can be enabled.
To config tracing, you need to use dubbo.WithTracing as an option of dubbo.NewInstance. In dubbo.WithTracing, you can add more options to config tracing module.
And the dubbo.apache.org/dubbo-go/v3/imports must be imported.
package main import ( "dubbo.apache.org/dubbo-go/v3" _ "dubbo.apache.org/dubbo-go/v3/imports" "dubbo.apache.org/dubbo-go/v3/otel/trace" ) func main() { instance, err := dubbo.NewInstance( dubbo.WithTracing( // add tracing options here trace.WithEnabled(), // enable tracing feature trace.WithStdoutExporter(), trace.WithW3cPropagator(), trace.WithAlwaysMode(), trace.WithRatioMode(), // use ratio mode trace.WithRatio(0.5), // sample ratio, only active when use ratio mode ), ) }
If you don't add any options in dubbo.WithTracing, default tracing config will be used. Default tracing config is shown below.
# default tracing config enable: false exporter: stdout endpoint: "" propagator: w3c sample-mode: ratio sample-ratio: 0.5
trace.WithEnabled() means enable tracingtrace.WithStdoutExporter()trace.WithJaegerExporter()trace.WithZipkinExporter()trace.WithOtlpHttpExporter()trace.WithOtlpGrpcExporter()http://localhost:14268/api/tracestrace.WithEndpoint(string)trace.WithW3cPropagator()trace.WithB3Propagator() zipkin exporter default use thistrace.WithAlwaysMode()trace.WithNeverMode()trace.WithRatioMode()trace.WithRatio(float64)