appsignal 2.1.0.alpha.3 → 2.1.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +43 -0
- data/.rubocop_todo.yml +289 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +11 -1
- data/Gemfile +1 -1
- data/LICENSE +1 -1
- data/appsignal.gemspec +1 -0
- data/bin/appsignal +2 -2
- data/ext/agent.yml +11 -11
- data/ext/extconf.rb +33 -33
- data/gemfiles/rails-4.2.gemfile +4 -0
- data/gemfiles/resque.gemfile +4 -0
- data/lib/appsignal.rb +58 -54
- data/lib/appsignal/auth_check.rb +15 -16
- data/lib/appsignal/capistrano.rb +4 -4
- data/lib/appsignal/cli.rb +28 -28
- data/lib/appsignal/cli/diagnose.rb +11 -11
- data/lib/appsignal/cli/helpers.rb +1 -1
- data/lib/appsignal/cli/install.rb +38 -38
- data/lib/appsignal/cli/notify_of_deploy.rb +1 -1
- data/lib/appsignal/config.rb +73 -71
- data/lib/appsignal/event_formatter.rb +8 -8
- data/lib/appsignal/event_formatter/action_view/render_formatter.rb +4 -4
- data/lib/appsignal/event_formatter/active_record/instantiation_formatter.rb +1 -1
- data/lib/appsignal/event_formatter/active_record/sql_formatter.rb +1 -1
- data/lib/appsignal/event_formatter/elastic_search/search_formatter.rb +9 -7
- data/lib/appsignal/event_formatter/faraday/request_formatter.rb +1 -1
- data/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter.rb +6 -6
- data/lib/appsignal/event_formatter/moped/query_formatter.rb +56 -43
- data/lib/appsignal/extension.rb +5 -5
- data/lib/appsignal/hooks.rb +28 -26
- data/lib/appsignal/hooks/active_support_notifications.rb +2 -2
- data/lib/appsignal/hooks/celluloid.rb +1 -1
- data/lib/appsignal/hooks/data_mapper.rb +2 -2
- data/lib/appsignal/hooks/delayed_job.rb +1 -1
- data/lib/appsignal/hooks/mongo_ruby_driver.rb +1 -1
- data/lib/appsignal/hooks/net_http.rb +4 -4
- data/lib/appsignal/hooks/passenger.rb +2 -2
- data/lib/appsignal/hooks/puma.rb +4 -4
- data/lib/appsignal/hooks/rake.rb +1 -1
- data/lib/appsignal/hooks/redis.rb +1 -1
- data/lib/appsignal/hooks/sequel.rb +2 -2
- data/lib/appsignal/hooks/shoryuken.rb +8 -8
- data/lib/appsignal/hooks/sidekiq.rb +16 -15
- data/lib/appsignal/hooks/unicorn.rb +1 -1
- data/lib/appsignal/hooks/webmachine.rb +1 -1
- data/lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb +6 -6
- data/lib/appsignal/integrations/data_mapper.rb +2 -3
- data/lib/appsignal/integrations/delayed_job_plugin.rb +5 -5
- data/lib/appsignal/integrations/mongo_ruby_driver.rb +6 -6
- data/lib/appsignal/integrations/padrino.rb +8 -8
- data/lib/appsignal/integrations/railtie.rb +5 -5
- data/lib/appsignal/integrations/resque.rb +4 -5
- data/lib/appsignal/integrations/resque_active_job.rb +3 -6
- data/lib/appsignal/integrations/sinatra.rb +2 -2
- data/lib/appsignal/integrations/webmachine.rb +2 -3
- data/lib/appsignal/js_exception_transaction.rb +10 -10
- data/lib/appsignal/marker.rb +3 -3
- data/lib/appsignal/rack/generic_instrumentation.rb +10 -9
- data/lib/appsignal/rack/js_exception_catcher.rb +7 -6
- data/lib/appsignal/rack/rails_instrumentation.rb +9 -8
- data/lib/appsignal/rack/sinatra_instrumentation.rb +19 -17
- data/lib/appsignal/rack/streaming_listener.rb +9 -8
- data/lib/appsignal/system.rb +19 -17
- data/lib/appsignal/transaction.rb +97 -40
- data/lib/appsignal/transmitter.rb +23 -30
- data/lib/appsignal/utils.rb +3 -3
- data/lib/appsignal/utils/params_sanitizer.rb +1 -1
- data/lib/appsignal/utils/query_params_sanitizer.rb +1 -1
- data/lib/appsignal/version.rb +2 -2
- data/spec/.rubocop.yml +4 -0
- data/spec/lib/appsignal/auth_check_spec.rb +7 -7
- data/spec/lib/appsignal/capistrano2_spec.rb +41 -41
- data/spec/lib/appsignal/capistrano3_spec.rb +43 -44
- data/spec/lib/appsignal/cli/notify_of_deploy_spec.rb +9 -11
- data/spec/lib/appsignal/cli_spec.rb +9 -9
- data/spec/lib/appsignal/config_spec.rb +88 -86
- data/spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb +9 -9
- data/spec/lib/appsignal/event_formatter/active_record/instantiation_formatter_spec.rb +4 -4
- data/spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb +4 -4
- data/spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb +12 -12
- data/spec/lib/appsignal/event_formatter/faraday/request_formatter_spec.rb +4 -4
- data/spec/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter_spec.rb +23 -23
- data/spec/lib/appsignal/event_formatter/moped/query_formatter_spec.rb +29 -30
- data/spec/lib/appsignal/event_formatter_spec.rb +28 -28
- data/spec/lib/appsignal/extension_spec.rb +15 -15
- data/spec/lib/appsignal/garbage_collection_profiler_spec.rb +6 -5
- data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +12 -12
- data/spec/lib/appsignal/hooks/delayed_job_spec.rb +34 -34
- data/spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb +3 -3
- data/spec/lib/appsignal/hooks/net_http_spec.rb +10 -10
- data/spec/lib/appsignal/hooks/rake_spec.rb +7 -7
- data/spec/lib/appsignal/hooks/redis_spec.rb +6 -6
- data/spec/lib/appsignal/hooks/shoryuken_spec.rb +21 -22
- data/spec/lib/appsignal/hooks/sidekiq_spec.rb +48 -45
- data/spec/lib/appsignal/hooks/webmachine_spec.rb +2 -2
- data/spec/lib/appsignal/hooks_spec.rb +16 -17
- data/spec/lib/appsignal/integrations/data_mapper_spec.rb +7 -8
- data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +19 -19
- data/spec/lib/appsignal/integrations/object_spec.rb +3 -3
- data/spec/lib/appsignal/integrations/padrino_spec.rb +44 -44
- data/spec/lib/appsignal/integrations/railtie_spec.rb +13 -13
- data/spec/lib/appsignal/integrations/resque_active_job_spec.rb +7 -7
- data/spec/lib/appsignal/integrations/resque_spec.rb +8 -8
- data/spec/lib/appsignal/integrations/sinatra_spec.rb +7 -7
- data/spec/lib/appsignal/integrations/webmachine_spec.rb +15 -15
- data/spec/lib/appsignal/js_exception_transaction_spec.rb +23 -23
- data/spec/lib/appsignal/marker_spec.rb +8 -8
- data/spec/lib/appsignal/minutely_spec.rb +6 -6
- data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +7 -7
- data/spec/lib/appsignal/rack/js_exception_catcher_spec.rb +13 -13
- data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +11 -11
- data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +21 -21
- data/spec/lib/appsignal/rack/streaming_listener_spec.rb +36 -36
- data/spec/lib/appsignal/system/container_spec.rb +1 -1
- data/spec/lib/appsignal/transaction_spec.rb +213 -184
- data/spec/lib/appsignal/transmitter_spec.rb +20 -20
- data/spec/lib/appsignal/utils/params_sanitizer_spec.rb +19 -19
- data/spec/lib/appsignal/utils/query_params_sanitizer_spec.rb +41 -41
- data/spec/lib/appsignal/utils_spec.rb +41 -37
- data/spec/lib/appsignal_spec.rb +150 -142
- data/spec/spec_helper.rb +18 -18
- data/spec/support/delegate_matcher.rb +6 -6
- data/spec/support/helpers/api_request_helper.rb +2 -2
- data/spec/support/helpers/config_helpers.rb +3 -3
- data/spec/support/helpers/dependency_helper.rb +13 -13
- data/spec/support/helpers/directory_helper.rb +5 -5
- data/spec/support/helpers/env_helpers.rb +14 -14
- data/spec/support/helpers/system_helpers.rb +3 -3
- data/spec/support/helpers/transaction_helpers.rb +10 -10
- metadata +20 -2
@@ -1,14 +1,14 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require "erb"
|
2
|
+
require "ostruct"
|
3
|
+
require "io/console"
|
4
|
+
require "appsignal/demo"
|
5
5
|
|
6
6
|
module Appsignal
|
7
7
|
class CLI
|
8
8
|
class Install
|
9
9
|
extend CLI::Helpers
|
10
10
|
|
11
|
-
EXCLUDED_ENVIRONMENTS = [
|
11
|
+
EXCLUDED_ENVIRONMENTS = ["test"].freeze
|
12
12
|
|
13
13
|
class << self
|
14
14
|
def run(push_api_key)
|
@@ -21,23 +21,23 @@ module Appsignal
|
|
21
21
|
puts colorize "#######################################", :green
|
22
22
|
puts
|
23
23
|
unless push_api_key
|
24
|
-
puts colorize
|
25
|
-
puts
|
26
|
-
puts
|
24
|
+
puts colorize "Problem encountered:", :red
|
25
|
+
puts " No push API key entered."
|
26
|
+
puts " - Sign up for AppSignal and follow the instructions"
|
27
27
|
puts " - Already signed up? Click 'New app' on the account overview page"
|
28
28
|
puts
|
29
|
-
puts colorize
|
29
|
+
puts colorize "Exiting installer...", :red
|
30
30
|
return
|
31
31
|
end
|
32
32
|
config = new_config
|
33
33
|
config[:push_api_key] = push_api_key
|
34
34
|
|
35
|
-
print
|
35
|
+
print "Validating API key"
|
36
36
|
periods
|
37
37
|
puts
|
38
38
|
begin
|
39
39
|
auth_check = Appsignal::AuthCheck.new(config)
|
40
|
-
unless auth_check.perform ==
|
40
|
+
unless auth_check.perform == "200"
|
41
41
|
puts "\n API key '#{config[:push_api_key]}' is not valid, please get a new one on https://appsignal.com"
|
42
42
|
return
|
43
43
|
end
|
@@ -47,7 +47,7 @@ module Appsignal
|
|
47
47
|
puts " Please try again"
|
48
48
|
return
|
49
49
|
end
|
50
|
-
puts colorize
|
50
|
+
puts colorize " API key valid!", :green
|
51
51
|
puts
|
52
52
|
|
53
53
|
if installed_frameworks.include?(:rails)
|
@@ -64,9 +64,9 @@ module Appsignal
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def install_for_rails(config)
|
67
|
-
require File.expand_path(File.join(Dir.pwd,
|
67
|
+
require File.expand_path(File.join(Dir.pwd, "config/application.rb"))
|
68
68
|
|
69
|
-
puts
|
69
|
+
puts "Installing for Ruby on Rails"
|
70
70
|
|
71
71
|
config[:name] = Rails.application.class.parent_name
|
72
72
|
|
@@ -82,10 +82,10 @@ module Appsignal
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def install_for_sinatra(config)
|
85
|
-
puts
|
86
|
-
config[:name] = required_input(
|
85
|
+
puts "Installing for Sinatra"
|
86
|
+
config[:name] = required_input(" Enter application name: ")
|
87
87
|
puts
|
88
|
-
configure(config, [
|
88
|
+
configure(config, ["development", "production", "staging"], true)
|
89
89
|
|
90
90
|
puts "Finish Sinatra configuration"
|
91
91
|
puts " Sinatra requires some manual configuration."
|
@@ -100,10 +100,10 @@ module Appsignal
|
|
100
100
|
end
|
101
101
|
|
102
102
|
def install_for_padrino(config)
|
103
|
-
puts
|
104
|
-
config[:name] = required_input(
|
103
|
+
puts "Installing for Padrino"
|
104
|
+
config[:name] = required_input(" Enter application name: ")
|
105
105
|
puts
|
106
|
-
configure(config, [
|
106
|
+
configure(config, ["development", "production", "staging"], true)
|
107
107
|
|
108
108
|
puts "Finish Padrino installation"
|
109
109
|
puts " Padrino requires some manual configuration."
|
@@ -118,12 +118,12 @@ module Appsignal
|
|
118
118
|
end
|
119
119
|
|
120
120
|
def install_for_grape(config)
|
121
|
-
puts
|
121
|
+
puts "Installing for Grape"
|
122
122
|
|
123
|
-
config[:name] = required_input(
|
123
|
+
config[:name] = required_input(" Enter application name: ")
|
124
124
|
puts
|
125
125
|
|
126
|
-
configure(config, [
|
126
|
+
configure(config, ["development", "production", "staging"], true)
|
127
127
|
|
128
128
|
puts "Manual Grape configuration needed"
|
129
129
|
puts " See the installation instructions at:"
|
@@ -133,13 +133,13 @@ module Appsignal
|
|
133
133
|
end
|
134
134
|
|
135
135
|
def install_for_capistrano
|
136
|
-
capfile = File.join(Dir.pwd,
|
136
|
+
capfile = File.join(Dir.pwd, "Capfile")
|
137
137
|
return unless File.exist?(capfile)
|
138
138
|
return if File.read(capfile) =~ %r{require ['|"]appsignal/capistrano}
|
139
139
|
|
140
|
-
puts
|
141
|
-
print
|
142
|
-
File.open(capfile,
|
140
|
+
puts "Installing for Capistrano"
|
141
|
+
print " Adding AppSignal integration to Capfile"
|
142
|
+
File.open(capfile, "a") do |f|
|
143
143
|
f.write "\nrequire 'appsignal/capistrano'\n"
|
144
144
|
end
|
145
145
|
periods
|
@@ -158,7 +158,7 @@ module Appsignal
|
|
158
158
|
loop do
|
159
159
|
print " Choose (1/2): "
|
160
160
|
case ask_for_input
|
161
|
-
when
|
161
|
+
when "1"
|
162
162
|
puts
|
163
163
|
print "Writing config file"
|
164
164
|
periods
|
@@ -171,7 +171,7 @@ module Appsignal
|
|
171
171
|
)
|
172
172
|
puts
|
173
173
|
break
|
174
|
-
when
|
174
|
+
when "2"
|
175
175
|
ENV["APPSIGNAL_ACTIVE"] = "true"
|
176
176
|
ENV["APPSIGNAL_PUSH_API_KEY"] = config[:push_api_key]
|
177
177
|
ENV["APPSIGNAL_APP_NAME"] = config[:name]
|
@@ -199,7 +199,7 @@ module Appsignal
|
|
199
199
|
sleep 0.3
|
200
200
|
puts
|
201
201
|
if Gem.win_platform?
|
202
|
-
puts
|
202
|
+
puts "The AppSignal agent currently does not work on Windows, please push these changes to your test/staging/production environment"
|
203
203
|
else
|
204
204
|
puts " Sending example data to AppSignal..."
|
205
205
|
if Appsignal::Demo.transmit
|
@@ -217,22 +217,22 @@ module Appsignal
|
|
217
217
|
def installed_frameworks
|
218
218
|
[].tap do |out|
|
219
219
|
begin
|
220
|
-
require
|
220
|
+
require "rails"
|
221
221
|
out << :rails
|
222
222
|
rescue LoadError
|
223
223
|
end
|
224
224
|
begin
|
225
|
-
require
|
225
|
+
require "sinatra"
|
226
226
|
out << :sinatra
|
227
227
|
rescue LoadError
|
228
228
|
end
|
229
229
|
begin
|
230
|
-
require
|
230
|
+
require "padrino"
|
231
231
|
out << :padrino
|
232
232
|
rescue LoadError
|
233
233
|
end
|
234
234
|
begin
|
235
|
-
require
|
235
|
+
require "grape"
|
236
236
|
out << :grape
|
237
237
|
rescue LoadError
|
238
238
|
end
|
@@ -241,7 +241,7 @@ module Appsignal
|
|
241
241
|
|
242
242
|
def rails_environments
|
243
243
|
Dir.glob(
|
244
|
-
File.join(Dir.pwd,
|
244
|
+
File.join(Dir.pwd, "config/environments/*.rb")
|
245
245
|
).map { |o| File.basename(o, ".rb") }.sort - EXCLUDED_ENVIRONMENTS
|
246
246
|
end
|
247
247
|
|
@@ -249,13 +249,13 @@ module Appsignal
|
|
249
249
|
template = ERB.new(
|
250
250
|
File.read(File.join(File.dirname(__FILE__), "../../../resources/appsignal.yml.erb")),
|
251
251
|
nil,
|
252
|
-
|
252
|
+
"-"
|
253
253
|
)
|
254
254
|
|
255
255
|
config = template.result(OpenStruct.new(data).instance_eval { binding })
|
256
256
|
|
257
|
-
FileUtils.mkdir_p(File.join(Dir.pwd,
|
258
|
-
File.write(File.join(Dir.pwd,
|
257
|
+
FileUtils.mkdir_p(File.join(Dir.pwd, "config"))
|
258
|
+
File.write(File.join(Dir.pwd, "config/appsignal.yml"), config)
|
259
259
|
end
|
260
260
|
|
261
261
|
def new_config
|
data/lib/appsignal/config.rb
CHANGED
@@ -1,67 +1,67 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require "erb"
|
2
|
+
require "yaml"
|
3
|
+
require "uri"
|
4
|
+
require "socket"
|
5
5
|
|
6
6
|
module Appsignal
|
7
7
|
class Config
|
8
|
-
SYSTEM_TMP_DIR = File.realpath(
|
8
|
+
SYSTEM_TMP_DIR = File.realpath("/tmp")
|
9
9
|
DEFAULT_CONFIG = {
|
10
10
|
:debug => false,
|
11
|
-
:log =>
|
11
|
+
:log => "file",
|
12
12
|
:ignore_errors => [],
|
13
13
|
:ignore_actions => [],
|
14
14
|
:filter_parameters => [],
|
15
15
|
:send_params => true,
|
16
|
-
:endpoint =>
|
16
|
+
:endpoint => "https://push.appsignal.com",
|
17
17
|
:instrument_net_http => true,
|
18
18
|
:instrument_redis => true,
|
19
19
|
:instrument_sequel => true,
|
20
20
|
:skip_session_data => false,
|
21
21
|
:enable_frontend_error_catching => false,
|
22
|
-
:frontend_error_catching_path =>
|
22
|
+
:frontend_error_catching_path => "/appsignal_error_catcher",
|
23
23
|
:enable_allocation_tracking => true,
|
24
24
|
:enable_gc_instrumentation => false,
|
25
25
|
:running_in_container => false,
|
26
26
|
:enable_host_metrics => true,
|
27
27
|
:enable_minutely_probes => false,
|
28
28
|
:hostname => ::Socket.gethostname,
|
29
|
-
:ca_file_path => File.expand_path(File.join(
|
29
|
+
:ca_file_path => File.expand_path(File.join("../../../resources/cacert.pem"), __FILE__)
|
30
30
|
}.freeze
|
31
31
|
|
32
32
|
ENV_TO_KEY_MAPPING = {
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
33
|
+
"APPSIGNAL_ACTIVE" => :active,
|
34
|
+
"APPSIGNAL_PUSH_API_KEY" => :push_api_key,
|
35
|
+
"APPSIGNAL_APP_NAME" => :name,
|
36
|
+
"APPSIGNAL_PUSH_API_ENDPOINT" => :endpoint,
|
37
|
+
"APPSIGNAL_FRONTEND_ERROR_CATCHING_PATH" => :frontend_error_catching_path,
|
38
|
+
"APPSIGNAL_DEBUG" => :debug,
|
39
|
+
"APPSIGNAL_LOG" => :log,
|
40
|
+
"APPSIGNAL_LOG_PATH" => :log_path,
|
41
|
+
"APPSIGNAL_INSTRUMENT_NET_HTTP" => :instrument_net_http,
|
42
|
+
"APPSIGNAL_INSTRUMENT_REDIS" => :instrument_redis,
|
43
|
+
"APPSIGNAL_INSTRUMENT_SEQUEL" => :instrument_sequel,
|
44
|
+
"APPSIGNAL_SKIP_SESSION_DATA" => :skip_session_data,
|
45
|
+
"APPSIGNAL_ENABLE_FRONTEND_ERROR_CATCHING" => :enable_frontend_error_catching,
|
46
|
+
"APPSIGNAL_IGNORE_ERRORS" => :ignore_errors,
|
47
|
+
"APPSIGNAL_IGNORE_ACTIONS" => :ignore_actions,
|
48
|
+
"APPSIGNAL_FILTER_PARAMETERS" => :filter_parameters,
|
49
|
+
"APPSIGNAL_SEND_PARAMS" => :send_params,
|
50
|
+
"APPSIGNAL_HTTP_PROXY" => :http_proxy,
|
51
|
+
"APPSIGNAL_ENABLE_ALLOCATION_TRACKING" => :enable_allocation_tracking,
|
52
|
+
"APPSIGNAL_ENABLE_GC_INSTRUMENTATION" => :enable_gc_instrumentation,
|
53
|
+
"APPSIGNAL_RUNNING_IN_CONTAINER" => :running_in_container,
|
54
|
+
"APPSIGNAL_WORKING_DIR_PATH" => :working_dir_path,
|
55
|
+
"APPSIGNAL_ENABLE_HOST_METRICS" => :enable_host_metrics,
|
56
|
+
"APPSIGNAL_ENABLE_MINUTELY_PROBES" => :enable_minutely_probes,
|
57
|
+
"APPSIGNAL_HOSTNAME" => :hostname,
|
58
|
+
"APPSIGNAL_CA_FILE_PATH" => :ca_file_path
|
59
59
|
}.freeze
|
60
60
|
|
61
61
|
attr_reader :root_path, :env, :initial_config, :config_hash
|
62
62
|
attr_accessor :logger
|
63
63
|
|
64
|
-
def initialize(root_path, env, initial_config={}, logger=Appsignal.logger)
|
64
|
+
def initialize(root_path, env, initial_config = {}, logger = Appsignal.logger)
|
65
65
|
@root_path = root_path
|
66
66
|
@env = ENV.fetch("APPSIGNAL_APP_ENV".freeze, env.to_s)
|
67
67
|
@initial_config = initial_config
|
@@ -90,16 +90,16 @@ module Appsignal
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def log_file_path
|
93
|
-
path = config_hash[:log_path] || root_path && File.join(root_path,
|
93
|
+
path = config_hash[:log_path] || root_path && File.join(root_path, "log")
|
94
94
|
if path && File.writable?(path)
|
95
|
-
return File.join(File.realpath(path),
|
95
|
+
return File.join(File.realpath(path), "appsignal.log")
|
96
96
|
end
|
97
97
|
|
98
98
|
if File.writable? SYSTEM_TMP_DIR
|
99
99
|
$stdout.puts "appsignal: Unable to log to '#{path}'. Logging to "\
|
100
100
|
"'#{SYSTEM_TMP_DIR}' instead. Please check the "\
|
101
101
|
"permissions for the application's (log) directory."
|
102
|
-
File.join(SYSTEM_TMP_DIR,
|
102
|
+
File.join(SYSTEM_TMP_DIR, "appsignal.log")
|
103
103
|
else
|
104
104
|
$stdout.puts "appsignal: Unable to log to '#{path}' or the "\
|
105
105
|
"'#{SYSTEM_TMP_DIR}' fallback. Please check the permissions "\
|
@@ -116,43 +116,44 @@ module Appsignal
|
|
116
116
|
end
|
117
117
|
|
118
118
|
def write_to_environment
|
119
|
-
ENV[
|
120
|
-
ENV[
|
121
|
-
ENV[
|
122
|
-
ENV[
|
123
|
-
ENV[
|
124
|
-
ENV[
|
125
|
-
ENV[
|
126
|
-
ENV[
|
127
|
-
ENV[
|
128
|
-
ENV[
|
129
|
-
ENV[
|
130
|
-
ENV[
|
131
|
-
ENV[
|
132
|
-
ENV[
|
133
|
-
ENV[
|
134
|
-
ENV[
|
135
|
-
ENV[
|
136
|
-
ENV[
|
137
|
-
ENV[
|
138
|
-
ENV[
|
139
|
-
ENV[
|
140
|
-
ENV[
|
119
|
+
ENV["APPSIGNAL_ACTIVE"] = active?.to_s
|
120
|
+
ENV["APPSIGNAL_APP_PATH"] = root_path.to_s
|
121
|
+
ENV["APPSIGNAL_AGENT_PATH"] = File.expand_path("../../../ext", __FILE__).to_s
|
122
|
+
ENV["APPSIGNAL_ENVIRONMENT"] = env
|
123
|
+
ENV["APPSIGNAL_AGENT_VERSION"] = Appsignal::Extension.agent_version
|
124
|
+
ENV["APPSIGNAL_LANGUAGE_INTEGRATION_VERSION"] = "ruby-#{Appsignal::VERSION}"
|
125
|
+
ENV["APPSIGNAL_DEBUG_LOGGING"] = config_hash[:debug].to_s
|
126
|
+
ENV["APPSIGNAL_LOG_FILE_PATH"] = log_file_path.to_s if log_file_path
|
127
|
+
ENV["APPSIGNAL_PUSH_API_ENDPOINT"] = config_hash[:endpoint]
|
128
|
+
ENV["APPSIGNAL_PUSH_API_KEY"] = config_hash[:push_api_key]
|
129
|
+
ENV["APPSIGNAL_APP_NAME"] = config_hash[:name]
|
130
|
+
ENV["APPSIGNAL_HTTP_PROXY"] = config_hash[:http_proxy]
|
131
|
+
ENV["APPSIGNAL_IGNORE_ACTIONS"] = config_hash[:ignore_actions].join(",")
|
132
|
+
ENV["APPSIGNAL_IGNORE_ERRORS"] = config_hash[:ignore_errors].join(",")
|
133
|
+
ENV["APPSIGNAL_FILTER_PARAMETERS"] = config_hash[:filter_parameters].join(",")
|
134
|
+
ENV["APPSIGNAL_SEND_PARAMS"] = config_hash[:send_params].to_s
|
135
|
+
ENV["APPSIGNAL_RUNNING_IN_CONTAINER"] = config_hash[:running_in_container].to_s
|
136
|
+
ENV["APPSIGNAL_WORKING_DIR_PATH"] = config_hash[:working_dir_path] if config_hash[:working_dir_path]
|
137
|
+
ENV["APPSIGNAL_ENABLE_HOST_METRICS"] = config_hash[:enable_host_metrics].to_s
|
138
|
+
ENV["APPSIGNAL_ENABLE_MINUTELY_PROBES"] = config_hash[:enable_minutely_probes].to_s
|
139
|
+
ENV["APPSIGNAL_HOSTNAME"] = config_hash[:hostname].to_s
|
140
|
+
ENV["APPSIGNAL_PROCESS_NAME"] = $0
|
141
|
+
ENV["APPSIGNAL_CA_FILE_PATH"] = config_hash[:ca_file_path].to_s
|
141
142
|
end
|
142
143
|
|
143
144
|
protected
|
144
145
|
|
145
146
|
def config_file
|
146
147
|
@config_file ||=
|
147
|
-
root_path.nil? ? nil : File.join(root_path,
|
148
|
+
root_path.nil? ? nil : File.join(root_path, "config", "appsignal.yml")
|
148
149
|
end
|
149
150
|
|
150
151
|
def detect_from_system
|
151
152
|
config_hash[:running_in_container] = true if Appsignal::System.container?
|
152
|
-
config_hash[:log] =
|
153
|
+
config_hash[:log] = "stdout" if Appsignal::System.heroku?
|
153
154
|
|
154
155
|
# Make active by default if APPSIGNAL_PUSH_API_KEY is present
|
155
|
-
config_hash[:active] = true if ENV[
|
156
|
+
config_hash[:active] = true if ENV["APPSIGNAL_PUSH_API_KEY"]
|
156
157
|
end
|
157
158
|
|
158
159
|
def load_from_disk
|
@@ -200,7 +201,7 @@ module Appsignal
|
|
200
201
|
APPSIGNAL_RUNNING_IN_CONTAINER APPSIGNAL_ENABLE_HOST_METRICS
|
201
202
|
APPSIGNAL_SEND_PARAMS APPSIGNAL_ENABLE_MINUTELY_PROBES).each do |var|
|
202
203
|
if env_var = ENV[var]
|
203
|
-
config[ENV_TO_KEY_MAPPING[var]] = env_var ==
|
204
|
+
config[ENV_TO_KEY_MAPPING[var]] = env_var == "true"
|
204
205
|
end
|
205
206
|
end
|
206
207
|
|
@@ -208,7 +209,7 @@ module Appsignal
|
|
208
209
|
%w(APPSIGNAL_IGNORE_ERRORS APPSIGNAL_IGNORE_ACTIONS
|
209
210
|
APPSIGNAL_FILTER_PARAMETERS).each do |var|
|
210
211
|
if env_var = ENV[var]
|
211
|
-
config[ENV_TO_KEY_MAPPING[var]] = env_var.split(
|
212
|
+
config[ENV_TO_KEY_MAPPING[var]] = env_var.split(",")
|
212
213
|
end
|
213
214
|
end
|
214
215
|
|
@@ -228,11 +229,12 @@ module Appsignal
|
|
228
229
|
# Strip path from endpoint so we're backwards compatible with
|
229
230
|
# earlier versions of the gem.
|
230
231
|
endpoint_uri = URI(config_hash[:endpoint])
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
232
|
+
config_hash[:endpoint] =
|
233
|
+
if endpoint_uri.port == 443
|
234
|
+
"#{endpoint_uri.scheme}://#{endpoint_uri.host}"
|
235
|
+
else
|
236
|
+
"#{endpoint_uri.scheme}://#{endpoint_uri.host}:#{endpoint_uri.port}"
|
237
|
+
end
|
236
238
|
|
237
239
|
if config_hash[:push_api_key]
|
238
240
|
@valid = true
|