From 7dc82129a2af33955dfbf9f57bdfaeb41ca76b72 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 17 Dec 2024 09:05:47 -0500 Subject: [PATCH] current_component will always be defined --- lib/datadog/di/code_tracker.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/datadog/di/code_tracker.rb b/lib/datadog/di/code_tracker.rb index 23aa896067a..dcd875e9731 100644 --- a/lib/datadog/di/code_tracker.rb +++ b/lib/datadog/di/code_tracker.rb @@ -90,8 +90,9 @@ def start # customer applications. rescue => exc # Code tracker may be loaded without the rest of DI, - # in which case DI.current_component won't be defined. - if component = DI.respond_to?(:current_component) && DI.current_component + # in which case DI.component will not yet be defined, + # but we will have DI.current_component (set to nil). + if component = DI.current_component raise if component.settings.dynamic_instrumentation.internal.propagate_all_exceptions component.logger.warn("Unhandled exception in script_compiled trace point: #{exc.class}: #{exc}") component.telemetry&.report(exc, description: "Unhandled exception in script_compiled trace point")