Skip to content
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

Excluded Exceptions list does not play nice with Puma Auto Reload mechanism - dev environment issue #2227

Open
cgaube opened this issue Jan 12, 2024 · 3 comments
Assignees

Comments

@cgaube
Copy link

cgaube commented Jan 12, 2024

Issue Description

https://github.com/getsentry/sentry-ruby/blob/master/sentry-ruby/lib/sentry/configuration.rb#L595-L600

This comparison function returns false as soon as the puma server is auto reloaded - (when you change a file in your dev environment) because the reloaded class id will be different

Instead of using ===. we should probably compare the NAME of the exception

excluded_exception_class.to_s === cause.to_s

Reproduction Steps

--enable debugging logger

  • Start puma in dev mode
  • manually trigger and exception anywhere in your code

notice that the exception is ignored User excluded error: XXXXX

  • change a file, any file, puma hot relad
  • go trigger the exception once again -> the error will be sent to Sentry

Expected Behavior

exceptions are ALWAYS excluded

Actual Behavior

after hot reload exceptions are sent to sentry

Ruby Version

3.2.2

SDK Version

5.15

Integration and Its Version

No response

Sentry Config

No response

@sl0thentr0py
Copy link
Member

hmm @st0012 do you have an opinion here?

@nerdrew
Copy link

nerdrew commented Jan 16, 2024

I think he means the Rails autoloader, not the puma autoloader.

@st0012
Copy link
Collaborator

st0012 commented Feb 4, 2024

I can't reproduce the issue:

# config/initializers/sentry.rb
class FooException < StandardError
end

Sentry.init do |config|
  # ....
  config.excluded_exceptions += ['FooException']
  config.logger = Logger.new($stdout)
  config.logger.level = :debug
end

And in the PostsController, I raise the exception with raise FooException.

Here's the logs for 2 requests:

Started GET "/posts/new" for 127.0.0.1 at 2024-02-04 12:31:05 +0000
D, [2024-02-04T12:31:05.702860 #72341] DEBUG -- sentry: [Tracing] Starting <http.server> transaction </posts/new>
  ActiveRecord::SchemaMigration Pluck (0.1ms)  SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
# ---------------------------------------
# I added this log to verify the file is reloaded by Rails
# ---------------------------------------
Loading /Users/hung-wulo/src/github.com/getsentry/sentry-ruby/sentry-rails/examples/rails-7.0/app/controllers/posts_controller.rb...
Processing by PostsController#new as HTML
Completed 500 Internal Server Error in 2ms (ActiveRecord: 0.0ms | Allocations: 1830)


  
FooException (FooException):
  
app/controllers/posts_controller.rb:25:in `new'
# ---------------------------------------
# The error is excluded by the SDK
# ---------------------------------------
D, [2024-02-04T12:31:05.885561 #72341] DEBUG -- sentry: User excluded error: #<FooException: FooException>
I, [2024-02-04T12:31:05.886686 #72341]  INFO -- sentry: [Transport] Sending envelope with items [transaction] 1c648774e4f8423fb0e82b60975f4c8d to Sentry
Started GET "/posts/new" for 127.0.0.1 at 2024-02-04 12:31:15 +0000
D, [2024-02-04T12:31:15.838721 #72341] DEBUG -- sentry: [Tracing] Starting <http.server> transaction </posts/new>
# ---------------------------------------
# I added this log to verify the file is reloaded by Rails
# ---------------------------------------
Loading /Users/hung-wulo/src/github.com/getsentry/sentry-ruby/sentry-rails/examples/rails-7.0/app/controllers/posts_controller.rb...
Processing by PostsController#new as HTML
Completed 500 Internal Server Error in 7ms (ActiveRecord: 0.4ms | Allocations: 7040)


  
FooException (FooException):
  
app/controllers/posts_controller.rb:26:in `new'
# ---------------------------------------
# After reloading, the error is excluded by the SDK again
# ---------------------------------------
D, [2024-02-04T12:31:16.000178 #72341] DEBUG -- sentry: User excluded error: #<FooException: FooException>
I, [2024-02-04T12:31:16.000869 #72341]  INFO -- sentry: [Transport] Sending envelope with items [transaction] 21f07bf4adc749e08e200e9d3a0d4574 to Sentry
I, [2024-02-04T12:32:05.955211 #72341]  INFO -- sentry: [Transport] Sending envelope with items [sessions]  to Sentry

I also don't think reloading the same class will make === fail as it'd be a major problem for many applications. One exception could be if the class is anonymous and is generated dynamically. But in that case I don't think it's possible to add them to the excluded_exceptions list.

Can you provide a more detailed example so we can investigate this further? Thank you 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

4 participants