🐛 cfRay is missing from proxied request logs (newHTTPLogger discards the zerolog context)
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 82/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- go
調査の方向性
proxy/logger.go の newHTTPLogger から始めてください。cfRay と lbProbe の呼び出しで戻り値が破棄されている箇所です。結果を ctx に代入し直し、そのうえで proxy パッケージに回帰テストを追加して、cfRay と lbProbe がログに記録されたフィールドに現れることを確認してください。現在のコードでそのテストが失敗し、変更後に成功すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
The per-request log lines emitted by the proxy never include the cfRay field (nor lbProbe for load balancer health probes), even when the request carries a Cf-Ray header. This affects the origin request error line (logRequestError) and the debug request/response lines (logHTTPRequest / logOriginHTTPResponse), so a cloudflared log line can't be correlated with the same request in Cloudflare's edge logs (Logpush RayID) or in origin access logs.
Root cause: newHTTPLogger in proxy/logger.go calls ctx.Str / ctx.Bool without assigning the result. zerolog.Context methods have value receivers and return the updated context, so both fields are dropped:
if cfRay != "" {
ctx.Str(logFieldCFRay, cfRay) // returned context is discarded
}
if lbProbe {
ctx.Bool(logFieldLBProbe, lbProbe) // returned context is discarded
}
https://github.com/cloudflare/cloudflared/blob/2026.10.0/proxy/logger.go#L35-L40
This came in with 971360d5e0b97c41f1cffd4b79c79a05e6a5e91b (TUN-8238: Refactor proxy logging), first released in 2024.2.1. Before that, the same error line did include it, e.g. in #1012: error="Incoming request ended abruptly: context canceled" cfRay=7e0bcd892f8d4dc8-SIN event=1 originService=....
To Reproduce
Steps to reproduce the behavior:
- Run a tunnel with any HTTP ingress rule, with JSON logs to make the fields easy to see:
cloudflared tunnel --output json run <TUNNEL> - Send a request through the tunnel that fails at the origin (for example, a client that disconnects before the origin responds, or an ingress rule pointing at a port with nothing listening).
- Look at the
"event":1log line for that request: there is nocfRayfield.
With --loglevel debug, the "event":1 request and response lines are missing cfRay as well.
If it's an issue with Cloudflare Tunnel:
4. Tunnel ID : not tunnel-specific, reproducible with any tunnel
5. cloudflared config: any HTTP ingress rule
Expected behavior
Per-request log lines include "cfRay":"<ray id>" (and "lbProbe":true for load balancer health probes), as newHTTPLogger intends.
Environment and versions
- OS: Linux (Kubernetes,
cloudflare/cloudflaredcontainer image) - Architecture: AMD64 and ARM64
- Version: 2026.10.0 (affects every release since 2024.2.1)
Logs and errors
Origin request error line from 2026.10.0 (hostname anonymised):
{"connIndex":1,"error":"Incoming request ended abruptly: context canceled","event":1,"ingressRule":9,"level":"error","originService":"https://origin.example.com","time":"2026-10-08T09:44:53Z"}
connIndex, originService and ingressRule from the same logger context are present; cfRay is not.
Additional context
The fix is a two-line change (ctx = ctx.Str(...) / ctx = ctx.Bool(...)). I'll open a PR with it and a regression test that fails on master and passes with the change.
- 主要言語
- Go
- スター
- 16.1k
- フォーク
- 1.5k
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
cloudflare/cloudflared のほかの issue
-
🐛 --output json writes invalid JSON lines when events are logged concurrently対応中かも @theolujay が 8 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
cloudflare/cloudflared#1761 · コメント 5 件 ·
メンテナーはふだん 1 日以内に返信
-
🐛 After SIGTERM, `cloudflared tunnel run` uses 100% of one CPU core for the whole graceful-shutdown period対応中かも @cyphercodes が 11 日前に担当しました。 オープンPriority: Normal Type: Bug
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
cloudflare/cloudflared#1753 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
tunnel route ip show: --filter-network-is-subset-of sends the superset filter対応中かも @wangyusheng1985 が 11 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 92/100
cloudflare/cloudflared#1750 ·
メンテナーはふだん 1 日以内に返信
-
🐛 QUIC Hijack() skips the status-written check that HTTP/2 enforces対応中かも @dedsec-terminal が 4 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
cloudflare/cloudflared#1748 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
🐛 QUIC Hijack() skips the status-written check that HTTP/2 enforces対応中かも @Asthenia0412 が 21 日前に担当しました。 オープンPriority: Normal Type: Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
cloudflare/cloudflared#1747 ·
メンテナーはふだん 1 日以内に返信
cloudflare/cloudflared の issue をすべて見る
似ている issue
-
[Bug]: message-level cache_control on chat messages is dropped, so Anthropic prompt caching never triggers対応中かも @Atharva-Kanherkar が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
メンテナーはふだん 1 日以内に返信
-
documentation good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
eugenioenko/ttt#1000 ·
メンテナーはふだん 1 日以内に返信
-
bug needs-acceptance wg/developer-experience-ecosystem
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
vllm-project/semantic-router#5249 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Billionmail/BillionMail#389 ·
-
在“产品文档”下拉列表,增加“探索”频道オープンenhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
DaoCloud/DaoCloud-docs#7489 ·
メンテナーはふだん 1 日以内に返信