go-zero中Telemetry的配置
go-zero中Telemetry的配置
使用 Jaeger 原生协议
Telemetry:
Name: gateway-api
Endpoint: http://localhost:14268/api/traces
Sampler: 0.1
Batcher: jaeger
Telemetry:
Name: user-rpc
Endpoint: http://localhost:14268/api/traces
Sampler: 0.1
Batcher: jaeger
对应 Jaeger 容器使用 14268 端口:
services:
# 添加 Elasticsearch 服务
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.9.0
container_name: elasticsearch_dev
environment:
- discovery.type=single-node
- xpack.security.enabled=false
- ES_JAVA_OPTS=-Xms1g -Xmx1g
- TZ=Asia/Shanghai
volumes:
- es_data:/usr/share/elasticsearch/data
ports:
- "9200:9200"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9200"]
interval: 10s
start_period: 60s # 首次检查前等待60秒
timeout: 5s
retries: 5
# 添加 Jaeger 服务
jaeger:
image: jaegertracing/all-in-one:1.53 # 使用支持 ES8 的版本
container_name: jaeger_dev
depends_on:
elasticsearch:
condition: service_healthy
environment:
- SPAN_STORAGE_TYPE=elasticsearch
- ES_SERVER_URLS=http://elasticsearch:9200
- ES_VERSION=8 # 明确指定 ES 版本
- LOG_LEVEL=info
- COLLECTOR_OTLP_ENABLED=true
- TZ=Asia/Shanghai
ports:
- "16686:16686"
- "14268:14268"
- "14269:14269"
- "6831:6831/udp"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:16686"]
interval: 20s
timeout: 5s
retries: 5
volumes:
es_data:
使用 gRPC 协议的 OTLP
Telemetry:
Name: gateway-api
# Endpoint: http://localhost:4317
# 这里不带 http://
Endpoint: localhost:4317
Sampler: 0.1
Batcher: otlpgrpc
Telemetry:
Name: user-rpc
Endpoint: localhost:4317
Sampler: 0.1
Batcher: otlpgrpc
使用 HTTP 协议的 OTLP
Telemetry:
Name: gateway-api
# 这里不带 http://
Endpoint: localhost:4318
Sampler: 0.1
Batcher: otlphttp
Telemetry:
Name: user-rpc
Endpoint: localhost:4318
Sampler: 0.1
Batcher: otlphttp
jaeger 容器使用 4317,4318 端口
jaeger:
image: jaegertracing/all-in-one:1.53 # 使用支持 ES8 的版本
container_name: jaeger_dev
depends_on:
elasticsearch:
condition: service_healthy
environment:
- SPAN_STORAGE_TYPE=elasticsearch
- ES_SERVER_URLS=http://elasticsearch:9200
- ES_VERSION=8 # 明确指定 ES 版本
- LOG_LEVEL=info
- COLLECTOR_OTLP_ENABLED=true
- TZ=Asia/Shanghai
ports:
- "16686:16686"
- "4317:4317"
- "4318:4318"
- "6831:6831/udp"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:16686"]
interval: 20s
timeout: 5s
retries: 5

浙公网安备 33010602011771号