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

@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
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
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants