honeybadger-io / honeybadger-ruby

Ruby gem for reporting errors to honeybadger.io
https://docs.honeybadger.io/lib/ruby/
MIT License
251 stars 145 forks source link

Add specific pg_advisory_unlock_all() call to list of ignored events #618

Closed justinjkim closed 1 month ago

justinjkim commented 1 month ago

Issue

According to Honeybadger's documentation on sending events to Insights, database-backed job backend queuing systems like good_job can generate noisy queries that still use up a customer's Insight quota. The documentation and source code (at least as of v5.16.0) list these queries generated by good_jobs and solid_queue as ignored by Honeybadger by default.

However, the regex used to detect these noisy queries fails to capture this Postgres call that each thread's job execution in good_job triggers:

SELECT pg_advisory_unlock_all()::text AS unlocked

Since this query doesn’t reference good_job directly, the Honeybadger regex pattern fails to prevent the events attached to these queries from being sent to the Insights API.

Proposal

Beyond updating the documentation to show a more accurate code snippet for ignoring these queries, we should add this specific unlock call to the default list of ignored events. This would look something like this:

IGNORE_EVENTS_DEFAULT = [
      { event_type: 'sql.active_record', query: /^(begin|commit)( transaction)?$/i },
      { event_type: 'sql.active_record', query: /(solid_queue|good_job)/i },
      { event_type: 'sql.active_record', query: (/SELECT pg_advisory_unlock_all\(\)::text AS unlocked/i) },
      { event_type: 'process_action.action_controller', controller: 'Rails::HealthController' }
    ].freeze

Additional Notes

The SELECT pg_advisory_unlock_all()::text AS unlocked call was removed from good_job's source code starting in version 3.20.0, so this proposal may be overkill. However, it could still help customers using older versions of good_job.

stympy commented 1 month ago

Instead of ignoring that query, we went with ignoring queries originating from GoodJob. This change is in gem version 5.17.0.

Thanks for opening the issue!