Class: Airbrake::Notifier Private
- Inherits:
-
Object
- Object
- Airbrake::Notifier
- Defined in:
- lib/airbrake-ruby/notifier.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
This class is reponsible for sending notices to Airbrake. It supports synchronous and asynchronous delivery.
Instance Method Summary collapse
- #add_filter(filter = nil, &block) ⇒ Object private
- #blacklist_keys(keys) ⇒ Object private
- #build_notice(exception, params = {}) ⇒ Object private
- #close ⇒ Object private
- #create_deploy(deploy_params) ⇒ Object private
-
#initialize(user_config) ⇒ Notifier
constructor
private
Creates a new Airbrake notifier with the given config options.
- #notify(exception, params = {}) ⇒ Object private
- #notify_sync(exception, params = {}) ⇒ Object private
- #whitelist_keys(keys) ⇒ Object private
Constructor Details
#initialize(user_config) ⇒ Notifier
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates a new Airbrake notifier with the given config options.
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/airbrake-ruby/notifier.rb', line 26 def initialize(user_config) @config = (user_config.is_a?(Config) ? user_config : Config.new(user_config)) unless [@config.project_id, @config.project_key].all? raise Airbrake::Error, 'both :project_id and :project_key are required' end @filter_chain = FilterChain.new(@config) @async_sender = AsyncSender.new(@config) @sync_sender = SyncSender.new(@config) end |
Instance Method Details
#add_filter(filter = nil, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
57 58 59 |
# File 'lib/airbrake-ruby/notifier.rb', line 57 def add_filter(filter = nil, &block) @filter_chain.add_filter(block_given? ? block : filter) end |
#blacklist_keys(keys) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
69 70 71 |
# File 'lib/airbrake-ruby/notifier.rb', line 69 def blacklist_keys(keys) add_filter(Filters::KeysBlacklist.new(*keys)) end |
#build_notice(exception, params = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/airbrake-ruby/notifier.rb', line 75 def build_notice(exception, params = {}) if @async_sender.closed? raise Airbrake::Error, "attempted to build #{exception} with closed Airbrake instance" end if exception.is_a?(Airbrake::Notice) exception else Notice.new(@config, convert_to_exception(exception), params) end end |
#close ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
90 91 92 |
# File 'lib/airbrake-ruby/notifier.rb', line 90 def close @async_sender.close end |
#create_deploy(deploy_params) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
96 97 98 99 100 101 102 103 |
# File 'lib/airbrake-ruby/notifier.rb', line 96 def create_deploy(deploy_params) deploy_params[:environment] ||= @config.environment host = @config.endpoint.to_s.split(@config.endpoint.path).first path = "/api/v4/projects/#{@config.project_id}/deploys?key=#{@config.project_key}" @sync_sender.send(deploy_params, URI.join(host, path)) end |
#notify(exception, params = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
44 45 46 47 |
# File 'lib/airbrake-ruby/notifier.rb', line 44 def notify(exception, params = {}) send_notice(exception, params) nil end |
#notify_sync(exception, params = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
51 52 53 |
# File 'lib/airbrake-ruby/notifier.rb', line 51 def notify_sync(exception, params = {}) send_notice(exception, params, @sync_sender) end |
#whitelist_keys(keys) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
63 64 65 |
# File 'lib/airbrake-ruby/notifier.rb', line 63 def whitelist_keys(keys) add_filter(Filters::KeysWhitelist.new(*keys)) end |