Skip to content

fix(active-record): avoid error spans for handled RecordInvalid#2087

Open
aviralgarg05 wants to merge 3 commits intoopen-telemetry:mainfrom
aviralgarg05:fix/issue-1459-active-record-recordinvalid-spans
Open

fix(active-record): avoid error spans for handled RecordInvalid#2087
aviralgarg05 wants to merge 3 commits intoopen-telemetry:mainfrom
aviralgarg05:fix/issue-1459-active-record-recordinvalid-spans

Conversation

@aviralgarg05
Copy link
Copy Markdown

@aviralgarg05 aviralgarg05 commented Mar 16, 2026

Summary

This PR fixes issue #1459 by preventing low-signal error spans for app-handled ActiveRecord bang persistence exceptions.

What changed

  • save!, create!, and update! now close spans and re-raise configured handled exceptions outside the span.
  • Default handled exception list remains narrow: [ActiveRecord::RecordInvalid].
  • Added optional configuration: handled_exceptions, which can include entries like ActiveRecord::RecordNotFound when teams explicitly want that behavior.

Why this is in scope

  • Default behavior still targets the original issue for RecordInvalid.
  • Reviewer feedback about configurability is implemented without broadening defaults.

Tests

  • RecordInvalid is suppressed for save!, create!, and update!.
  • Non-handled exceptions still emit exception events.
  • Configured handled exception behavior is covered by tests.

Copy link
Copy Markdown
Member

@dmathieu dmathieu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about other errors that usually don't raise either, such as RecordNotFound?
Should the list of exceptions be configurable?

@aviralgarg05 aviralgarg05 changed the title fix(active_record): avoid error spans for handled RecordInvalid fix(active-record): avoid error spans for handled RecordInvalid Mar 17, 2026
@aviralgarg05
Copy link
Copy Markdown
Author

What about other errors that usually don't raise either, such as RecordNotFound? Should the list of exceptions be configurable?

Applied these as well

@github-actions
Copy link
Copy Markdown
Contributor

👋 This pull request has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the keep label to hold stale off permanently, or do nothing. If you do nothing this pull request will be closed eventually by the stale bot

@github-actions github-actions Bot added the stale Marks an issue/PR stale label Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants