将我的 Heroku 应用程序移至 Unicorn 后,New Relic 停止显示除部署以外的任何报告。我尝试了此处建议的解决方案:https://newrelic.com/docs/ruby/no-data-with-unicorn没有运气。我尝试更新所有 gem,但现在出现错误:
Exiting /Users/bashar/.rvm/gems/ruby-1.9.3-preview1@global/gems/rpm_contrib-2.1.11/lib/rpm_contrib/instrumentation/mongoid.rb:13:in
block (2 levels) in <top (required)>': uninitialized constant Mongoid::Collection (NameError) from /Users/bashar/.rvm/gems/ruby-1.9.3-preview1/gems/newrelic_rpm-3.6.0.83/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb:53:in
call' from /Users/bashar/.rvm/gems/ruby-1.9.3-preview1/gems/newrelic_rpm-3.6.0.83/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb:53:inblock in execute' from /Users/bashar/.rvm/gems/ruby-1.9.3-preview1/gems/newrelic_rpm-3.6.0.83/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb:52:in
each' from /Users/bashar/.rvm/gems/ruby-1.9.3-preview1/gems/newrelic_rpm-3.6.0.83/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb:52:inexecute' from /Users/bashar/.rvm/gems/ruby-1.9.3-preview1/gems/newrelic_rpm-3.6.0.83/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb:19:in
block in detect!' from /Users/bashar/.rvm/gems/ruby-1.9.3-preview1/gems/newrelic_rpm-3.6.0.83/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb:17:ineach' from /Users/bashar/.rvm/gems/ruby-1.9.3-preview1/gems/newrelic_rpm-3.6.0.83/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb:17:in
detect!' from /Users/bashar/.rvm/gems/ruby-1.9.3-preview1/gems/newrelic_rpm-3.6.0.83/lib/new_relic/control/instrumentation.rb:93:in_install_instrumentation' from /Users/bashar/.rvm/gems/ruby-1.9.3-preview1/gems/newrelic_rpm-3.6.0.83/lib/new_relic/control/instrumentation.rb:52:in
install_instrumentation' from /Users/bashar/.rvm/gems/ruby-1.9.3-preview1/gems/newrelic_rpm-3.6.0.83/lib/new_relic/control/instance_methods.rb:76:ininit_plugin' from /Users/bashar/.rvm/gems/ruby-1.9.3-preview1/gems/newrelic_rpm-3.6.0.83/lib/newrelic_rpm.rb:40:in
block in ' from /Users/bashar/.rvm/gems/ruby-1.9.3-preview1/gems/railties-3.2.11/lib/rails/initializable.rb:30:ininstance_exec' from /Users/bashar/.rvm/gems/ruby-1.9.3-preview1/gems/railties-3.2.11/lib/rails/initializable.rb:30:in
run' from /Users/bashar/.rvm/gems/ruby-1.9.3-preview1/gems/railties-3.2.11/lib/rails/initializable.rb:55:inblock in run_initializers' from /Users/bashar/.rvm/gems/ruby-1.9.3-preview1/gems/railties-3.2.11/lib/rails/initializable.rb:54:in
each' from /Users/bashar/.rvm/gems/ruby-1.9.3-preview1/gems/railties-3.2.11/lib/rails/initializable.rb:54:inrun_initializers' from /Users/bashar/.rvm/gems/ruby-1.9.3-preview1/gems/railties-3.2.11/lib/rails/application.rb:136:in
initialize!' from /Users/bashar/.rvm/gems/ruby-1.9.3-preview1/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:30:inmethod_missing' from /Users/bashar/rails-projects/myapp/config/environment.rb:5:in
' from /Users/bashar/rails-projects/myapp/config.ru:7:inblock in <main>' from /Users/bashar/.rvm/gems/ruby-1.9.3-preview1/gems/rack-1.4.1/lib/rack/builder.rb:51:in
instance_eval' from /Users/bashar/.rvm/gems/ruby-1.9.3-preview1/gems/rack-1.4.1/lib/rack/builder.rb:51:ininitialize' from /Users/bashar/rails-projects/myapp/config.ru:1:in
new' from /Users/bashar/rails-projects/myapp/config.ru:1:in<main>' from /Users/bashar/.rvm/gems/ruby-1.9.3-preview1/gems/rack-1.4.1/lib/rack/builder.rb:40:in
eval' from /Users/bashar/.rvm/gems/ruby-1.9.3-preview1/gems/rack-1.4.1/lib/rack/builder.rb:40:inparse_file' from /Users/bashar/.rvm/gems/ruby-1.9.3-preview1/gems/rack-1.4.1/lib/rack/server.rb:200:in
app' from /Users/bashar/.rvm/gems/ruby-1.9.3-preview1/gems/railties-3.2.11/lib/rails/commands/server.rb:46:inapp' from /Users/bashar/.rvm/gems/ruby-1.9.3-preview1/gems/rack-1.4.1/lib/rack/server.rb:301:in
wrapped_app' from /Users/bashar/.rvm/gems/ruby-1.9.3-preview1/gems/rack-1.4.1/lib/rack/server.rb:252:instart' from /Users/bashar/.rvm/gems/ruby-1.9.3-preview1/gems/railties-3.2.11/lib/rails/commands/server.rb:70:in
start' from /Users/bashar/.rvm/gems/ruby-1.9.3-preview1/gems/railties-3.2.11/lib/rails/commands.rb:55:inblock in <top (required)>' from /Users/bashar/.rvm/gems/ruby-1.9.3-preview1/gems/railties-3.2.11/lib/rails/commands.rb:50:in
tap' from /Users/bashar/.rvm/gems/ruby-1.9.3-preview1/gems/railties-3.2.11/lib/rails/commands.rb:50:in<top (required)>' from script/rails:6:in
require' from script/rails:6:in `'
我有以下顺序的 gem :
gem 'rpm_contrib'
gem 'newrelic_rpm'
gem 'newrelic_moped'
我过去升级到 Mongoid 3 时遇到过类似的问题,但当时的解决方案是 newrelic_moped。这次好像不行。
有什么想法吗?
最佳答案
我也一样。将以下代码添加到 config/initializers/newrelic.rb
:
# Ensure the agent is started using Unicorn.
# This is needed when using Unicorn and preload_app is not set to true.
# See https://newrelic.com/docs/ruby/no-data-with-unicorn
if defined? Unicorn
::NewRelic::Agent.manual_start()
::NewRelic::Agent.after_fork(:force_reconnect => true)
end
关于ruby-on-rails - New Relic 导致未初始化的常量 Mongoid::Collection (NameError),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16002682/