You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SpringBoot 2.5集成OpenTelemetry与Jaeger无追踪数据求助

排查步骤与解决方案

1. 修正OpenTelemetry Collector接收器监听地址

你的Collector配置中,OTLP gRPC接收器的endpoint设置为otel-collector:4317,这会导致Collector仅监听容器内部的服务名地址,外部(本地运行的Spring Boot应用)的请求无法进入容器。修改otel-collector-config.yml的接收器配置:

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317  # 监听所有网络接口

修改后重启Collector容器:docker-compose restart otel-collector

2. 完善Spring Boot OTLP导出配置

确保应用正确配置OTLP导出的必要参数,在application.properties中添加:

# 确保追踪导出开启
sleuth.otel.exporter.otlp.trace.enabled=true
# 设置采样率为100%,避免部分请求不被导出
sleuth.sampler.probability=1.0
# 明确指定使用gRPC协议(默认是gRPC,但显式设置更稳妥)
sleuth.otel.exporter.otlp.protocol=grpc

3. 检查依赖版本兼容性

Spring Cloud Sleuth OTel与OpenTelemetry依赖版本需匹配,避免因版本冲突导致导出失败:

  • 确认spring-cloud-sleuth-otel-autoconfigure的版本与Spring Boot版本兼容(例如Spring Boot 2.7.x对应Spring Cloud 2021.0.x版本)
  • 移除手动指定的grpc-okhttp版本,让Sleuth OTel管理依赖版本,避免版本不一致:
<!-- 移除这个手动指定版本的依赖 -->
<!--
<dependency>
    <groupId>io.grpc</groupId>
    <artifactId>grpc-okhttp</artifactId>
    <version>1.42.1</version>
</dependency>
-->

4. 检查Collector与Jaeger的连通性及日志

查看Collector的运行日志,确认是否有数据接收或导出错误:

# 获取Collector容器ID并查看日志
docker ps | grep otel-collector
docker logs <容器ID>

如果日志中有类似connection refused或export failed的错误,检查Jaeger容器是否正常运行,以及Collector的Jaeger exporter配置是否正确(当前配置的jaeger-all-in-one:14250在Docker Compose网络中是正确的)。

5. 验证本地应用到Collector的连通性

测试本地Spring Boot应用是否能连接到Collector的4317端口:

# 使用telnet测试(需提前安装telnet)
telnet localhost 4317
# 或使用grpcurl(需安装)查看Collector的服务状态
grpcurl -plaintext localhost:4317 list

如果连接失败,检查Docker Compose的端口映射是否正确(当前4317:4317是正确的),以及防火墙是否阻止了该端口的访问。


内容的提问来源于stack exchange,提问作者EnricoNiccoli

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.03 18:12:12