Jaeger trace 接入
配置
示例:configs/config_trace_jaeger.json
{
"tracing": {
"enable": true,
"driver": "jaeger",
"config": {
"service_name": "layotto"
}
}
}
字段 | 必填 | 说明 |
---|---|---|
service_name | Y | 服务名称 |
agent_host | N | agent组件端口 |
strategy | N | 数据上报方式,默认使用 collector 方式. 可选的配置值有collector 和agent |
collector_endpoint | N | collector的端口号,默认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
清理资源
cd ${project_path}/diagnostics/jaeger
docker-compose -f jaeger-docker-compose.yaml down