OTLP HTTP exporter reports a 3xx response as a successful export, so redirected batches are dropped without any log

未关闭 适合新手
#5,865 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

@d4rshnn 已经在做这个了。

开始于 2026年10月31日。

  • #5868 来自 @d4rshnn —— 未关闭
  • #5905 来自 @2Zest —— 已关闭,未合并
  • #5911 来自 @2Zest —— 已关闭,未合并

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
observability

调研方向

从 exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/http.py 中的共享 exporter 逻辑入手,尤其关注 issue 中链接的代码行。检查现有的 HTTP 导出状态处理测试,然后验证 3xx 响应会产生 SpanExportResult.FAILURE 和错误日志,而成功响应仍会被视为成功。

由索引模型根据 Issue 内容生成。

描述

bug
Describe your environment

OS: macOS (Darwin 25.5.0)
Python version: 3.14.6
SDK version: 1.45.1 (opentelemetry-exporter-otlp-proto-http 1.45.1, opentelemetry-exporter-otlp-common 0.66b1, opentelemetry-exporter-http-transport 0.66b1)
API version: 1.45.1

What happened?

Redirections are not followed and are not logged as error. It makes the batches silently dropped.

Both HTTP transports turn off redirects since #5194.
The shared exporter code still counts any status from 200 to 399 as success. So a 308 comes back as SpanExportResult.SUCCESS, nothing is logged and the batch is lost.

https://github.com/open-telemetry/opentelemetry-python/blob/3462000f323b4f3d03c10d09b9d82c03119f2c59/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/http.py#L203-L218

Steps to Reproduce

The following code runs a server that always redirects and tries to export to that server. The export is successful.

import logging
import threading
from http.server import BaseHTTPRequestHandler, HTTPServer

from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace import TracerProvider

logging.basicConfig(level=logging.DEBUG)

class AlwaysRedirect(BaseHTTPRequestHandler):
    def do_POST(self):
        self.rfile.read(int(self.headers["Content-Length"]))
        self.send_response(308)
        self.send_header("Location", "/elsewhere/v1/traces")
        self.send_header("Content-Length", "0")
        self.end_headers()


server = HTTPServer(("127.0.0.1", 0), AlwaysRedirect)
threading.Thread(target=server.serve_forever, daemon=True).start()

span = TracerProvider().get_tracer("repro").start_span("span")
span.end()

exporter = OTLPSpanExporter(endpoint=f"http://127.0.0.1:{server.server_port}/v1/traces")
print("export result:", exporter.export([span]))
Expected Result

The export is reported as failed (SpanExportResult.FAILURE) with an error log.

Actual Result

The export is successful but nothing is really exported and batches are lost.

Additional context

No response

Would you like to implement a fix?

No response

Tip

No response

主要语言
Python
星标
2.7k
派生
1.1k
平均合并
4 天 13 分钟
30 天内合并 PR
38

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

open-telemetry/opentelemetry-python 的其他 Issue

查看 open-telemetry/opentelemetry-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。