From feadcee5536a34726f6b7553fd12b3cbbe52b69b Mon Sep 17 00:00:00 2001
From: Heinrich Lee Yu <heinrich@gitlab.com>
Date: Wed, 24 Apr 2024 18:06:39 +0800
Subject: [PATCH] Fix GraphQL tracer deprecation

Updates our GraphQL tracers to the new format

See https://github.com/rmosolgo/graphql-ruby/pull/4878
---
 .../layout/empty_line_after_magic_comment.yml |  1 -
 .rubocop_todo/lint/unused_method_argument.yml |  1 -
 .rubocop_todo/rspec/feature_category.yml      |  1 -
 .rubocop_todo/rspec/verified_doubles.yml      |  1 -
 .rubocop_todo/style/lambda.yml                |  1 -
 .rubocop_todo/style/redundant_self.yml        |  1 -
 Gemfile                                       |  2 +-
 Gemfile.checksum                              |  2 +-
 Gemfile.lock                                  |  4 +-
 app/graphql/gitlab_schema.rb                  |  8 +--
 .../tracers/application_context_tracer.rb     | 28 ++--------
 lib/gitlab/graphql/tracers/logger_tracer.rb   | 19 +++----
 lib/gitlab/graphql/tracers/metrics_tracer.rb  | 27 +++------
 lib/gitlab/graphql/tracers/timer_tracer.rb    | 27 ---------
 spec/graphql/gitlab_schema_spec.rb            |  3 +-
 .../ast/logger_analyzer_spec.rb               |  4 +-
 .../application_context_tracer_spec.rb        | 27 ++++-----
 .../graphql/tracers/logger_tracer_spec.rb     |  4 +-
 .../graphql/tracers/metrics_tracer_spec.rb    |  5 +-
 .../graphql/tracers/timer_tracer_spec.rb      | 55 -------------------
 spec/support/helpers/graphql/fake_tracer.rb   | 15 -----
 spec/support/rspec_order_todo.yml             |  1 -
 22 files changed, 46 insertions(+), 191 deletions(-)
 delete mode 100644 lib/gitlab/graphql/tracers/timer_tracer.rb
 delete mode 100644 spec/lib/gitlab/graphql/tracers/timer_tracer_spec.rb
 delete mode 100644 spec/support/helpers/graphql/fake_tracer.rb

diff --git a/.rubocop_todo/layout/empty_line_after_magic_comment.yml b/.rubocop_todo/layout/empty_line_after_magic_comment.yml
index ba0af7180905e..58fe1a823edd7 100644
--- a/.rubocop_todo/layout/empty_line_after_magic_comment.yml
+++ b/.rubocop_todo/layout/empty_line_after_magic_comment.yml
@@ -509,7 +509,6 @@ Layout/EmptyLineAfterMagicComment:
     - 'spec/lib/gitlab/graphql/mount_mutation_spec.rb'
     - 'spec/lib/gitlab/graphql/present/field_extension_spec.rb'
     - 'spec/lib/gitlab/graphql/tracers/logger_tracer_spec.rb'
-    - 'spec/lib/gitlab/graphql/tracers/timer_tracer_spec.rb'
     - 'spec/lib/gitlab/health_checks/redis_spec.rb'
     - 'spec/lib/gitlab/import/set_async_jid_spec.rb'
     - 'spec/lib/gitlab/jwt_token_spec.rb'
diff --git a/.rubocop_todo/lint/unused_method_argument.yml b/.rubocop_todo/lint/unused_method_argument.yml
index df930ca1622a7..c23f70d090f28 100644
--- a/.rubocop_todo/lint/unused_method_argument.yml
+++ b/.rubocop_todo/lint/unused_method_argument.yml
@@ -454,7 +454,6 @@ Lint/UnusedMethodArgument:
     - 'lib/gitlab/graphql/lazy.rb'
     - 'lib/gitlab/graphql/project/dast_profile_connection_extension.rb'
     - 'lib/gitlab/graphql/query_analyzers/ast/logger_analyzer.rb'
-    - 'lib/gitlab/graphql/tracers/timer_tracer.rb'
     - 'lib/gitlab/hook_data/subgroup_builder.rb'
     - 'lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb'
     - 'lib/gitlab/import_export/fast_hash_serializer.rb'
diff --git a/.rubocop_todo/rspec/feature_category.yml b/.rubocop_todo/rspec/feature_category.yml
index 7b11afa864027..798bfce91dcbb 100644
--- a/.rubocop_todo/rspec/feature_category.yml
+++ b/.rubocop_todo/rspec/feature_category.yml
@@ -3452,7 +3452,6 @@ RSpec/FeatureCategory:
     - 'spec/lib/gitlab/graphql/tracers/application_context_tracer_spec.rb'
     - 'spec/lib/gitlab/graphql/tracers/logger_tracer_spec.rb'
     - 'spec/lib/gitlab/graphql/tracers/metrics_tracer_spec.rb'
-    - 'spec/lib/gitlab/graphql/tracers/timer_tracer_spec.rb'
     - 'spec/lib/gitlab/graphql/type_name_deprecations_spec.rb'
     - 'spec/lib/gitlab/graphql_logger_spec.rb'
     - 'spec/lib/gitlab/graphs/commits_spec.rb'
diff --git a/.rubocop_todo/rspec/verified_doubles.yml b/.rubocop_todo/rspec/verified_doubles.yml
index 7619a75a43c7f..1079324ed135c 100644
--- a/.rubocop_todo/rspec/verified_doubles.yml
+++ b/.rubocop_todo/rspec/verified_doubles.yml
@@ -549,7 +549,6 @@ RSpec/VerifiedDoubles:
     - 'spec/lib/gitlab/graphql/present/field_extension_spec.rb'
     - 'spec/lib/gitlab/graphql/timeout_spec.rb'
     - 'spec/lib/gitlab/graphql/tracers/application_context_tracer_spec.rb'
-    - 'spec/lib/gitlab/graphql/tracers/timer_tracer_spec.rb'
     - 'spec/lib/gitlab/health_checks/gitaly_check_spec.rb'
     - 'spec/lib/gitlab/hook_data/base_builder_spec.rb'
     - 'spec/lib/gitlab/hotlinking_detector_spec.rb'
diff --git a/.rubocop_todo/style/lambda.yml b/.rubocop_todo/style/lambda.yml
index 606dbb49f92f8..0603cc8d2558f 100644
--- a/.rubocop_todo/style/lambda.yml
+++ b/.rubocop_todo/style/lambda.yml
@@ -61,7 +61,6 @@ Style/Lambda:
     - 'spec/lib/gitlab/cross_project_access/class_methods_spec.rb'
     - 'spec/lib/gitlab/database/load_balancing/action_cable_callbacks_spec.rb'
     - 'spec/lib/gitlab/graphql/tracers/application_context_tracer_spec.rb'
-    - 'spec/lib/gitlab/graphql/tracers/timer_tracer_spec.rb'
     - 'spec/lib/gitlab/middleware/rack_multipart_tempfile_factory_spec.rb'
     - 'spec/lib/gitlab/path_regex_spec.rb'
     - 'spec/services/groups/autocomplete_service_spec.rb'
diff --git a/.rubocop_todo/style/redundant_self.yml b/.rubocop_todo/style/redundant_self.yml
index 153a05d262d88..660eb584506aa 100644
--- a/.rubocop_todo/style/redundant_self.yml
+++ b/.rubocop_todo/style/redundant_self.yml
@@ -320,7 +320,6 @@ Style/RedundantSelf:
     - 'lib/gitlab/graphql/tracers/application_context_tracer.rb'
     - 'lib/gitlab/graphql/tracers/logger_tracer.rb'
     - 'lib/gitlab/graphql/tracers/metrics_tracer.rb'
-    - 'lib/gitlab/graphql/tracers/timer_tracer.rb'
     - 'lib/gitlab/highlight.rb'
     - 'lib/gitlab/http.rb'
     - 'lib/gitlab/import_export/error.rb'
diff --git a/Gemfile b/Gemfile
index 61110d45b4979..48a6e61dcab9a 100644
--- a/Gemfile
+++ b/Gemfile
@@ -381,7 +381,7 @@ gem 'gettext', '~> 3.4', '>= 3.4.9',
   group: [:development, :test],
   feature_category: :internationalization
 
-gem 'batch-loader', '~> 2.0.1' # rubocop:todo Gemfile/MissingFeatureCategory
+gem 'batch-loader', '~> 2.0.5' # rubocop:todo Gemfile/MissingFeatureCategory
 
 # Perf bar
 gem 'peek', '~> 1.1' # rubocop:todo Gemfile/MissingFeatureCategory
diff --git a/Gemfile.checksum b/Gemfile.checksum
index f3152d62885d5..d8089d34e7556 100644
--- a/Gemfile.checksum
+++ b/Gemfile.checksum
@@ -49,7 +49,7 @@
 {"name":"backport","version":"1.2.0","platform":"ruby","checksum":"912c7dfdd9ee4625d013ddfccb6205c3f92da69a8990f65c440e40f5b2fc7f75"},
 {"name":"base32","version":"0.3.2","platform":"ruby","checksum":"532e9b19c5dd1fce281df67fc93a803ebd5d26426a93f6dda6612769bc46fe2c"},
 {"name":"base64","version":"0.2.0","platform":"ruby","checksum":"0f25e9b21a02a0cc0cea8ef92b2041035d39350946e8789c562b2d1a3da01507"},
-{"name":"batch-loader","version":"2.0.1","platform":"ruby","checksum":"93f711df78d316ee0440a7a45daba4f5418d0ee2b5f58f60c9ea038424e7a89d"},
+{"name":"batch-loader","version":"2.0.5","platform":"ruby","checksum":"964bf638b8f498bab40abaafc6f89c057b2e02aa25b64fc1ec12872ad6bff213"},
 {"name":"bcrypt","version":"3.1.18","platform":"java","checksum":"5464e06c00cb6bd3ff982feef4cb7f1efc9b302753cbaf12e73512d8f401f2d2"},
 {"name":"bcrypt","version":"3.1.18","platform":"ruby","checksum":"154de0b0b089e56d5980c5037ad85fc9554cfbf4996538673c1ddbc9b61b1f11"},
 {"name":"benchmark","version":"0.2.0","platform":"ruby","checksum":"5f7087b794613abdd3ac9c13f4351f65b164bcb15ced2ad29508e365f9b28c77"},
diff --git a/Gemfile.lock b/Gemfile.lock
index a8f5241a9f21c..376e2e942452d 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -340,7 +340,7 @@ GEM
     backport (1.2.0)
     base32 (0.3.2)
     base64 (0.2.0)
-    batch-loader (2.0.1)
+    batch-loader (2.0.5)
     bcrypt (3.1.18)
     benchmark (0.2.0)
     benchmark-ips (2.11.0)
@@ -1936,7 +1936,7 @@ DEPENDENCIES
   axe-core-rspec (~> 4.9.0)
   babosa (~> 2.0)
   base32 (~> 0.3.0)
-  batch-loader (~> 2.0.1)
+  batch-loader (~> 2.0.5)
   bcrypt (~> 3.1, >= 3.1.14)
   benchmark-ips (~> 2.11.0)
   benchmark-memory (~> 0.1)
diff --git a/app/graphql/gitlab_schema.rb b/app/graphql/gitlab_schema.rb
index 2c4cbb45f9720..1d39acd118522 100644
--- a/app/graphql/gitlab_schema.rb
+++ b/app/graphql/gitlab_schema.rb
@@ -11,11 +11,9 @@ class GitlabSchema < GraphQL::Schema
   AUTHENTICATED_MAX_DEPTH = 20
 
   # Tracers (order is important)
-  use Gitlab::Graphql::Tracers::ApplicationContextTracer
-  use Gitlab::Graphql::Tracers::MetricsTracer
-  use Gitlab::Graphql::Tracers::LoggerTracer
-
-  use Gitlab::Graphql::Tracers::TimerTracer
+  trace_with Gitlab::Graphql::Tracers::MetricsTracer
+  trace_with Gitlab::Graphql::Tracers::LoggerTracer
+  trace_with Gitlab::Graphql::Tracers::ApplicationContextTracer
 
   use Gitlab::Graphql::Subscriptions::ActionCableWithLoadBalancing
   use BatchLoader::GraphQL
diff --git a/lib/gitlab/graphql/tracers/application_context_tracer.rb b/lib/gitlab/graphql/tracers/application_context_tracer.rb
index 4193c46e3215e..8ab35ccaad6cc 100644
--- a/lib/gitlab/graphql/tracers/application_context_tracer.rb
+++ b/lib/gitlab/graphql/tracers/application_context_tracer.rb
@@ -4,34 +4,18 @@ module Gitlab
   module Graphql
     module Tracers
       # This graphql-ruby tracer sets up `ApplicationContext` for certain operations.
-      class ApplicationContextTracer
-        def self.use(schema)
-          schema.tracer(self.new)
-        end
-
-        # See docs on expected interface for trace
-        # https://graphql-ruby.org/api-doc/1.12.17/GraphQL/Tracing
-        def trace(key, data)
-          case key
-          when "execute_query"
-            operation = known_operation(data)
+      module ApplicationContextTracer
+        def execute_query(query:)
+          operation = known_operation(query)
 
-            ::Gitlab::ApplicationContext.with_context(caller_id: operation.to_caller_id) do
-              yield
-            end
-          else
-            yield
+          ::Gitlab::ApplicationContext.with_context(caller_id: operation.to_caller_id) do
+            super
           end
         end
 
         private
 
-        def known_operation(data)
-          # The library guarantees that we should have :query for execute_query, but we're being defensive here
-          query = data.fetch(:query, nil)
-
-          return ::Gitlab::Graphql::KnownOperations.UNKNOWN unless query
-
+        def known_operation(query)
           ::Gitlab::Graphql::KnownOperations.default.from_query(query)
         end
       end
diff --git a/lib/gitlab/graphql/tracers/logger_tracer.rb b/lib/gitlab/graphql/tracers/logger_tracer.rb
index 3302b2bae3f77..ee96bc4c83a3f 100644
--- a/lib/gitlab/graphql/tracers/logger_tracer.rb
+++ b/lib/gitlab/graphql/tracers/logger_tracer.rb
@@ -4,22 +4,17 @@ module Gitlab
   module Graphql
     module Tracers
       # This tracer writes logs for certain trace events.
-      # It reads duration metadata written by TimerTracer.
-      class LoggerTracer
-        def self.use(schema)
-          schema.tracer(self.new)
-        end
+      module LoggerTracer
+        def execute_query(query:)
+          start_time = ::Gitlab::Metrics::System.monotonic_time
 
-        def trace(key, data)
-          yield
+          super
         rescue StandardError => e
-          data[:exception] = e
           raise e
         ensure
-          case key
-          when "execute_query"
-            log_execute_query(**data)
-          end
+          duration_s = ::Gitlab::Metrics::System.monotonic_time - start_time
+
+          log_execute_query(query: query, duration_s: duration_s, exception: e)
         end
 
         private
diff --git a/lib/gitlab/graphql/tracers/metrics_tracer.rb b/lib/gitlab/graphql/tracers/metrics_tracer.rb
index 9fc001c0a6dc1..fe05963ce3078 100644
--- a/lib/gitlab/graphql/tracers/metrics_tracer.rb
+++ b/lib/gitlab/graphql/tracers/metrics_tracer.rb
@@ -3,33 +3,20 @@
 module Gitlab
   module Graphql
     module Tracers
-      class MetricsTracer
-        def self.use(schema)
-          schema.tracer(self.new)
-        end
+      module MetricsTracer
+        def execute_query(query:)
+          start_time = ::Gitlab::Metrics::System.monotonic_time
 
-        # See https://graphql-ruby.org/api-doc/1.12.16/GraphQL/Tracing for full list of events
-        def trace(key, data)
-          result = yield
+          super
 
-          case key
-          when "execute_query"
-            increment_query_sli(data)
-          end
+          duration_s = ::Gitlab::Metrics::System.monotonic_time - start_time
 
-          result
+          increment_query_sli(query: query, duration_s: duration_s)
         end
 
         private
 
-        def increment_query_sli(data)
-          duration_s = data.fetch(:duration_s, nil)
-          query = data.fetch(:query, nil)
-
-          # We're just being defensive here...
-          # duration_s comes from TimerTracer and we should be pretty much guaranteed it exists
-          return unless duration_s && query
-
+        def increment_query_sli(query:, duration_s:)
           operation = ::Gitlab::Graphql::KnownOperations.default.from_query(query)
           query_urgency = operation.query_urgency
 
diff --git a/lib/gitlab/graphql/tracers/timer_tracer.rb b/lib/gitlab/graphql/tracers/timer_tracer.rb
deleted file mode 100644
index 2cf06086a3cd3..0000000000000
--- a/lib/gitlab/graphql/tracers/timer_tracer.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-# frozen_string_literal: true
-
-module Gitlab
-  module Graphql
-    module Tracers
-      # This graphql-ruby tracer records duration for trace events and merges
-      # the duration into the trace event's metadata. This way, separate tracers
-      # can all use the same duration information.
-      #
-      # NOTE: TimerTracer should be applied last **after** other tracers, so
-      # that it runs first (similar to function composition)
-      class TimerTracer
-        def self.use(schema)
-          schema.tracer(self.new)
-        end
-
-        def trace(key, data)
-          start_time = ::Gitlab::Metrics::System.monotonic_time
-
-          yield
-        ensure
-          data[:duration_s] = ::Gitlab::Metrics::System.monotonic_time - start_time
-        end
-      end
-    end
-  end
-end
diff --git a/spec/graphql/gitlab_schema_spec.rb b/spec/graphql/gitlab_schema_spec.rb
index c9ae3dc987ed7..2eefdf3abb3d0 100644
--- a/spec/graphql/gitlab_schema_spec.rb
+++ b/spec/graphql/gitlab_schema_spec.rb
@@ -4,12 +4,11 @@
 
 RSpec.describe GitlabSchema do
   let_it_be(:connections) { described_class.connections.all_wrappers }
-  let_it_be(:tracers) { described_class.tracers }
 
   let(:user) { build :user }
 
   it 'uses batch loading' do
-    expect(tracers).to include(BatchLoader::GraphQL)
+    expect(described_class.trace_modules_for(:default)).to include(BatchLoader::GraphQL::Trace)
   end
 
   it 'has the base mutation' do
diff --git a/spec/lib/gitlab/graphql/query_analyzers/ast/logger_analyzer_spec.rb b/spec/lib/gitlab/graphql/query_analyzers/ast/logger_analyzer_spec.rb
index bcdb796527627..ea52bf2e08096 100644
--- a/spec/lib/gitlab/graphql/query_analyzers/ast/logger_analyzer_spec.rb
+++ b/spec/lib/gitlab/graphql/query_analyzers/ast/logger_analyzer_spec.rb
@@ -25,9 +25,7 @@
       RequestStore.store[:graphql_logs] = nil
 
       allow(Gitlab::Metrics::System).to receive(:monotonic_time)
-        .and_return(monotonic_time_before, monotonic_time_before,
-                    monotonic_time_before, monotonic_time_before,
-                    monotonic_time_after)
+        .and_return(monotonic_time_before, monotonic_time_before, monotonic_time_after)
     end
 
     it 'returns the complexity, depth, duration, etc' do
diff --git a/spec/lib/gitlab/graphql/tracers/application_context_tracer_spec.rb b/spec/lib/gitlab/graphql/tracers/application_context_tracer_spec.rb
index 264fe993197b1..09bfa0bc152cb 100644
--- a/spec/lib/gitlab/graphql/tracers/application_context_tracer_spec.rb
+++ b/spec/lib/gitlab/graphql/tracers/application_context_tracer_spec.rb
@@ -3,40 +3,41 @@
 require 'spec_helper'
 
 RSpec.describe Gitlab::Graphql::Tracers::ApplicationContextTracer do
-  let(:tracer_spy) { spy('tracer_spy') }
   let(:default_known_operations) { ::Gitlab::Graphql::KnownOperations.new(['fooOperation']) }
   let(:dummy_schema) do
-    schema = Class.new(GraphQL::Schema) do
-      use Gitlab::Graphql::Tracers::ApplicationContextTracer
-
+    Class.new(GraphQL::Schema) do
       query Graphql::FakeQueryType
     end
+  end
 
-    fake_tracer = Graphql::FakeTracer.new(lambda do |key, *args|
-      tracer_spy.trace(key, Gitlab::ApplicationContext.current)
-    end)
+  let(:inner_tracer) { Module.new }
+  let!(:context) do
+    context = {}
 
-    schema.tracer(fake_tracer)
+    inner_tracer.define_method(:execute_query, ->(*) {
+      context.merge!(Gitlab::ApplicationContext.current)
+    })
 
-    schema
+    context
   end
 
   before do
     allow(::Gitlab::Graphql::KnownOperations).to receive(:default).and_return(default_known_operations)
+
+    dummy_schema.trace_with inner_tracer
+    dummy_schema.trace_with described_class
   end
 
   it "sets application context during execute_query and cleans up afterwards", :aggregate_failures do
     dummy_schema.execute("query fooOperation { helloWorld }")
 
-    # "parse" is just an arbitrary trace event that isn't setting caller_id
-    expect(tracer_spy).to have_received(:trace).with("parse", hash_excluding("meta.caller_id"))
-    expect(tracer_spy).to have_received(:trace).with("execute_query", hash_including("meta.caller_id" => "graphql:fooOperation")).once
+    expect(context).to include("meta.caller_id" => "graphql:fooOperation")
     expect(Gitlab::ApplicationContext.current).not_to include("meta.caller_id")
   end
 
   it "sets caller_id when operation is not known" do
     dummy_schema.execute("query fuzz { helloWorld }")
 
-    expect(tracer_spy).to have_received(:trace).with("execute_query", hash_including("meta.caller_id" => "graphql:unknown")).once
+    expect(context).to include("meta.caller_id" => "graphql:unknown")
   end
 end
diff --git a/spec/lib/gitlab/graphql/tracers/logger_tracer_spec.rb b/spec/lib/gitlab/graphql/tracers/logger_tracer_spec.rb
index 6eef6827f1039..3abe182dc3cc2 100644
--- a/spec/lib/gitlab/graphql/tracers/logger_tracer_spec.rb
+++ b/spec/lib/gitlab/graphql/tracers/logger_tracer_spec.rb
@@ -4,9 +4,7 @@
 RSpec.describe Gitlab::Graphql::Tracers::LoggerTracer do
   let(:dummy_schema) do
     Class.new(GraphQL::Schema) do
-      # LoggerTracer depends on TimerTracer
-      use Gitlab::Graphql::Tracers::LoggerTracer
-      use Gitlab::Graphql::Tracers::TimerTracer
+      trace_with Gitlab::Graphql::Tracers::LoggerTracer
 
       query_analyzer Gitlab::Graphql::QueryAnalyzers::AST::LoggerAnalyzer
 
diff --git a/spec/lib/gitlab/graphql/tracers/metrics_tracer_spec.rb b/spec/lib/gitlab/graphql/tracers/metrics_tracer_spec.rb
index f077cff6875ff..1c6b195850e4e 100644
--- a/spec/lib/gitlab/graphql/tracers/metrics_tracer_spec.rb
+++ b/spec/lib/gitlab/graphql/tracers/metrics_tracer_spec.rb
@@ -10,9 +10,8 @@
 
   let(:fake_schema) do
     Class.new(GraphQL::Schema) do
-      use Gitlab::Graphql::Tracers::ApplicationContextTracer
-      use Gitlab::Graphql::Tracers::MetricsTracer
-      use Gitlab::Graphql::Tracers::TimerTracer
+      trace_with Gitlab::Graphql::Tracers::MetricsTracer
+      trace_with Gitlab::Graphql::Tracers::ApplicationContextTracer
 
       query Graphql::FakeQueryType
     end
diff --git a/spec/lib/gitlab/graphql/tracers/timer_tracer_spec.rb b/spec/lib/gitlab/graphql/tracers/timer_tracer_spec.rb
deleted file mode 100644
index e42883aafd8e2..0000000000000
--- a/spec/lib/gitlab/graphql/tracers/timer_tracer_spec.rb
+++ /dev/null
@@ -1,55 +0,0 @@
-# frozen_string_literal: true
-require "fast_spec_helper"
-
-RSpec.describe Gitlab::Graphql::Tracers::TimerTracer do
-  let(:expected_duration) { 5 }
-  let(:tracer_spy) { spy('tracer_spy') }
-  let(:dummy_schema) do
-    schema = Class.new(GraphQL::Schema) do
-      use Gitlab::Graphql::Tracers::TimerTracer
-
-      query Graphql::FakeQueryType
-    end
-
-    schema.tracer(Graphql::FakeTracer.new(lambda { |*args| tracer_spy.trace(*args) }))
-
-    schema
-  end
-
-  before do
-    current_time = 0
-    allow(tracer_spy).to receive(:trace)
-    allow(Gitlab::Metrics::System).to receive(:monotonic_time) do
-      current_time += expected_duration
-    end
-  end
-
-  it "adds duration_s to the trace metadata", :aggregate_failures do
-    query_string = "query fooOperation { helloWorld }"
-
-    dummy_schema.execute(query_string)
-
-    expect_to_have_traced(tracer_spy, expected_duration, query_string)
-  end
-
-  it "adds a duration_s even if the query failed" do
-    query_string = "query fooOperation { breakingField }"
-
-    expect { dummy_schema.execute(query_string) }.to raise_error(/This field is supposed to break/)
-
-    expect_to_have_traced(tracer_spy, expected_duration, query_string)
-  end
-
-  def expect_to_have_traced(tracer_spy, expected_duration, query_string)
-    # "parse" and "execute_query" are just arbitrary trace events
-    expect(tracer_spy).to have_received(:trace).with("parse", {
-      duration_s: expected_duration,
-      query_string: query_string
-    })
-    expect(tracer_spy).to have_received(:trace).with("execute_query", {
-      # greater than expected duration because other calls made to `.monotonic_time` are outside our control
-      duration_s: be >= expected_duration,
-      query: instance_of(GraphQL::Query)
-    })
-  end
-end
diff --git a/spec/support/helpers/graphql/fake_tracer.rb b/spec/support/helpers/graphql/fake_tracer.rb
deleted file mode 100644
index 58688c9abd0af..0000000000000
--- a/spec/support/helpers/graphql/fake_tracer.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-module Graphql
-  class FakeTracer
-    def initialize(trace_callback)
-      @trace_callback = trace_callback
-    end
-
-    def trace(...)
-      @trace_callback.call(...)
-
-      yield
-    end
-  end
-end
diff --git a/spec/support/rspec_order_todo.yml b/spec/support/rspec_order_todo.yml
index 7a530c8936cb9..25e390b57949e 100644
--- a/spec/support/rspec_order_todo.yml
+++ b/spec/support/rspec_order_todo.yml
@@ -6083,7 +6083,6 @@
 - './spec/lib/gitlab/graphql/tracers/application_context_tracer_spec.rb'
 - './spec/lib/gitlab/graphql/tracers/logger_tracer_spec.rb'
 - './spec/lib/gitlab/graphql/tracers/metrics_tracer_spec.rb'
-- './spec/lib/gitlab/graphql/tracers/timer_tracer_spec.rb'
 - './spec/lib/gitlab/graphql/type_name_deprecations_spec.rb'
 - './spec/lib/gitlab/graphs/commits_spec.rb'
 - './spec/lib/gitlab/group_search_results_spec.rb'
-- 
GitLab