The following scenario is implemented here.
We want to trace a sample transaction that spans over four service.
It starts at service A, passes B and C, and ends at service D.
As the trace starts at service A, the dapr sidecar of A creates the Trace ID and appends
it as request header (called traceparent
) when requesting service B.
Then, service B has to manually forward this header when requesting service C.
C also has to forward this header manually when requesting service D.
This is propagating sequential service calls.
All tracing operations like creation and reporting to Jaeger via Zipkin collector are done by dapr,
which is explicitly configured to do distributed tracing using the tracing-config.yaml
.
- dapr CLI
- Java (Version >=17)
- A running Jaeger instance
docker run \ -e COLLECTOR_ZIPKIN_HOST_PORT=:9412 \ -p 16686:16686 \ -p 9412:9412 \ jaegertracing/all-in-one
./gradlew buildAllServices
dapr run --app-id a-service --app-port 8080 --app-protocol http --dapr-http-port 3500 --config tracing-config.yaml -- java -cp a/build/libs/fat.jar org.example.AKt
dapr run --app-id b-service --app-port 8081 --app-protocol http --dapr-http-port 3501 --config tracing-config.yaml -- java -cp b/build/libs/fat.jar org.example.BKt
dapr run --app-id c-service --app-port 8082 --app-protocol http --dapr-http-port 3502 --config tracing-config.yaml -- java -cp c/build/libs/fat.jar org.example.CKt
dapr run --app-id d-service --app-port 8083 --app-protocol http --dapr-http-port 3503 --config tracing-config.yaml -- java -cp d/build/libs/fat.jar org.example.DKt
As you can see, the dapr CLI is used to start up both, the dapr sidecar and the service.
curl http://localhost:8080/
Visit http://localhost:16686/