Skip to content

Commit

Permalink
fix(active_record): Propagate **kwargs and &block
Browse files Browse the repository at this point in the history
Otherwise *args can have too many arguments,
which often happened on Rails 6.1 and above with postgres.

ArgumentError: wrong number of arguments (given 6, expected 1..5)
[...]lib/active_record/connection_adapters/abstract_adapter.rb:759:in `log'

Signed-off-by: Ferenc Géczi <[email protected]>
  • Loading branch information
Ferenc- committed Jun 19, 2023
1 parent 35c1696 commit 997c77f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/instana/instrumentation/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module ActiveRecord
IGNORED_SQL = %w[BEGIN COMMIT SET].freeze
SANITIZE_REGEXP = /('[\s\S][^']*'|\d*\.\d+|\d+|NULL)/i.freeze

def log(sql, name = 'SQL', binds = [], *args)
def log(sql, name = 'SQL', binds = [], *args, **kwargs, &block)
call_payload = {
activerecord: {
adapter: @config[:adapter],
Expand All @@ -24,7 +24,7 @@ def log(sql, name = 'SQL', binds = [], *args)
call_payload[:activerecord][:binds] = mapped
end

maybe_trace(call_payload, name) { super(sql, name, binds, *args) }
maybe_trace(call_payload, name) { super(sql, name, binds, *args, **kwargs, &block) }
end

private
Expand Down

0 comments on commit 997c77f

Please sign in to comment.