Events dropped client-side for size are only logged at debug level and not recorded as lost
メンテナーはふだん 2 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 76/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- ruby
- 領域
- backend, observability
調査の方向性
sentry-ruby/lib/sentry/transport.rb の Transport#serialize_envelope 付近から始め、サイズ超過アイテムを破棄する経路と、#2885 で追加された 413 の処理を比較してください。失われたイベントと破棄されたイベントの統計がどのように記録されるかを確認し、この破棄についても同等の可視性を追加してください。サイズ超過アイテムが warn レベルでログに記録され、失われたものとして記録されれば完了です。再現時に、破棄されたイベントの結果が空でないことを確認してください。
索引モデルが issue の本文から書いたものです。
説明
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
warnlevel, 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時間
- マージ済み PR(30日)
- 29
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
getsentry/sentry-ruby のほかの issue
-
Bug Ruby
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
getsentry/sentry-ruby#3211 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
with_child_span drops spans when blocks exit via break, return, or throw対応中かも @itsrayeedscodespace が 1 日前に担当しました。 オープンBug Ruby Traces Waiting for: Product Owner
難易度 2/5 1〜3時間 初心者へのやさしさ 38/100
getsentry/sentry-ruby#3206 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
Let apps choose how the client IP on events is determined対応中かも @sl0thentr0py が 11 日前に担当しました。 オープンImprovement Ruby
getsentry/sentry-ruby#3180 · コメント 2 件 · リアクション 1 件 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
-
breaking change Next Major
難易度 2/5 1〜3時間 初心者へのやさしさ 58/100
getsentry/sentry-ruby#3176 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
With `register_error_subscriber`, view errors are reported twice: the wrapper by the middleware, and its cause by the error subscriber対応中かも @sl0thentr0py が 13 日前に担当しました。 オープンBug Ruby
難易度 4/5 1〜2日 初心者へのやさしさ 57/100
getsentry/sentry-ruby#3166 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
getsentry/sentry-ruby の issue をすべて見る
似ている issue
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
internetee/registry#2984 ·
メンテナーはふだん 6 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
ecosyste-ms/issues#862 ·
メンテナーはふだん 1 日以内に返信
-
Redis Lua error `@user_script:52: ERR value is not an integer or out of range` when `window_size` is configured対応中かも @mimosa が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
riscv/riscv-unified-db#2829 ·
メンテナーはふだん 1 日以内に返信
-
⛓️ Security Difficulty: Easy Good First Issue Help Wanted ruby Type: Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
rubyforgood/casa#7404 ·
メンテナーはふだん 1 日以内に返信