OpenTracing example
It's an example implementation for my article on https://pgillich.medium.com/multi-hop-tracing-with-opentelemetry-in-golang-792df5feb37c
docker run -d --name jaeger -e COLLECTOR_ZIPKIN_HOST_PORT=:9411 -e COLLECTOR_OTLP_ENABLED=true -p 6831:6831/udp -p 6832:6832/udp -p 5778:5778 -p 16686:16686 -p 4317:4317 -p 4318:4318 -p 14250:14250 -p 14268:14268 -p 14269:14269 -p 9411:9411 jaegertracing/all-in-one:1.38
git clone https://github.com/pgillich/opentracing-example.git
Compiling the binary (Go 1.18):
go build
Example commands to the servers:
LISTENADDR=127.0.0.1:55501 INSTANCE=backend-1 ./opentracing-example backend --response PONG_1 &
LISTENADDR=127.0.0.1:55502 INSTANCE=backend-2 ./opentracing-example backend --response PONG_2 &
LISTENADDR=127.0.0.1:55500 INSTANCE=frontend ./opentracing-example frontend &
Example command to run client:
SERVER=127.0.0.1:55500 INSTANCE=client-1 ./opentracing-example client http://127.0.0.1:55501/ping http://127.0.0.1:55502/ping http://127.0.0.1:55502/ping
Example command to send request to frontend without client:
curl -X GET http://127.0.0.1:55500/proxy --data-binary 'http://127.0.0.1:55501/ping http://127.0.0.1:55502/ping http://127.0.0.1:55502/ping'
Test cases are in test/e2e_test.go
.
Below examples are working with https://github.com/pgillich/kind-on-dev/tree/1.24.
Add below line to /etc/hosts
similar to:
172.18.255.128 opentracing-example.kind-01.company.com
make build image
kind load docker-image pgillich/opentracing-example:v0.0.1 --name demo
sync && echo 3 | sudo tee /proc/sys/vm/drop_caches
Running servers:
kubectl apply -k deployments/kustomize/
Running client:
SERVER=opentracing-example.kind-01.company.com INSTANCE=client-1 JAEGERURL=http://jaeger-collector.kind-01.company.com/api/traces ./build/bin/opentracing-example client http://backend:55501/ping http://backend:55501/ping http://backend:55501/ping