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

能否通过PutTraceSegments将追踪段发送至OTel Collector的AWS X-Ray端点?

问题:能否将追踪段发送至OpenTelemetry Collector的AWS X-Ray端点?

我尝试使用PutTraceSegments函数发送来自Lambda、API网关等服务的追踪数据到OpenTelemetry Collector,配置AWS SDK自定义端点后未检测到错误,收到的响应显示{"UnprocessedTraceSegments":[]},但始终看不到已发送的追踪数据。


我的配置代码

AWS SDK Go 配置

cfg, err := config.LoadDefaultConfig(ctx,
            config.WithRegion(region),
            config.WithRetryMaxAttempts(maxRetries),
            config.WithEndpointResolverWithOptions(customEndpoint),
            config.WithClientLogMode(aws.LogRequestWithBody|aws.LogResponseWithBody))

自定义端点配置

customEndpoint := aws.EndpointResolverWithOptionsFunc(func(service, region string, options ...interface{}) (aws.Endpoint, error) {
    return aws.Endpoint{
        PartitionID:   "aws",
        SigningRegion: "region",
        Source:        aws.EndpointSourceCustom,
        URL:           "http://collector-endpoint:2000/",
    }, nil
})

收到的响应

HTTP/1.1 200 OK
Content-Type: application/json
{"UnprocessedTraceSegments":[]}

OpenTelemetry Collector 配置

receivers:
  awsxray:
    endpoint: 0.0.0.0:2000
    transport: udp
exporters:
  awsxray:
    region: us-east-1
service:
  pipelines:
    traces:
      receivers: [awsxray]
      exporters: [awsxray]

问题排查与解决

1. 传输协议不匹配是核心原因

AWS SDK的PutTraceSegments接口基于HTTP/HTTPS发送请求,但你的OTel Collector awsxray接收器配置的是UDP传输——UDP模式是X-Ray daemon的专属协议,无法接收HTTP请求,导致数据根本没被Collector正确接收。

2. 修改OTel Collector接收器配置

将awsxray接收器的传输方式改为HTTP:

receivers:
  awsxray:
    endpoint: 0.0.0.0:2000
    transport: http  # 替换原有的udp配置
exporters:
  awsxray:
    region: us-east-1
service:
  pipelines:
    traces:
      receivers: [awsxray]
      exporters: [awsxray]

3. 校准SDK端点配置细节

  • 确认collector-endpoint是可访问的有效地址:如果SDK运行在容器环境,不要用localhost,改用Collector的容器名称或宿主机IP
  • 统一签名区域:将SDK配置中的SigningRegion: "region"替换为实际区域(比如us-east-1),和Collector exporter的区域保持一致
  • 端点URL末尾的斜杠不影响,但确保没有拼写错误

4. 验证Collector运行状态

重启Collector后,查看日志是否有接收到请求的记录。配置正确的情况下,会出现类似"Received X-Ray trace segment"的日志,说明数据已进入Collector,随后会由exporter转发到AWS X-Ray,此时就能在X-Ray控制台看到追踪数据了。


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.16 03:20:14