From 2e6142c4c360119b50d47c1f015779e2d7d5d864 Mon Sep 17 00:00:00 2001 From: Vishnu Narayanan Date: Tue, 25 Mar 2025 01:13:17 +0530 Subject: [PATCH] fix: refactor --- .../concerns/request_exception_handler.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/controllers/concerns/request_exception_handler.rb b/app/controllers/concerns/request_exception_handler.rb index 07aed94d9..e50795d56 100644 --- a/app/controllers/concerns/request_exception_handler.rb +++ b/app/controllers/concerns/request_exception_handler.rb @@ -70,15 +70,15 @@ module RequestExceptionHandler def report_to_apms(exception) apm_reporters = { - ::NewRelic::Agent => -> { ::NewRelic::Agent.notice_error(exception) }, - ::Datadog::Tracing => -> { ::Datadog::Tracing.active_span&.set_error(exception) }, - ::ElasticAPM => -> { ::ElasticAPM.report(exception) }, - ::ScoutApm::Error => -> { ::ScoutApm::Error.capture(exception) }, - ::Sentry => -> { ::Sentry.capture_exception(exception) } + 'NewRelic::Agent' => -> { ::NewRelic::Agent.notice_error(exception) }, + 'Datadog::Tracing' => -> { ::Datadog::Tracing.active_trace&.set_error(exception) }, + 'ElasticAPM' => -> { ::ElasticAPM.report(exception) }, + 'ScoutApm::Error' => -> { ::ScoutApm::Error.capture(exception) }, + 'Sentry' => -> { ::Sentry.capture_exception(exception) } } - apm_reporters.each do |apm_module, reporter| - reporter.call if defined?(apm_module) + apm_reporters.each do |module_name, reporter| + reporter.call if Object.const_defined?(module_name) end end end