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.
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.
You can view the full example source code here.
Enable tracing using dubbo.WithTracing()
, and you can control tracing behavior with multiple parameters:
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 using ratio mode
),
)
}
If you do not specify any option parameters in the dubbo.WithTracing()
call, the default behavior will be used:
# 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/traces
trace.WithEndpoint(string)
trace.WithW3cPropagator()
trace.WithB3Propagator()
zipkin exporter defaults to using thistrace.WithAlwaysMode()
trace.WithNeverMode()
trace.WithRatioMode()
trace.WithRatio(float64)