ruby-on-rails - 为 heroku run rake、heroku run console 等关闭 NewRelic

标签 ruby-on-rails ruby heroku newrelic

我已经在我的 Heroku 应用程序上安装了 NewRelic,但是当我使用 heroku run rake xxx 运行 rake 任务时,我想将它关闭(或者至少看不到日志)——它会产生很多自己的输出,以至于rake 任务的结果是模糊的。

想知道是否有一些方法可以通过 NewRelic 配置文件等来做到这一点

This question here suggests that it solves the problem,但我很好地保留应用程序的New Relic设置,只是不适用于rake、控制台和其他我可能希望自己阅读的命令行任务“放”输出等

最佳答案

在 Rails 应用程序的根目录中编辑 Rakefile,并添加以下内容:

ENV['NEW_RELIC_AGENT_ENABLED'] = 'false'

NewRelic 代理将遵守此环境变量,并且在 Rakefile 中设置它会导致在您的应用程序或 newrelic 代理加载之前为所有 rake 任务设置它。

关于ruby-on-rails - 为 heroku run rake、heroku run console 等关闭 NewRelic,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21384766/

相关文章:

ruby-on-rails - rake db :migrate do? 究竟是什么

ruby - 使用 Liquid 获取、操作和排序哈希对象值

mysql - ld : library not found for -lzstd while bundle install for mysql2 gem Ruby on macOS Big Sur 11. 4

swift - Vapor 网络套接字保持与数据库的连接

java - 如何创建表 postgresql Heroku?

ruby-on-rails - rails : Why “collection=” doesn't update records with existing id?

ruby-on-rails - 如何在 Rails 中模拟半金融交易

ruby-on-rails - Rails 3.1 Assets 管道和缓存

ruby-on-rails - #<PG::Result:0x007fcc82900a78> 的未定义方法 `empty?'

node.js - 如何将客户端的正确 IP 地址获取到托管在 Heroku 上的 Node socket.io 应用程序中?