diff --git a/lib/buildkite/test_collector.rb b/lib/buildkite/test_collector.rb index 97e1df4..4f10b3a 100644 --- a/lib/buildkite/test_collector.rb +++ b/lib/buildkite/test_collector.rb @@ -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" @@ -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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index aae93ad..69fa230 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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) }