Skip to content

Commit

Permalink
Merge pull request #312 from appsignal/ignore_namespaces
Browse files Browse the repository at this point in the history
Add ignore_namespaces option
  • Loading branch information
thijsc authored Jun 15, 2017
2 parents 0ae3e01 + bc7cea2 commit 27c6e7d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
11 changes: 7 additions & 4 deletions lib/appsignal/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ class Config
DEFAULT_CONFIG = {
:debug => false,
:log => "file",
:ignore_errors => [],
:ignore_actions => [],
:ignore_errors => [],
:ignore_namespaces => [],
:filter_parameters => [],
:send_params => true,
:endpoint => "https://push.appsignal.com",
Expand Down Expand Up @@ -43,8 +44,9 @@ class Config
"APPSIGNAL_INSTRUMENT_SEQUEL" => :instrument_sequel,
"APPSIGNAL_SKIP_SESSION_DATA" => :skip_session_data,
"APPSIGNAL_ENABLE_FRONTEND_ERROR_CATCHING" => :enable_frontend_error_catching,
"APPSIGNAL_IGNORE_ERRORS" => :ignore_errors,
"APPSIGNAL_IGNORE_ACTIONS" => :ignore_actions,
"APPSIGNAL_IGNORE_ERRORS" => :ignore_errors,
"APPSIGNAL_IGNORE_NAMESPACES" => :ignore_namespaces,
"APPSIGNAL_FILTER_PARAMETERS" => :filter_parameters,
"APPSIGNAL_SEND_PARAMS" => :send_params,
"APPSIGNAL_HTTP_PROXY" => :http_proxy,
Expand Down Expand Up @@ -132,6 +134,7 @@ def write_to_environment # rubocop:disable Metrics/AbcSize
ENV["_APPSIGNAL_HTTP_PROXY"] = config_hash[:http_proxy]
ENV["_APPSIGNAL_IGNORE_ACTIONS"] = config_hash[:ignore_actions].join(",")
ENV["_APPSIGNAL_IGNORE_ERRORS"] = config_hash[:ignore_errors].join(",")
ENV["_APPSIGNAL_IGNORE_NAMESPACES"] = config_hash[:ignore_namespaces].join(",")
ENV["_APPSIGNAL_FILTER_PARAMETERS"] = config_hash[:filter_parameters].join(",")
ENV["_APPSIGNAL_SEND_PARAMS"] = config_hash[:send_params].to_s
ENV["_APPSIGNAL_RUNNING_IN_CONTAINER"] = config_hash[:running_in_container].to_s
Expand Down Expand Up @@ -209,8 +212,8 @@ def load_from_environment
end

# Configuration with array of strings type
%w(APPSIGNAL_IGNORE_ERRORS APPSIGNAL_IGNORE_ACTIONS
APPSIGNAL_FILTER_PARAMETERS).each do |var|
%w(APPSIGNAL_IGNORE_ACTIONS APPSIGNAL_IGNORE_ERRORS
APPSIGNAL_IGNORE_NAMESPACES APPSIGNAL_FILTER_PARAMETERS).each do |var|
env_var = ENV[var]
next unless env_var
config[ENV_TO_KEY_MAPPING[var]] = env_var.split(",")
Expand Down
9 changes: 8 additions & 1 deletion spec/lib/appsignal/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@
expect(config.config_hash).to eq(
:debug => false,
:log => "file",
:ignore_errors => [],
:ignore_actions => [],
:ignore_errors => [],
:ignore_namespaces => [],
:filter_parameters => [],
:instrument_net_http => true,
:instrument_redis => true,
Expand Down Expand Up @@ -279,6 +280,8 @@
ENV["APPSIGNAL_APP_NAME"] = "App name"
ENV["APPSIGNAL_DEBUG"] = "true"
ENV["APPSIGNAL_IGNORE_ACTIONS"] = "action1,action2"
ENV["APPSIGNAL_IGNORE_ERRORS"] = "VerySpecificError,AnotherError"
ENV["APPSIGNAL_IGNORE_NAMESPACES"] = "admin,private_namespace"
ENV["APPSIGNAL_INSTRUMENT_NET_HTTP"] = "false"
ENV["APPSIGNAL_INSTRUMENT_REDIS"] = "false"
ENV["APPSIGNAL_INSTRUMENT_SEQUEL"] = "false"
Expand All @@ -294,6 +297,8 @@
expect(config[:name]).to eq "App name"
expect(config[:debug]).to be_truthy
expect(config[:ignore_actions]).to eq %w(action1 action2)
expect(config[:ignore_errors]).to eq %w(VerySpecificError AnotherError)
expect(config[:ignore_namespaces]).to eq %w(admin private_namespace)
expect(config[:instrument_net_http]).to be_falsey
expect(config[:instrument_redis]).to be_falsey
expect(config[:instrument_sequel]).to be_falsey
Expand Down Expand Up @@ -366,6 +371,7 @@
config[:http_proxy] = "http://localhost"
config[:ignore_actions] = %w(action1 action2)
config[:ignore_errors] = %w(VerySpecificError AnotherError)
config[:ignore_namespaces] = %w(admin private_namespace)
config[:log] = "stdout"
config[:log_path] = "/tmp"
config[:hostname] = "app1.local"
Expand All @@ -391,6 +397,7 @@
expect(ENV["_APPSIGNAL_HTTP_PROXY"]).to eq "http://localhost"
expect(ENV["_APPSIGNAL_IGNORE_ACTIONS"]).to eq "action1,action2"
expect(ENV["_APPSIGNAL_IGNORE_ERRORS"]).to eq "VerySpecificError,AnotherError"
expect(ENV["_APPSIGNAL_IGNORE_NAMESPACES"]).to eq "admin,private_namespace"
expect(ENV["_APPSIGNAL_FILTER_PARAMETERS"]).to eq "password,confirm_password"
expect(ENV["_APPSIGNAL_SEND_PARAMS"]).to eq "true"
expect(ENV["_APPSIGNAL_RUNNING_IN_CONTAINER"]).to eq "false"
Expand Down

0 comments on commit 27c6e7d

Please sign in to comment.