Skip to content

Commit

Permalink
Tracing ActiveRecord if ActiveSupport is present
Browse files Browse the repository at this point in the history
If the suite that’s being monitored doesn’t have ActiveSupport, then it
definitely doesn’t have ActiveRecord, and so no tracing is required.
  • Loading branch information
pat committed Feb 15, 2024
1 parent d3246b9 commit f37d79a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/buildkite/test_collector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ module TestCollector
require "timeout"
require "tmpdir"

require "active_support/notifications"

require_relative "test_collector/version"
require_relative "test_collector/error"
require_relative "test_collector/ci"
Expand Down Expand Up @@ -70,6 +68,10 @@ def self.enable_tracing!
Buildkite::TestCollector::Network.configure
Buildkite::TestCollector::Object.configure

return unless defined?(ActiveSupport)

require "active_support/notifications"

ActiveSupport::Notifications.subscribe("sql.active_record") do |name, start, finish, id, payload|
Buildkite::TestCollector::Uploader.tracer&.backfill(:sql, finish - start, **{ query: payload[:sql] })
end
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require "buildkite/test_collector"
require "active_support/notifications"

Dir["spec/support/**/*.rb"].each { |f| require File.expand_path(f) }

Expand Down

0 comments on commit f37d79a

Please sign in to comment.