From e17cf0ff88dd54e9db91fd138459420273f918c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Peder=20Brandtz=C3=A6g?= Date: Wed, 20 Nov 2024 18:15:19 +0100 Subject: [PATCH] fix: pass block argument in ActiveRecord `find_by_sql` patch `find_by_sql` takes a block as its final argument, which is neither a positional nor a keyword argument, hence we need to pass it explicitly; before this commit, the block was not passed to the `super()` call and hence not executed, thus altering application behavior. Fixes #1258 --- .../instrumentation/active_record/patches/querying.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/querying.rb b/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/querying.rb index 094575ae4..0b9f37904 100644 --- a/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/querying.rb +++ b/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/querying.rb @@ -20,9 +20,9 @@ class << base module ClassMethods method_name = ::ActiveRecord.version >= Gem::Version.new('7.0.0') ? :_query_by_sql : :find_by_sql - define_method(method_name) do |*args, **kwargs| + define_method(method_name) do |*args, **kwargs, &block| tracer.in_span("#{self} query") do - super(*args, **kwargs) + super(*args, **kwargs, &block) end end