Events dropped client-side for size are only logged at debug level and not recorded as lost

未關閉 適合新手
#3,209 2 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 2 天內回覆

@sentry-junior 已經在處理了。

開始於 2026年11月16日。

  • #3210 來自 @sentry-junior —— 未關閉

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
76/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
ruby

研究方向

從 sentry-ruby/lib/sentry/transport.rb 中 Transport#serialize_envelope 附近開始,比較丟棄過大項目的路徑與 #2885 新增的 413 處理。檢查遺失事件和已丟棄事件統計如何記錄,然後為這次丟棄加入同等的可觀測性。完成條件是:過大項目以 warn 層級記錄,並被記錄為遺失;請確認重現結果中的已丟棄事件不為空。

由索引模型根據 Issue 內容生成。

描述

Bug Junior: repro Ruby
Issue Description

When an envelope item is still larger than MAX_SERIALIZED_PAYLOAD_SIZE after Envelope::Item#serialize has removed breadcrumbs and reduced the stacktrace, Transport#serialize_envelope skips it with a log_debug and nothing else:

https://github.com/getsentry/sentry-ruby/blob/master/sentry-ruby/lib/sentry/transport.rb#L77-L82

Since the event is never sent, Relay never sees it, so it doesn't show up in the invalid payload stats either. And unlike the 413 path added in #2885, no client report is recorded. With the SDK logger at the usual info level, the event is lost without any trace.

The size reduction doesn't touch extra or contexts, so a large custom payload is enough to hit this. In our case, a scheduled job reported a list of record ids in extra - the list was about 3 MB, and the event never arrived. We only noticed because we knew a report should arrive, and were confused why none did arrive.

#2381 asked for truncation of custom contexts and was declined in favor of server-side handling, with a pointer to the invalid payload stats. That makes sense for truncation, but these events never reach the server, so the stats can't show them. This issue is only about making the drop visible.

Reproduction Steps
require "logger"
gem "sentry-ruby", "7.2.0"
require "sentry-ruby"

Sentry.init do |config|
  config.dsn = "http://[email protected]:9/1" # nothing listens here; the event is dropped before any request
  config.background_worker_threads = 0
  config.sdk_logger = Logger.new($stdout, level: ENV.fetch("LOG_LEVEL", "info"))
end

Sentry.capture_message("Found records", extra: { ids: (1..200_000).to_a })

puts "discarded events: #{Sentry.get_current_client.transport.instance_variable_get(:@discarded_events).inspect}"
Expected Behavior
  • The drop is logged at warn level, like the 413 response.
  • A lost event is recorded (e.g. record_lost_event(:send_error, item.data_category, num: item.item_count, num_bytes: item.lost_event_byte_size), as in the 413 path), so it shows up in the org's stats.
Actual Behavior

With LOG_LEVEL=info, the script prints only:

discarded events: {}

With LOG_LEVEL=debug, the drop is logged, but still no lost event is recorded:

DEBUG -- sentry: Envelope item [event] is still oversized after size reduction: {event_id: 34, level: 7, timestamp: 22, environment: 13, server_name: 19, modules: 13408, message: 15, user: 2, tags: 2, contexts: 525, extra: 1288904, fingerprint: 2, platform: 6, sdk: 40, type: 7, threads: 1654}
discarded events: {}
Ruby Version

4.0.9

SDK Version

7.2.0

Integration and Its Version

Reproducible with plain sentry-ruby; we noticed it in Rails 8.1 with sentry-rails and sentry-sidekiq 7.2.0.

Sentry Config

No response

主要語言
Ruby
星號
990
分支
552
平均合併
2 天 16 小時
30 天內合併 PR
29

環境準備

在 Codespaces 中開啟

在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

getsentry/sentry-ruby 的其他 Issue

查看 getsentry/sentry-ruby 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。