Skip to content

Commit

Permalink
feat: call spans that produce reads query
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsimo committed Oct 3, 2024
1 parent 18c3d5a commit 73b1f82
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ class << base
module ClassMethods
if ::ActiveRecord.version >= Gem::Version.new('7.0.0')
def _query_by_sql(...)
tracer.in_span("#{self}.find_by_sql") do
tracer.in_span("#{self} query") do
super
end
end
else
def find_by_sql(...)
tracer.in_span("#{self}.find_by_sql") do
tracer.in_span("#{self} query") do
super
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@

before { exporter.reset }

describe 'find_by_sql' do
describe 'query' do
it 'traces' do
Account.create!

User.find_by_sql('SELECT * FROM users')
Account.first.users.to_a

user_find_spans = spans.select { |s| s.name == 'User.find_by_sql' }
account_find_span = spans.find { |s| s.name == 'Account.find_by_sql' }
user_find_spans = spans.select { |s| s.name == 'User query' }
account_find_span = spans.find { |s| s.name == 'Account query' }

_(user_find_spans.length).must_equal(2)
_(account_find_span).wont_be_nil
Expand Down

0 comments on commit 73b1f82

Please sign in to comment.