Skip to content

Instantly share code, notes, and snippets.

@stympy
Created July 12, 2024 19:32
Show Gist options
  • Save stympy/b4e2eac9687d322c3d7886f7c9d92125 to your computer and use it in GitHub Desktop.
Save stympy/b4e2eac9687d322c3d7886f7c9d92125 to your computer and use it in GitHub Desktop.
Filtering and truncating SQL before reporting to Insights
# config/initializers/honeybadger.rb
Honeybadger.configure do |config|
config.before_event do |event|
# DB-backed job backends can generate a lot of useless queries
if event.event_type == "sql.active_record" && event[:query]&.match?(/good_job|solid_queue/)
event.halt!
end
# Truncate long queries
if event.event_type == "sql.active_record" && event[:query].present?
event[:query] = event[:query].first(256)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment