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
data/gemfiles/rails-4.2.gemfile
CHANGED
data/gemfiles/resque.gemfile
CHANGED
data/lib/appsignal.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "json"
|
2
|
+
require "logger"
|
3
|
+
require "securerandom"
|
4
4
|
|
5
5
|
module Appsignal
|
6
6
|
class << self
|
7
|
+
extend Gem::Deprecate
|
8
|
+
|
7
9
|
attr_accessor :config, :agent, :extension_loaded
|
8
10
|
attr_writer :logger, :in_memory_log
|
9
11
|
|
@@ -12,7 +14,7 @@ module Appsignal
|
|
12
14
|
end
|
13
15
|
|
14
16
|
def initialize_extensions
|
15
|
-
Appsignal.logger.debug(
|
17
|
+
Appsignal.logger.debug("Initializing extensions")
|
16
18
|
extensions.each do |extension|
|
17
19
|
Appsignal.logger.debug("Initializing #{extension}")
|
18
20
|
extension.initializer
|
@@ -21,25 +23,26 @@ module Appsignal
|
|
21
23
|
|
22
24
|
def start
|
23
25
|
unless extension_loaded?
|
24
|
-
logger.info(
|
26
|
+
logger.info("Not starting appsignal, extension is not loaded")
|
25
27
|
return
|
26
28
|
else
|
27
|
-
logger.debug(
|
29
|
+
logger.debug("Starting appsignal")
|
28
30
|
end
|
29
31
|
|
30
32
|
unless @config
|
31
33
|
@config = Config.new(
|
32
34
|
Dir.pwd,
|
33
|
-
ENV[
|
35
|
+
ENV["APPSIGNAL_APP_ENV"] || ENV["RAILS_ENV"] || ENV["RACK_ENV"]
|
34
36
|
)
|
35
37
|
end
|
36
38
|
|
37
39
|
if config.valid?
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
logger.level =
|
41
|
+
if config[:debug]
|
42
|
+
Logger::DEBUG
|
43
|
+
else
|
44
|
+
Logger::INFO
|
45
|
+
end
|
43
46
|
if config.active?
|
44
47
|
logger.info("Starting AppSignal #{Appsignal::VERSION} (#{$0}, Ruby #{RUBY_VERSION}, #{RUBY_PLATFORM})")
|
45
48
|
config.write_to_environment
|
@@ -62,7 +65,7 @@ module Appsignal
|
|
62
65
|
logger.info("Not starting, not active for #{config.env}")
|
63
66
|
end
|
64
67
|
else
|
65
|
-
logger.error(
|
68
|
+
logger.error("Not starting, no valid config for this environment")
|
66
69
|
end
|
67
70
|
end
|
68
71
|
|
@@ -74,11 +77,11 @@ module Appsignal
|
|
74
77
|
end
|
75
78
|
end
|
76
79
|
|
77
|
-
def stop(called_by=nil)
|
80
|
+
def stop(called_by = nil)
|
78
81
|
if called_by
|
79
82
|
logger.debug("Stopping appsignal (#{called_by})")
|
80
83
|
else
|
81
|
-
logger.debug(
|
84
|
+
logger.debug("Stopping appsignal")
|
82
85
|
end
|
83
86
|
Appsignal::Extension.stop
|
84
87
|
end
|
@@ -86,24 +89,24 @@ module Appsignal
|
|
86
89
|
def forked
|
87
90
|
return unless active?
|
88
91
|
Appsignal.start_logger
|
89
|
-
logger.debug(
|
92
|
+
logger.debug("Forked process, resubscribing and restarting extension")
|
90
93
|
Appsignal::Extension.start
|
91
94
|
end
|
92
95
|
|
93
96
|
def get_server_state(key)
|
94
|
-
Appsignal::Extension
|
97
|
+
Appsignal::Extension.get_server_state(key)
|
95
98
|
end
|
96
99
|
|
97
100
|
# Wrap a transaction with appsignal monitoring.
|
98
|
-
def monitor_transaction(name, env={})
|
101
|
+
def monitor_transaction(name, env = {})
|
99
102
|
unless active?
|
100
103
|
return yield
|
101
104
|
end
|
102
105
|
|
103
|
-
if name.start_with?(
|
106
|
+
if name.start_with?("perform_job".freeze)
|
104
107
|
namespace = Appsignal::Transaction::BACKGROUND_JOB
|
105
108
|
request = Appsignal::Transaction::GenericRequest.new(env)
|
106
|
-
elsif name.start_with?(
|
109
|
+
elsif name.start_with?("process_action".freeze)
|
107
110
|
namespace = Appsignal::Transaction::HTTP_REQUEST
|
108
111
|
request = ::Rack::Request.new(env)
|
109
112
|
else
|
@@ -133,13 +136,13 @@ module Appsignal
|
|
133
136
|
#
|
134
137
|
# Useful for cases such as Rake tasks and Resque-like systems where a process is
|
135
138
|
# forked and immediately exits after the transaction finishes.
|
136
|
-
def monitor_single_transaction(name, env={}, &block)
|
139
|
+
def monitor_single_transaction(name, env = {}, &block)
|
137
140
|
monitor_transaction(name, env, &block)
|
138
141
|
ensure
|
139
|
-
stop(
|
142
|
+
stop("monitor_single_transaction")
|
140
143
|
end
|
141
144
|
|
142
|
-
def listen_for_error
|
145
|
+
def listen_for_error
|
143
146
|
yield
|
144
147
|
rescue => error
|
145
148
|
send_error(error)
|
@@ -147,8 +150,8 @@ module Appsignal
|
|
147
150
|
end
|
148
151
|
alias :listen_for_exception :listen_for_error
|
149
152
|
|
150
|
-
def send_error(error, tags=nil, namespace=Appsignal::Transaction::HTTP_REQUEST)
|
151
|
-
return
|
153
|
+
def send_error(error, tags = nil, namespace = Appsignal::Transaction::HTTP_REQUEST)
|
154
|
+
return unless active?
|
152
155
|
unless error.is_a?(Exception)
|
153
156
|
logger.error('Can\'t send error, given value is not an exception')
|
154
157
|
return
|
@@ -166,15 +169,14 @@ module Appsignal
|
|
166
169
|
|
167
170
|
def set_error(exception)
|
168
171
|
return if !active? ||
|
169
|
-
|
170
|
-
|
171
|
-
is_ignored_error?(exception)
|
172
|
+
Appsignal::Transaction.current.nil? ||
|
173
|
+
exception.nil?
|
172
174
|
Appsignal::Transaction.current.set_error(exception)
|
173
175
|
end
|
174
176
|
alias :set_exception :set_error
|
175
177
|
alias :add_exception :set_error
|
176
178
|
|
177
|
-
def tag_request(params={})
|
179
|
+
def tag_request(params = {})
|
178
180
|
return unless active?
|
179
181
|
transaction = Appsignal::Transaction.current
|
180
182
|
return false unless transaction
|
@@ -182,14 +184,14 @@ module Appsignal
|
|
182
184
|
end
|
183
185
|
alias :tag_job :tag_request
|
184
186
|
|
185
|
-
def instrument(name, title=nil, body=nil, body_format=Appsignal::EventFormatter::DEFAULT)
|
187
|
+
def instrument(name, title = nil, body = nil, body_format = Appsignal::EventFormatter::DEFAULT)
|
186
188
|
Appsignal::Transaction.current.start_event
|
187
189
|
return_value = yield
|
188
190
|
Appsignal::Transaction.current.finish_event(name, title, body, body_format)
|
189
191
|
return_value
|
190
192
|
end
|
191
193
|
|
192
|
-
def instrument_sql(name, title=nil, body=nil, &block)
|
194
|
+
def instrument_sql(name, title = nil, body = nil, &block)
|
193
195
|
instrument(name, title, body, Appsignal::EventFormatter::SQL_BODY_FORMAT, &block)
|
194
196
|
end
|
195
197
|
|
@@ -211,7 +213,7 @@ module Appsignal
|
|
211
213
|
Appsignal.logger.warn("Process gauge value #{value} for key '#{key}' is too big")
|
212
214
|
end
|
213
215
|
|
214
|
-
def increment_counter(key, value=1)
|
216
|
+
def increment_counter(key, value = 1)
|
215
217
|
Appsignal::Extension.increment_counter(key.to_s, value)
|
216
218
|
rescue RangeError
|
217
219
|
Appsignal.logger.warn("Counter value #{value} for key '#{key}' is too big")
|
@@ -232,8 +234,8 @@ module Appsignal
|
|
232
234
|
|
233
235
|
def log_formatter(prefix = nil)
|
234
236
|
pre = "#{prefix}: " if prefix
|
235
|
-
proc do |severity, datetime,
|
236
|
-
"[#{datetime.strftime(
|
237
|
+
proc do |severity, datetime, _progname, msg|
|
238
|
+
"[#{datetime.strftime("%Y-%m-%dT%H:%M:%S")} (process) ##{Process.pid}][#{severity}] #{pre}#{msg}\n"
|
237
239
|
end
|
238
240
|
end
|
239
241
|
|
@@ -256,7 +258,7 @@ module Appsignal
|
|
256
258
|
end
|
257
259
|
|
258
260
|
if path_arg
|
259
|
-
logger.info(
|
261
|
+
logger.info("Setting the path in start_logger has no effect anymore, set it in the config instead")
|
260
262
|
end
|
261
263
|
end
|
262
264
|
|
@@ -272,10 +274,12 @@ module Appsignal
|
|
272
274
|
Appsignal.config[:ignore_errors].include?(error.class.name)
|
273
275
|
end
|
274
276
|
alias :is_ignored_exception? :is_ignored_error?
|
277
|
+
deprecate :is_ignored_error?, :none, 2017, 3
|
275
278
|
|
276
279
|
def is_ignored_action?(action)
|
277
280
|
Appsignal.config[:ignore_actions].include?(action)
|
278
281
|
end
|
282
|
+
deprecate :is_ignored_action?, :none, 2017, 3
|
279
283
|
|
280
284
|
# Convenience method for skipping instrumentations around a block of code.
|
281
285
|
#
|
@@ -305,22 +309,22 @@ module Appsignal
|
|
305
309
|
end
|
306
310
|
end
|
307
311
|
|
308
|
-
require
|
309
|
-
require
|
310
|
-
require
|
311
|
-
require
|
312
|
-
require
|
313
|
-
require
|
314
|
-
require
|
315
|
-
require
|
316
|
-
require
|
317
|
-
require
|
318
|
-
require
|
319
|
-
require
|
320
|
-
require
|
321
|
-
require
|
322
|
-
require
|
323
|
-
require
|
324
|
-
require
|
325
|
-
require
|
326
|
-
require
|
312
|
+
require "appsignal/utils"
|
313
|
+
require "appsignal/extension"
|
314
|
+
require "appsignal/auth_check"
|
315
|
+
require "appsignal/config"
|
316
|
+
require "appsignal/event_formatter"
|
317
|
+
require "appsignal/hooks"
|
318
|
+
require "appsignal/marker"
|
319
|
+
require "appsignal/minutely"
|
320
|
+
require "appsignal/garbage_collection_profiler"
|
321
|
+
require "appsignal/integrations/railtie" if defined?(::Rails)
|
322
|
+
require "appsignal/integrations/resque"
|
323
|
+
require "appsignal/integrations/resque_active_job"
|
324
|
+
require "appsignal/transaction"
|
325
|
+
require "appsignal/version"
|
326
|
+
require "appsignal/rack/generic_instrumentation"
|
327
|
+
require "appsignal/rack/js_exception_catcher"
|
328
|
+
require "appsignal/js_exception_transaction"
|
329
|
+
require "appsignal/transmitter"
|
330
|
+
require "appsignal/system"
|
data/lib/appsignal/auth_check.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
module Appsignal
|
2
2
|
class AuthCheck
|
3
|
-
ACTION =
|
3
|
+
ACTION = "auth".freeze
|
4
4
|
|
5
5
|
attr_reader :config, :logger
|
6
6
|
|
7
|
-
def initialize(config, logger=Appsignal.logger)
|
7
|
+
def initialize(config, logger = Appsignal.logger)
|
8
8
|
@config = config
|
9
9
|
@logger = logger
|
10
10
|
end
|
@@ -14,23 +14,22 @@ module Appsignal
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def perform_with_result
|
17
|
-
|
18
|
-
|
17
|
+
status = perform
|
18
|
+
result =
|
19
19
|
case status
|
20
|
-
when
|
21
|
-
|
22
|
-
when
|
23
|
-
|
20
|
+
when "200"
|
21
|
+
"AppSignal has confirmed authorization!"
|
22
|
+
when "401"
|
23
|
+
"API key not valid with AppSignal..."
|
24
24
|
else
|
25
|
-
|
26
|
-
|
25
|
+
"Could not confirm authorization: " \
|
26
|
+
"#{status.nil? ? "nil" : status}"
|
27
27
|
end
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
28
|
+
[status, result]
|
29
|
+
rescue => e
|
30
|
+
result = "Something went wrong while trying to "\
|
31
|
+
"authenticate with AppSignal: #{e}"
|
32
|
+
[nil, result]
|
34
33
|
end
|
35
34
|
end
|
36
35
|
end
|
data/lib/appsignal/capistrano.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "appsignal"
|
2
|
+
require "capistrano/version"
|
3
3
|
|
4
4
|
if defined?(Capistrano::VERSION) && Gem::Version.new(Capistrano::VERSION) >= Gem::Version.new(3)
|
5
5
|
# Capistrano 3+
|
6
|
-
load File.expand_path(
|
6
|
+
load File.expand_path("../integrations/capistrano/appsignal.cap", __FILE__)
|
7
7
|
else
|
8
8
|
# Capistrano 2
|
9
|
-
require
|
9
|
+
require "appsignal/integrations/capistrano/capistrano_2_tasks"
|
10
10
|
end
|
data/lib/appsignal/cli.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
1
|
+
require "optparse"
|
2
|
+
require "logger"
|
3
|
+
require "yaml"
|
4
|
+
require "appsignal"
|
5
|
+
require "appsignal/cli/helpers"
|
6
|
+
require "appsignal/cli/demo"
|
7
|
+
require "appsignal/cli/diagnose"
|
8
|
+
require "appsignal/cli/install"
|
9
|
+
require "appsignal/cli/notify_of_deploy"
|
10
10
|
|
11
11
|
module Appsignal
|
12
12
|
class CLI
|
@@ -15,7 +15,7 @@ module Appsignal
|
|
15
15
|
class << self
|
16
16
|
attr_accessor :options
|
17
17
|
|
18
|
-
def run(argv=ARGV)
|
18
|
+
def run(argv = ARGV)
|
19
19
|
@options = {}
|
20
20
|
global = global_option_parser
|
21
21
|
commands = command_option_parser
|
@@ -48,56 +48,56 @@ module Appsignal
|
|
48
48
|
|
49
49
|
def global_option_parser
|
50
50
|
OptionParser.new do |o|
|
51
|
-
o.banner =
|
51
|
+
o.banner = "Usage: appsignal <command> [options]"
|
52
52
|
|
53
|
-
o.on
|
53
|
+
o.on "-v", "--version", "Print version and exit" do |_arg|
|
54
54
|
puts "AppSignal #{Appsignal::VERSION}"
|
55
55
|
exit(0)
|
56
56
|
end
|
57
57
|
|
58
|
-
o.on
|
58
|
+
o.on "-h", "--help", "Show help and exit" do
|
59
59
|
puts o
|
60
60
|
exit(0)
|
61
61
|
end
|
62
62
|
|
63
|
-
o.separator
|
64
|
-
o.separator "Available commands: #{AVAILABLE_COMMANDS.join(
|
63
|
+
o.separator ""
|
64
|
+
o.separator "Available commands: #{AVAILABLE_COMMANDS.join(", ")}"
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
68
|
def command_option_parser
|
69
69
|
{
|
70
|
-
|
71
|
-
o.banner =
|
70
|
+
"demo" => OptionParser.new do |o|
|
71
|
+
o.banner = "Usage: appsignal demo [options]"
|
72
72
|
|
73
|
-
o.on
|
73
|
+
o.on "--environment=<app_env>", "The environment to demo" do |arg|
|
74
74
|
options[:environment] = arg
|
75
75
|
end
|
76
76
|
end,
|
77
|
-
|
78
|
-
o.banner =
|
77
|
+
"diagnose" => OptionParser.new do |o|
|
78
|
+
o.banner = "Usage: appsignal diagnose [options]"
|
79
79
|
|
80
|
-
o.on
|
80
|
+
o.on "--environment=<app_env>", "The environment to diagnose" do |arg|
|
81
81
|
options[:environment] = arg
|
82
82
|
end
|
83
83
|
end,
|
84
|
-
|
85
|
-
|
86
|
-
o.banner =
|
84
|
+
"install" => OptionParser.new,
|
85
|
+
"notify_of_deploy" => OptionParser.new do |o|
|
86
|
+
o.banner = "Usage: appsignal notify_of_deploy [options]"
|
87
87
|
|
88
|
-
o.on
|
88
|
+
o.on "--revision=<revision>", "The revision you're deploying" do |arg|
|
89
89
|
options[:revision] = arg
|
90
90
|
end
|
91
91
|
|
92
|
-
o.on
|
92
|
+
o.on "--user=<user>", "The name of the user that's deploying" do |arg|
|
93
93
|
options[:user] = arg
|
94
94
|
end
|
95
95
|
|
96
|
-
o.on
|
96
|
+
o.on "--environment=<app_env>", "The environment you're deploying to" do |arg|
|
97
97
|
options[:environment] = arg
|
98
98
|
end
|
99
99
|
|
100
|
-
o.on
|
100
|
+
o.on "--name=<name>", "The name of the app (optional)" do |arg|
|
101
101
|
options[:name] = arg
|
102
102
|
end
|
103
103
|
end
|
@@ -42,7 +42,7 @@ module Appsignal
|
|
42
42
|
initial_config[:log_path] = Rails.root.join("log")
|
43
43
|
end
|
44
44
|
|
45
|
-
ENV[
|
45
|
+
ENV["APPSIGNAL_DIAGNOSE"] = "true"
|
46
46
|
Appsignal.config = Appsignal::Config.new(
|
47
47
|
current_path,
|
48
48
|
options[:environment],
|
@@ -79,9 +79,9 @@ module Appsignal
|
|
79
79
|
puts " Heroku: true" if Appsignal::System.heroku?
|
80
80
|
print " root user: "
|
81
81
|
puts Process.uid == 0 ? "yes (not recommended)" : "no"
|
82
|
-
|
83
|
-
|
84
|
-
|
82
|
+
|
83
|
+
return unless Appsignal::System.container?
|
84
|
+
puts " Container id: #{Appsignal::System::Container.id}"
|
85
85
|
end
|
86
86
|
|
87
87
|
def config
|
@@ -96,12 +96,12 @@ module Appsignal
|
|
96
96
|
def environment
|
97
97
|
env = Appsignal.config.env
|
98
98
|
puts " Environment: #{env}"
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
99
|
+
|
100
|
+
return unless env == ""
|
101
|
+
puts " Warning: No environment set, no config loaded!"
|
102
|
+
puts " Please make sure appsignal diagnose is run within your "
|
103
|
+
puts " project directory with an environment."
|
104
|
+
puts " appsignal diagnose --environment=production"
|
105
105
|
end
|
106
106
|
|
107
107
|
def paths_writable
|
@@ -154,7 +154,7 @@ module Appsignal
|
|
154
154
|
:current_path => Dir.pwd,
|
155
155
|
:root_path => config.root_path,
|
156
156
|
:log_dir_path => log_file_path ? File.dirname(log_file_path) : "",
|
157
|
-
:log_file_path => log_file_path
|
157
|
+
:log_file_path => log_file_path
|
158
158
|
}
|
159
159
|
end
|
160
160
|
|