From 5f8f2b007871f89c53cac9f2d0d45d609e2ddef3 Mon Sep 17 00:00:00 2001 From: fallwith Date: Mon, 21 Oct 2024 15:05:58 -0700 Subject: [PATCH] DD templating: conditionally invoke requires as per #2844, don't perform `require_relative` on content that won't be used unless all dependency detection checks succeed --- .../templates/dependency_detection.tt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/tasks/instrumentation_generator/templates/dependency_detection.tt b/lib/tasks/instrumentation_generator/templates/dependency_detection.tt index e5c82ebb6f..b1af9b4535 100644 --- a/lib/tasks/instrumentation_generator/templates/dependency_detection.tt +++ b/lib/tasks/instrumentation_generator/templates/dependency_detection.tt @@ -2,10 +2,6 @@ # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details. # frozen_string_literal: true -require_relative '<%= @snake_name.downcase %>/instrumentation' -require_relative '<%= @snake_name.downcase %>/chain' -require_relative '<%= @snake_name.downcase %>/prepend' - DependencyDetection.defer do named :<%= @name.match?(/\-|\_/) ? "'#{@snake_name}'" : @name.downcase %> @@ -18,6 +14,10 @@ DependencyDetection.defer do end executes do + require_relative '<%= @snake_name.downcase %>/instrumentation' + require_relative '<%= @snake_name.downcase %>/chain' + require_relative '<%= @snake_name.downcase %>/prepend' + # prepend_instrument and chain_instrument call extract_supportability_name # to get the library name for supportability metrics and info-level logging. # This is done by spliting on the 2nd to last spot of the instrumented