microsoft / ApplicationInsights-Ruby

Microsoft Application Insights SDK for Ruby
Other
30 stars 36 forks source link

undefined method `new' for "ApplicationInsights::Rack::TrackRequest":String when starting server or sidekiq on Rails 5.2 #70

Open Deekor opened 5 years ago

Deekor commented 5 years ago

Just updated my Rails app from 5.0 -> 5.2 and now I cant start the rails server.

/Users/dmevans/.rvm/gems/ruby-2.4.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/stack.rb:37:in `build': undefined method `new' for "ApplicationInsights::Rack::TrackRequest":String (NoMethodError)
Did you mean?  next
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/stack.rb:101:in `block in build'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/stack.rb:101:in `each'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/stack.rb:101:in `inject'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/stack.rb:101:in `build'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/scout_apm-2.4.24/lib/scout_apm/instruments/middleware_summary.rb:31:in `build_with_scout_instruments'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/railties-5.2.3/lib/rails/engine.rb:510:in `block in app'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/railties-5.2.3/lib/rails/engine.rb:506:in `synchronize'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/railties-5.2.3/lib/rails/engine.rb:506:in `app'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/railties-5.2.3/lib/rails/application/finisher.rb:47:in `block in <module:Finisher>'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/railties-5.2.3/lib/rails/initializable.rb:32:in `instance_exec'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/railties-5.2.3/lib/rails/initializable.rb:32:in `run'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/railties-5.2.3/lib/rails/initializable.rb:61:in `block in run_initializers'
    from /Users/dmevans/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:228:in `block in tsort_each'
    from /Users/dmevans/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
    from /Users/dmevans/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:431:in `each_strongly_connected_component_from'
    from /Users/dmevans/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:349:in `block in each_strongly_connected_component'
    from /Users/dmevans/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:347:in `each'
    from /Users/dmevans/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:347:in `call'
    from /Users/dmevans/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:347:in `each_strongly_connected_component'
    from /Users/dmevans/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:226:in `tsort_each'
    from /Users/dmevans/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:205:in `tsort_each'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/railties-5.2.3/lib/rails/initializable.rb:60:in `run_initializers'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/railties-5.2.3/lib/rails/application.rb:361:in `initialize!'
    from /Users/dmevans/Repos/Bookly/config/environment.rb:5:in `<main>'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
    from config.ru:24:in `block in <main>'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/rack-2.0.7/lib/rack/builder.rb:55:in `instance_eval'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/rack-2.0.7/lib/rack/builder.rb:55:in `initialize'
    from config.ru:in `new'
    from config.ru:in `<main>'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/rack-2.0.7/lib/rack/builder.rb:49:in `eval'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/rack-2.0.7/lib/rack/builder.rb:49:in `new_from_string'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/rack-2.0.7/lib/rack/builder.rb:40:in `parse_file'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/rack-2.0.7/lib/rack/server.rb:319:in `build_app_and_options_from_config'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/rack-2.0.7/lib/rack/server.rb:219:in `app'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/railties-5.2.3/lib/rails/commands/server/server_command.rb:27:in `app'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/rack-2.0.7/lib/rack/server.rb:354:in `wrapped_app'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/railties-5.2.3/lib/rails/commands/server/server_command.rb:89:in `log_to_stdout'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/railties-5.2.3/lib/rails/commands/server/server_command.rb:51:in `start'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/railties-5.2.3/lib/rails/commands/server/server_command.rb:147:in `block in perform'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/railties-5.2.3/lib/rails/commands/server/server_command.rb:142:in `tap'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/railties-5.2.3/lib/rails/commands/server/server_command.rb:142:in `perform'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/thor-0.19.4/lib/thor/command.rb:27:in `run'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/thor-0.19.4/lib/thor/invocation.rb:126:in `invoke_command'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/thor-0.19.4/lib/thor.rb:369:in `dispatch'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/railties-5.2.3/lib/rails/command/base.rb:65:in `perform'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/railties-5.2.3/lib/rails/command.rb:46:in `invoke'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/railties-5.2.3/lib/rails/commands.rb:18:in `<main>'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
    from /Users/dmevans/.rvm/gems/ruby-2.4.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
    from bin/rails:4:in `<main>'
Deekor commented 5 years ago

Its coming from this line in development.rb

config.middleware.use 'ApplicationInsights::Rack::TrackRequest', ENV['AZURE_APP_INSIGHTS_INSTRUMENTATION_KEY'], 500
Soph commented 5 years ago

Not sure if you still having issues with that. But I just did run into the same. And the solution is to remove the quotes around ApplicationInsights::Rack::TrackRequest.

So this should work:

config.middleware.use ApplicationInsights::Rack::TrackRequest, ENV['AZURE_APP_INSIGHTS_INSTRUMENTATION_KEY'], 500