在go-zero demo中集成jaeger
go-zero 框架已经对 jaeger 等 opentelemetry
框架进行了集成,本文介绍如何配置 jaeger 参数,以便在 go-zero demo 中使用 jaeger 实现 tracing。
以已经实现的 go-zero demo 为基础,添加 jaeger 配置:
Telemetry:
Name: search-api
Endpoint: http://localhost:14268/api/traces
Sampler: 1.0
Batcher: jaeger
Telemetry:
Name: user-api
Endpoint: http://localhost:14268/api/traces
Sampler: 1.0
Batcher: jaeger
Telemetry:
Name: user-rpc
Endpoint: http://localhost:14268/api/traces
Sampler: 1.0
Batcher: jaeger
docker run -d --name jaeger \
-e COLLECTOR_ZIPKIN_HOST_PORT=:9411 \
-p 5775:5775/udp \
-p 6831:6831/udp \
-p 6832:6832/udp \
-p 5778:5778 \
-p 16686:16686 \
-p 14250:14250 \
-p 14268:14268 \
-p 14269:14269 \
-p 9411:9411 \
jaegertracing/all-in-one:1.30
- 获取登录 token
curl -k -v POST localhost:8888/users -d '{"name": "bzz", "password": "bzz@1234"}' -H 'content-type: application/json'
- 获取用户名密码
curl -k -v -X GET localhost:8889/users/name/bzz -d '{"name": "bzz"}' -H 'content-type: application/json' -H 'authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NDQ4MjkzNTIsImlhdCI6MTY0NDc0Mjk1MiwidXNlcklkIjoxfQ.QBlfWDMTqFEeYl6yWF7d0MqgCayKtm5Q94_z4_CHkE4'
- 登录 jaeger ui:
http://localhost:16686
- 查看本地调用相关 tracing: