lib/contrast/framework/manager.rb in contrast-agent-4.12.0 vs lib/contrast/framework/manager.rb in contrast-agent-4.13.0

- old
+ new

@@ -14,13 +14,13 @@ module Framework # Allows access to framework specific information class Manager include Contrast::Components::Logger::InstanceMethods - # Order here does matter as the first framework listed will be the first one we pull information from - # Rack will be a special case that may involve updating some logic to handle only applying Rack if Rails/Sinatra - # do not exist + # Order here does matter as the first framework listed will be the first one we pull information from Rack will + # be a special case that may involve updating some logic to handle only applying Rack if Rails/Sinatra do not + # exist SUPPORTED_FRAMEWORKS = [ Contrast::Framework::Rails::Support, Contrast::Framework::Sinatra::Support, Contrast::Framework::Grape::Support, Contrast::Framework::Rack::Support ].cs__freeze @@ -32,13 +32,12 @@ framework_klass end @_frameworks.compact! end - # Patches that have to be applied as early as possible to catch calls - # that happen prior to the first Request, typically those around - # configuration. + # Patches that have to be applied as early as possible to catch calls that happen prior to the first Request, + # typically those around configuration. def before_load_patches! @_before_load_patches ||= begin SUPPORTED_FRAMEWORKS.each(&:before_load_patches!) true end @@ -79,12 +78,12 @@ found || ::Rack::Directory.new('').root end # Build a request from the provided env, based on the framework(s) we're currently supporting. # - # @param env [Hash] the various variables stored by this and other Middlewares to know the state and values - # of this particular Request + # @param env [Hash] the various variables stored by this and other Middlewares to know the state and values of + # this particular Request # @return [::Rack::Request] either a rack request or subclass thereof. def retrieve_request env # If we're mounted on Rails, use Rails. if @_frameworks.include?(Contrast::Framework::Rails::Support) return Contrast::Framework::Rails::Support.retrieve_request(env) @@ -97,24 +96,24 @@ ::Rack::Request.new(env) rescue StandardError => e logger.warn('Unable to retrieve_request', e) end - # @param env [Hash] the various variables stored by this and other Middlewares to know the state - # and values of this particular Request + # @param env [Hash] the various variables stored by this and other Middlewares to know the state and values of + # this particular Request # @return [Boolean] true if at least one framework is streaming the response; false if none are streaming def streaming? env result = false @_frameworks.each do |framework| result = framework.streaming?(env) break if result end result end - # Iterate through current frameworks and return the current request's route. This will be the first - # non-nil result. + # Iterate through current frameworks and return the current request's route. This will be the first non-nil + # result. # # @param request [Contrast::Agent::Request] the current request. # @return [Contrast::Api::Dtm::RouteCoverage] the current route as a Dtm. def get_route_dtm request @_frameworks.lazy.map { |framework_support| framework_support.current_route(request) }.reject(&:nil?).first @@ -122,9 +121,12 @@ # Sometimes the framework we want to instrument is loaded after our agent code. To catch that case, we'll detect # if the loaded_module is the marker class for any of our supported frameworks. If it is, and we don't already # have support enabled, we'll enable it now. We'll also need to catch up on any other startup actions that we've # missed. Most likely, this is only necessary for those applications which have applications mounted on them. + # + # TODO: RUBY-1354 + # TODO: RUBY-1356 # # @param mod [Module] the module or class that was just loaded def register_late_framework mod return unless mod