Transaction status incorrectly reports 500 (internal_error) instead of actual HTTP status code (eg. 404) when Rails handles exceptions

オープン
#2,825 コメント 6 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

@sl0thentr0py がすでに取り組んでいます。

2026年1月8日 から。

  • #2848 @solnic による — マージされずにクローズ

評価

この issue はまだ評価されていません。

説明

Bug Ruby sentry-rails Spans
Issue Description

When Rails handles an exception internally and converts it to a specific HTTP status code (e.g., ActiveRecord::RecordNotFound -> 404), the Sentry transaction is incorrectly reported with status internal_error and http.response.status_code: 500 instead of the actual HTTP response status code.

This creates inaccurate reports, as all Rails-rescued exceptions appear as 500 errors in Sentry, even though the client receives the correct HTTP status code (404, 422, etc.).

The breadcrumbs in the transaction correctly show the actual status code (404), but the transaction-level status and span-level status codes are incorrect (500).

Even though version 6.0.0+ includes trace_ignore_status_codes which by default excludes 404s from being traced, this is a workaround rather than a fix. The underlying issue of incorrect status code reporting remains for any status codes that are not ignored.

Reproduction Steps
  1. Configure a Rails application with sentry-rails version 5.27.0
  2. Enable tracing with config.traces_sample_rate = 1.0
  3. Create a route that raises ActiveRecord::RecordNotFound or similar exception that Rails rescues and converts to a 404 response
  4. Make a request to that route
  5. Examine the transaction in Sentry
Expected Behavior
  • Span status should be "not_found"
  • Span data.http.response.status_code should be 404
Actual Behavior
  • Span status is "internal_error"
  • Span data.http.response.status_code is 500
Ruby Version

Ruby 3.4.4

SDK Version

sentry-ruby: 5.27.0

Integration and Its Version

No response

Sentry Config

No response

主要言語
Ruby
スター
990
フォーク
552
平均マージ
2日 16時間
マージ済み PR(30日)
29

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

getsentry/sentry-ruby のほかの issue

getsentry/sentry-ruby の issue をすべて見る

似ている issue

Ruby の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。