【发布时间】:2016-06-27 12:32:41
【问题描述】:
我在 heroku 上部署了一个标准的 rails 4 应用程序。
我正在尝试向它添加错误。
第一:
- 我在 Bugsnag UI (https://bugsnag.com/accounts/jobteaser/projects/new) 中创建了一个新项目,
- 选择导轨,
rails generate bugsnag <API_KEY_FROM_BUGSNAG_UI>
宝石文件
gem 'bugsnag'
config/initializers/bugsnag.rb
Bugsnag.configure do |config|
config.api_key = '<API_KEY_FROM_BUGSNAG_UI>'
end
lib/tasks/test_exception.rake
namespace :myapp do
desc 'Test task that raises an exception'
task :test_exception do
raise 'This is a sample exception'
end
end
- 然后我使用
git push heroku master提交、推送和部署 - 确保 heroku 是最新的
heroku restart
然后heroku run rake myapp:test_exception
=>
Running rake myapp:test_exception on ⬢ myapp... up, run.2877
W, [2016-06-27T12:23:56.017117 #3]
WARN -- : ** [Bugsnag] No API key configured, couldn't notify rake aborted!
This is a sample exception
/app/lib/tasks/test_exception.rake:9:in `block (2 levels) in <top (required)>'
/app/vendor/bundle/ruby/2.2.0/gems/bugsnag-4.2.1/lib/bugsnag/rake.rb:12:in `execute_with_bugsnag'
Tasks: TOP => jd:sample_exception
(See full trace by running task with --trace)
我希望 heroku 向 bugsnag 发送异常。我错过了什么?
注意:如果我在本地运行命令,则 bugsnag 集成工作正常(我在 bugsnag UI 中看到异常),例如:rake myapp:test_exception
【问题讨论】:
标签: ruby-on-rails-4 heroku bugsnag