scoutapp / scout_apm_ruby

ScoutAPM Ruby Agent. Supports Rails, Sinatra, Grape, Rack, and many other frameworks

Home Page:https://scoutapm.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stack level too deep with appsignal gem

Geesu opened this issue · comments

We recently added the appsignal gem and now we're unable to deploy our application due to Stack level too deep. Here is the trace:

from /var/www/app/shared/bundle/ruby/2.7.0/gems/scout_apm-5.2.0/lib/scout_apm/config.rb:233:in `detect'
01 	from /var/www/app/shared/bundle/ruby/2.7.0/gems/scout_apm-5.2.0/lib/scout_apm/config.rb:233:in `overlay_for_key'
01 	from /var/www/app/shared/bundle/ruby/2.7.0/gems/scout_apm-5.2.0/lib/scout_apm/config.rb:241:in `value'
01 	from /var/www/app/shared/bundle/ruby/2.7.0/gems/scout_apm-5.2.0/lib/scout_apm/instruments/net_http.rb:43:in `request_scout_description'
01 	from /var/www/app/shared/bundle/ruby/2.7.0/gems/scout_apm-5.2.0/lib/scout_apm/instruments/net_http.rb:29:in `request_with_scout_instruments'
01 	from /var/www/app/shared/bundle/ruby/2.7.0/gems/appsignal-3.0.27/lib/appsignal/integrations/net_http.rb:11:in `block in request'
01 	from /var/www/app/shared/bundle/ruby/2.7.0/gems/appsignal-3.0.27/lib/appsignal/helpers/instrumentation.rb:525:in `instrument'
01 	from /var/www/app/shared/bundle/ruby/2.7.0/gems/appsignal-3.0.27/lib/appsignal/integrations/net_http.rb:7:in `request

It looks like AppSignal hooks the net_http request like so:

module Appsignal
  module Integrations
    module NetHttpIntegration
      def request(request, body = nil, &block)
        Appsignal.instrument(
          "request.net_http",
          "#{request.method} #{use_ssl? ? "https" : "http"}://#{request["host"] || address}"
        ) do
          super
        end
      end
    end
  end
end

I'm not sure if this is an issue with the scout gem or with appsignal so I'm opening an issue here.

Related PRs here. Should prepend be used instead here?

Loading the appsignal gem after scout fixes the issue.

Thanks for the report @Geesu - This should be resolved by #448 which I will release as a new gem version on Monday.