Permalink
Browse files

enable filtering of env vars for rake handler

  • Loading branch information...
1 parent 9f7ea74 commit 56e2cef153ae8ec381fcceb2ebf693940c7eb0bf @shime shime committed Sep 30, 2012
Showing with 19 additions and 16 deletions.
  1. +1 −1 Rakefile
  2. +7 −7 lib/airbrake/configuration.rb
  3. +1 −1 lib/airbrake/notice.rb
  4. +7 −1 lib/airbrake/rake_handler.rb
  5. +3 −6 test/configuration_test.rb
View
@@ -9,7 +9,7 @@ rescue LoadError
end
require './lib/airbrake/version'
-FEATURES = ["sinatra","rack","metal","user_informer"]
+FEATURES = ["sinatra","rack","metal","user_informer","rake"]
desc 'Default: run unit tests.'
task :default => [:test, "cucumber:rails:all"] + FEATURES
@@ -7,8 +7,8 @@ class Configuration
:http_open_timeout, :http_read_timeout, :ignore, :ignore_by_filters,
:ignore_user_agent, :notifier_name, :notifier_url, :notifier_version,
:params_filters, :project_root, :port, :protocol, :proxy_host,
- :proxy_pass, :proxy_port, :proxy_user, :secure, :use_system_ssl_cert_chain,
- :framework, :user_information, :rescue_rake_exceptions].freeze
+ :proxy_pass, :proxy_port, :proxy_user, :secure, :use_system_ssl_cert_chain,
+ :framework, :user_information, :rescue_rake_exceptions, :rake_environment_filters].freeze
# The API key for your project, found on the project edit form.
attr_accessor :api_key
@@ -60,6 +60,10 @@ class Configuration
# A list of filters for ignoring exceptions. See #ignore_by_filter.
attr_reader :ignore_by_filters
+ # A list of environment keys that will be ignored from what is sent to Airbrake server
+ # Empty by default and used only in rake handler
+ attr_reader :rake_environment_filters
+
# A list of exception classes to ignore. The array can be appended to.
attr_reader :ignore
@@ -158,6 +162,7 @@ def initialize
@user_information = 'Airbrake Error {{error_id}}'
@rescue_rake_exceptions = nil
@user_attributes = DEFAULT_USER_ATTRIBUTES.dup
+ @rake_environment_filters = []
end
# Takes a block and adds it to the list of backtrace filters. When the filters
@@ -271,11 +276,6 @@ def js_notifier=(*args)
warn '[AIRBRAKE] config.js_notifier has been deprecated and has no effect. You should use <%= airbrake_javascript_notifier %> directly at the top of your layouts. Be sure to place it before all other javascript.'
end
- def environment_filters
- warn 'config.environment_filters has been deprecated and has no effect.'
- []
- end
-
def ca_bundle_path
if use_system_ssl_cert_chain? && File.exist?(OpenSSL::X509::DEFAULT_CERT_FILE)
OpenSSL::X509::DEFAULT_CERT_FILE
View
@@ -92,7 +92,7 @@ def attr_readers
# Private writers for all the attributes
attr_writer :exception, :api_key, :backtrace, :error_class, :error_message,
:backtrace_filters, :parameters, :params_filters,
- :environment_filters, :session_data, :project_root, :url, :ignore,
+ :session_data, :project_root, :url, :ignore,
:ignore_by_filters, :notifier_name, :notifier_url, :notifier_version,
:component, :action, :cgi_data, :environment_name, :hostname, :user
@@ -13,7 +13,7 @@ def display_error_message_with_airbrake(ex)
(Airbrake.configuration.rescue_rake_exceptions ||
(Airbrake.configuration.rescue_rake_exceptions===nil && !self.tty_output?))
- Airbrake.notify_or_ignore(ex, :component => reconstruct_command_line, :cgi_data => ENV)
+ Airbrake.notify_or_ignore(ex, :component => reconstruct_command_line, :cgi_data => environment_info)
end
display_error_message_without_airbrake(ex)
@@ -23,6 +23,12 @@ def reconstruct_command_line
"rake #{ARGV.join( ' ' )}"
end
+ def environment_info
+ ENV.reject do |k|
+ Airbrake.configuration.rake_environment_filters.include? k
+ end
+ end
+
# This module brings Rake 0.8.7 error handling to 0.9.0 standards
module Rake087Methods
# Method taken from Rake 0.9.0 source
@@ -25,6 +25,7 @@ class ConfigurationTest < Test::Unit::TestCase
Airbrake::Configuration::DEFAULT_PARAMS_FILTERS
assert_config_default :backtrace_filters,
Airbrake::Configuration::DEFAULT_BACKTRACE_FILTERS
+ assert_config_default :rake_environment_filters, []
assert_config_default :ignore,
Airbrake::Configuration::IGNORE_DEFAULT
assert_config_default :development_lookup, true
@@ -114,12 +115,8 @@ class ConfigurationTest < Test::Unit::TestCase
assert_appends_value :params_filters
end
- should "warn when attempting to read environment filters" do
- config = Airbrake::Configuration.new
- config.
- expects(:warn).
- with(regexp_matches(/deprecated/i))
- assert_equal [], config.environment_filters
+ should "allow rake environment filters to be appended" do
+ assert_appends_value :rake_environment_filters
end
should "warn when attempting to write js_notifier" do

0 comments on commit 56e2cef

Please sign in to comment.