在自定义 Airbrake 通知中传递环境

发布于 2025-01-03 20:59:51 字数 474 浏览 0 评论 0原文

我已经从与 Rails 应用程序一起运行的 Ruby EM 服务器向 Airbrake 编写了自定义通知。在发生异常的情况下,我按照 API 文档通知 Airbrake

 Airbrake.notify(
    :error_class   => "Ruby EM Server Error:",
    :error_message => "EM Server Crashed with error: #{$!}",
    :backtrace    => $@,
  ) if ENV['RAILS_ENV'] == 'production'

但是,当错误显示为“未知:EM 服务器因错误而崩溃:”时,

我知道发送通知时的 RAILS_ENV 是什么,所以我想知道是否有什么方法可以将这些信息传递给 Airbrake,而无需编写 XML 并将其发布。

我希望看到错误显示为“生产:EM 服务器因错误而崩溃:”

I've written a custom notification to Airbrake from a Ruby EM server we run along with our Rails app. In the case of an exception, I notify Airbrake as per the API docs

 Airbrake.notify(
    :error_class   => "Ruby EM Server Error:",
    :error_message => "EM Server Crashed with error: #{$!}",
    :backtrace    => $@,
  ) if ENV['RAILS_ENV'] == 'production'

However, when the error comes through as "Unknown: EM Server Crashed with error:"

I know what the RAILS_ENV is when I send off the notification so I was wondering if there was any way I can pass this info on to Airbrake without writing XML and posting it.

I'd like to see the error to come through as "Production: EM Server Crashed with error:"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甩你一脸翔 2025-01-10 20:59:51

试试这个:

 Airbrake.notify(
    :error_class      => "Ruby EM Server Error:",
    :error_message    => "EM Server Crashed with error: #{$!}",
    :backtrace        => $@,
    :environment_name => ENV['RAILS_ENV']
  ) if ENV['RAILS_ENV'] == 'production'

environment_name选项位于gem的文档中。

Try this:

 Airbrake.notify(
    :error_class      => "Ruby EM Server Error:",
    :error_message    => "EM Server Crashed with error: #{$!}",
    :backtrace        => $@,
    :environment_name => ENV['RAILS_ENV']
  ) if ENV['RAILS_ENV'] == 'production'

The environment_name option is in the gem's documentation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文