Created
May 11, 2023 13:54
-
-
Save skatkov/17d1f53d38ea90c4a4c678197e682173 to your computer and use it in GitHub Desktop.
Store sample of sql when ActiveRecord::QueryCanceled occured
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationJob < ActiveJob::Base | |
include ActiveSupport::Rescuable | |
# PG::QueryCanceled will be wrapped with ActiveRecord::QueryCanceled errors and it's a direct | |
# descendant of ActiveRecord::StatementInvalid error. | |
rescue_from ActiveRecord::StatementInvalid do |exception| | |
# It's hard to know, on which queries we're seeing statement timeouts -- so we are making this explicit in AppSignal error. | |
Appsignal::Transaction.current.set_sample_data("custom_data", sql_statement: exception.sql) | |
raise exception | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment