跳到主要内容

Jaeger trace 接入

配置

示例:configs/config_trace_jaeger.json

{
"tracing": {
"enable": true,
"driver": "jaeger",
"config": {
"service_name": "layotto"
}
}
}
字段必填说明
service_nameY服务名称
agent_hostNagent组件端口
strategyN数据上报方式,默认使用 collector 方式. 可选的配置值有collectoragent
collector_endpointNcollector的端口号,默认http://127.0.0.1:14268/api/traces

运行Jaeger

cd ${project_path}/diagnostics/jaeger

docker-compose -f jaeger-docker-compose.yaml up -d

运行layotto

可以按照如下方式启动一个layotto的server:

切换目录:

cd ${project_path}/cmd/layotto_multiple_api

构建:

go build -o layotto

运行:

./layotto start -c ../../configs/config_trace_jaeger.json 

运行 Demo

对应的调用端代码在client.go 中,运行它会调用layotto的SayHello接口:

切换目录:

 cd ${project_path}/demo/flowcontrol/

构建:

 go build -o client

运行:

./client

访问 http://localhost:16686

img.png

清理资源

cd ${project_path}/diagnostics/jaeger

docker-compose -f jaeger-docker-compose.yaml down