From d471c972a82541f5906dc24320e518e7af55beb8 Mon Sep 17 00:00:00 2001 From: Ivo Anjo Date: Thu, 8 Jun 2023 10:50:57 +0100 Subject: [PATCH 1/2] Document profiler `require` strategy **What does this PR do?**: This PR documents the profiler `require` strategy, as a follow-up to the discussion in . **Motivation**: Make it easier to maintain by clearly documenting our expectations. **Additional Notes**: N/A **How to test the change?**: Nothing to test, only comments added. --- lib/datadog/profiling.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/datadog/profiling.rb b/lib/datadog/profiling.rb index 1334f88e245..d2c288c92e0 100644 --- a/lib/datadog/profiling.rb +++ b/lib/datadog/profiling.rb @@ -178,6 +178,10 @@ def self.allocation_count # rubocop:disable Lint/DuplicateMethods, Lint/NestedMe end end + # All requires for the profiler should be directly added here; and everything should be loaded eagerly. + # (Currently there's a few exceptions for the old profiler, but we should avoid other exceptions.) + # + # All of the profiler should be loaded and ready to go when this method returns `true`. private_class_method def self.load_profiling return false unless supported? @@ -197,7 +201,8 @@ def self.allocation_count # rubocop:disable Lint/DuplicateMethods, Lint/NestedMe require_relative 'profiling/profiler' require_relative 'profiling/native_extension' require_relative 'profiling/trace_identifiers/helper' - # This file is loaded in Profiling::Component#load_pprof_support; see notes there for why + # This file is no longer eagerly loaded as a workaround for an issue. It only gets loaded dynamically if the old + # profiler is in use. See Profiling::Component#load_pprof_support for more details. # require_relative 'profiling/pprof/pprof_pb' require_relative 'profiling/tag_builder' require_relative 'profiling/http_transport' From ec27ca8ddf3d599d72820b3dd6b4998902c6df68 Mon Sep 17 00:00:00 2001 From: Gustavo Caso Date: Mon, 19 Jun 2023 11:24:46 +0200 Subject: [PATCH 2/2] Removed unused constants from Appsec::Contrib::*::Ext modules --- lib/datadog/appsec/contrib/devise/ext.rb | 1 - lib/datadog/appsec/contrib/rack/ext.rb | 1 - lib/datadog/appsec/contrib/rails/ext.rb | 3 +-- lib/datadog/appsec/contrib/sinatra/ext.rb | 1 - 4 files changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/datadog/appsec/contrib/devise/ext.rb b/lib/datadog/appsec/contrib/devise/ext.rb index 71fc3239be5..c9517cc0ffa 100644 --- a/lib/datadog/appsec/contrib/devise/ext.rb +++ b/lib/datadog/appsec/contrib/devise/ext.rb @@ -6,7 +6,6 @@ module Contrib module Devise # Devise integration constants module Ext - APP = 'devise' end end end diff --git a/lib/datadog/appsec/contrib/rack/ext.rb b/lib/datadog/appsec/contrib/rack/ext.rb index 899fd35be8b..271f466d29e 100644 --- a/lib/datadog/appsec/contrib/rack/ext.rb +++ b/lib/datadog/appsec/contrib/rack/ext.rb @@ -6,7 +6,6 @@ module Contrib module Rack # Rack integration constants module Ext - APP = 'rack' end end end diff --git a/lib/datadog/appsec/contrib/rails/ext.rb b/lib/datadog/appsec/contrib/rails/ext.rb index 1ee16c35d61..f04008310d2 100644 --- a/lib/datadog/appsec/contrib/rails/ext.rb +++ b/lib/datadog/appsec/contrib/rails/ext.rb @@ -4,9 +4,8 @@ module Datadog module AppSec module Contrib module Rails - # Rack integration constants + # Rails integration constants module Ext - APP = 'rails' end end end diff --git a/lib/datadog/appsec/contrib/sinatra/ext.rb b/lib/datadog/appsec/contrib/sinatra/ext.rb index ffa806906d4..1002bcbb0b9 100644 --- a/lib/datadog/appsec/contrib/sinatra/ext.rb +++ b/lib/datadog/appsec/contrib/sinatra/ext.rb @@ -6,7 +6,6 @@ module Contrib module Sinatra # Sinatra integration constants module Ext - APP = 'sinatra' ROUTE_INTERRUPT = :datadog_appsec_contrib_sinatra_route_interrupt end end