diff --git a/lib/honeybadger/config/defaults.rb b/lib/honeybadger/config/defaults.rb index cdd77ed5..1923a46a 100644 --- a/lib/honeybadger/config/defaults.rb +++ b/lib/honeybadger/config/defaults.rb @@ -325,6 +325,11 @@ class Boolean; end default: false, type: Boolean }, + "active_agent.insights.enabled": { + description: "Enable automatic data collection for Active Agent.", + default: true, + type: Boolean + }, "active_job.attempt_threshold": { description: "The number of attempts before notifications will be sent.", default: 0, diff --git a/lib/honeybadger/plugins/active_agent.rb b/lib/honeybadger/plugins/active_agent.rb new file mode 100644 index 00000000..fd7cd417 --- /dev/null +++ b/lib/honeybadger/plugins/active_agent.rb @@ -0,0 +1,16 @@ +require "honeybadger/plugin" +require "honeybadger/ruby" +require "honeybadger/notification_subscriber" + +module Honeybadger + Plugin.register :active_agent do + requirement { defined?(::ActiveAgent) } + + execution do + if config.load_plugin_insights?(:active_agent) + # TODO: NotificationSubscriber may be the wrong thing to use here, or we may want to subclass it. + ::ActiveSupport::Notifications.subscribe(/(prompt|embed|stream_open|stream_close|stream_chunk|tool_call|process|provider)\.active_agent/, Honeybadger::NotificationSubscriber.new) + end + end + end +end