在 Rails 通知中,我订阅了“process_action.action_controller”,并希望为有效负载添加更多属性。我怎样才能做到这一点?
我曾尝试使用 append_info_to_payload,但这似乎无济于事。
module AppendExceptionPayload
module ControllerRuntime
extend ActiveSupport::Concern
protected
def append_info_to_payload(payload)
super
payload[:happy] = "HAPPY"
end
end
end
订阅和上面的代码在 Rails 引擎中,所以这是我调用添加它的地方:
require 'append_exception_payload'
module Instrument
class Engine < ::Rails::Engine
ActiveSupport.on_load :action_controller do
include AppendExceptionPayload::ControllerRuntime
end
end
end