我正在heroku上运行一个带有grape(没有rails)的ruby应用程序,并且正在使用new relic插件。这个应用程序是由独角兽提供的。如here所述,我将此选项集成到配置中。这是我的设置:
unicorn.rb:
worker_processes 3
preload_app true
timeout 30
config.ru:
if ENV['RACK_ENV'] == 'production'
require 'newrelic_rpm'
end
heroku上的环境设置为production,因此应该正确地包含该文件此外,heroku日志文件指示new relic代理已成功启动:
2013-04-08T10:47:47+00:00 heroku[deployhooks]: Notified New Relic about the deploy
2013-04-08T10:47:49+00:00 app[web.1]: ** [NewRelic][04/08/13 10:47:49 +0000 eea5ecfd-86be-4b88-8b2a-6b7564aa9943 (2)] INFO : Reading configuration from config/newrelic.yml
2013-04-08T10:47:49+00:00 app[web.1]: ** [NewRelic][04/08/13 10:47:49 +0000 eea5ecfd-86be-4b88-8b2a-6b7564aa9943 (2)] INFO : Environment: production
2013-04-08T10:47:49+00:00 app[web.1]: ** [NewRelic][04/08/13 10:47:49 +0000 eea5ecfd-86be-4b88-8b2a-6b7564aa9943 (2)] INFO : Dispatcher: unicorn
2013-04-08T10:47:49+00:00 app[web.1]: ** [NewRelic][04/08/13 10:47:49 +0000 eea5ecfd-86be-4b88-8b2a-6b7564aa9943 (2)] INFO : Application: mobile-v1-ruby
2013-04-08T10:47:49+00:00 app[web.1]: ** [NewRelic][04/08/13 10:47:49 +0000 eea5ecfd-86be-4b88-8b2a-6b7564aa9943 (2)] INFO : Connecting workers after forking.
2013-04-08T10:47:49+00:00 app[web.1]: ** [NewRelic][04/08/13 10:47:49 +0000 eea5ecfd-86be-4b88-8b2a-6b7564aa9943 (2)] INFO : Installing Net instrumentation
2013-04-08T10:47:49+00:00 app[web.1]: ** [NewRelic][04/08/13 10:47:49 +0000 eea5ecfd-86be-4b88-8b2a-6b7564aa9943 (2)] INFO : Installing Unicorn instrumentation
2013-04-08T10:47:49+00:00 app[web.1]: ** [NewRelic][04/08/13 10:47:49 +0000 eea5ecfd-86be-4b88-8b2a-6b7564aa9943 (2)] INFO : Detected Unicorn, please see additional documentation: https://newrelic.com/docs/troubleshooting/im-using-unicorn-and-i-dont-see-any-data
2013-04-08T10:47:49+00:00 app[web.1]: ** [NewRelic][04/08/13 10:47:49 +0000 eea5ecfd-86be-4b88-8b2a-6b7564aa9943 (2)] INFO : Finished instrumentation
2013-04-08T10:47:49+00:00 app[web.1]: Hey there - I started in environment: production
2013-04-08T10:47:49+00:00 app[web.1]: I, [2013-04-08T10:47:49.798057 #2] INFO -- : listening on addr=0.0.0.0:58224 fd=9
2013-04-08T10:47:49+00:00 app[web.1]: I, [2013-04-08T10:47:49.798299 #2] INFO -- : worker=0 spawning...
2013-04-08T10:47:49+00:00 app[web.1]: I, [2013-04-08T10:47:49.809140 #2] INFO -- : worker=1 spawning...
2013-04-08T10:47:49+00:00 app[web.1]: I, [2013-04-08T10:47:49.812632 #5] INFO -- : worker=0 spawned pid=5
2013-04-08T10:47:49+00:00 app[web.1]: I, [2013-04-08T10:47:49.816144 #2] INFO -- : worker=2 spawning...
2013-04-08T10:47:49+00:00 app[web.1]: I, [2013-04-08T10:47:49.819594 #5] INFO -- : worker=0 ready
2013-04-08T10:47:49+00:00 app[web.1]: I, [2013-04-08T10:47:49.821252 #9] INFO -- : worker=1 spawned pid=9
2013-04-08T10:47:49+00:00 app[web.1]: I, [2013-04-08T10:47:49.823869 #2] INFO -- : master process ready
2013-04-08T10:47:49+00:00 app[web.1]: I, [2013-04-08T10:47:49.826441 #9] INFO -- : worker=1 ready
2013-04-08T10:47:49+00:00 app[web.1]: I, [2013-04-08T10:47:49.831072 #13] INFO -- : worker=2 spawned pid=13
2013-04-08T10:47:49+00:00 app[web.1]: I, [2013-04-08T10:47:49.836053 #13] INFO -- : worker=2 ready
2013-04-08T10:47:50+00:00 heroku[web.1]: State changed from starting to up
对我来说一切都很好。但在new relic上,我只接收部署通知。有人知道吗?
非常感谢。
最佳答案
我现在可以解决了谢谢你们的帮助,伙计们它使用的是开发模式、葡萄请求显示以及通过mongoid对mongodb的数据库请求。
猜猜看:最糟糕的问题之一是我的条件加载中的字符串比较:
if ENV['RACK_ENV'] == "production"
用==的等式似乎不起作用。我把它改成了.eql?(方法加上一些新的文物仪器重新加载的东西,现在一切工作神奇:d真棒!
if ENV['RACK_ENV'].eql?("production")
这是我的工作设置:
Gemfile公司
gem "newrelic-grape"
gem "newrelic_moped"
gem "newrelic_rpm"
配置ru
run MyApp.new
if ENV["NEW_RELIC_ENABLE"].eql?("true")
if ENV["RACK_ENV"].eql?("development")
puts "Loading NewRelic in developer mode ..."
require "new_relic/rack/developer_mode"
use NewRelic::Rack::DeveloperMode
end
if !ENV["RACK_ENV"].eql?("test")
NewRelic::Agent.manual_start
DependencyDetection.detect!
end
end
如果正确定义了RACK-ENV,这将以开发人员模式加载new relic否则,它将正常启动,除非处于测试模式。
这里最大的问题是缺少命令newrelic::agent.manual_start和dependencyDetection.detect!
如果启用了new relic,则api.rb类现在包括机架检测。
api.rb标准
if !ENV['RACK_ENV'].eql?("test") && ENV['NEW_RELIC_ENABLE'].eql?("true")
include NewRelic::Agent::Instrumentation::Rack
end
关于ruby - 尽管preload_app = true,通过Heroku的Newrelic不会从Unicorn中运行的Ruby实例接收数据,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15877587/