Skip to content

Caught AR validation errors are resulting in error spans #1459

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
renchap opened this issue Mar 27, 2025 · 1 comment
Open

Caught AR validation errors are resulting in error spans #1459

renchap opened this issue Mar 27, 2025 · 1 comment
Labels
help wanted Extra attention is needed instrumentation keep Ensures stale-bot keeps this issue/PR open

Comments

@renchap
Copy link

renchap commented Mar 27, 2025

Our app uses ActiveRecord validations (example), and uses some create! calls in the code (example controller action, and create!).

Then a record fails the validation, an exception is thrown, and is then caught and returned as an HTTP error, with the failed validations in the body (here).

This causes the OTEL instrumentation to generate traces where the User.create! span has an error attached, but the root span does not:

Image

This causes tools like Sentry or Datadog to create a new entry in their error tracking system, even if everything is handled in the app and the error is not actionable.

Using exceptions for such control flow is a common pattern in Rails, and as an application developer or operator, I expect that errors are things that needs to be reviewed and fixed, which is not the case here.

Note: there is a relevant discussion in the Slack channel

Possible discussed solutions are marking some exceptions (such as ActiveRecord::RecordInvalid or ActiveRecord:: RecordNotFound) as non-exceptional in the AR Validations instrumentation, or having a setting to prevent those spans to be errors entirely, allowing the app developer to explicitly indicate that those exceptions are handled correctly by the app (and if thats not the case, the root span should be an error anyway).

Copy link
Contributor

👋 This issue 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 issue will be closed eventually by the stale bot.

@github-actions github-actions bot added the stale Marks an issue/PR stale label Apr 27, 2025
@arielvalentin arielvalentin added help wanted Extra attention is needed instrumentation keep Ensures stale-bot keeps this issue/PR open and removed stale Marks an issue/PR stale labels Apr 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed instrumentation keep Ensures stale-bot keeps this issue/PR open
Projects
None yet
Development

No branches or pull requests

2 participants