appsignal 2.9.18.beta.1 → 2.10.6.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +0 -6
  3. data/.semaphore/semaphore.yml +964 -0
  4. data/CHANGELOG.md +48 -1
  5. data/README.md +1 -1
  6. data/Rakefile +82 -23
  7. data/appsignal.gemspec +5 -2
  8. data/build_matrix.yml +100 -52
  9. data/ext/agent.yml +19 -19
  10. data/gemfiles/capistrano2.gemfile +0 -5
  11. data/gemfiles/capistrano3.gemfile +0 -5
  12. data/gemfiles/grape.gemfile +0 -5
  13. data/gemfiles/no_dependencies.gemfile +0 -5
  14. data/gemfiles/padrino.gemfile +0 -6
  15. data/gemfiles/que.gemfile +0 -5
  16. data/gemfiles/que_beta.gemfile +0 -5
  17. data/gemfiles/rails-3.2.gemfile +0 -5
  18. data/gemfiles/rails-4.0.gemfile +0 -5
  19. data/gemfiles/rails-4.1.gemfile +0 -5
  20. data/gemfiles/rails-4.2.gemfile +0 -5
  21. data/gemfiles/resque.gemfile +0 -6
  22. data/lib/appsignal.rb +10 -7
  23. data/lib/appsignal/cli.rb +9 -2
  24. data/lib/appsignal/cli/diagnose.rb +21 -20
  25. data/lib/appsignal/cli/helpers.rb +22 -10
  26. data/lib/appsignal/cli/install.rb +2 -1
  27. data/lib/appsignal/cli/notify_of_deploy.rb +1 -1
  28. data/lib/appsignal/config.rb +23 -9
  29. data/lib/appsignal/event_formatter.rb +5 -6
  30. data/lib/appsignal/hooks/net_http.rb +13 -8
  31. data/lib/appsignal/integrations/grape.rb +2 -1
  32. data/lib/appsignal/integrations/net_http.rb +16 -0
  33. data/lib/appsignal/logger.rb +22 -0
  34. data/lib/appsignal/minutely.rb +5 -6
  35. data/lib/appsignal/rack/js_exception_catcher.rb +5 -0
  36. data/lib/appsignal/system.rb +6 -0
  37. data/lib/appsignal/transaction.rb +8 -3
  38. data/lib/appsignal/transmitter.rb +0 -1
  39. data/lib/appsignal/utils/deprecation_message.rb +2 -2
  40. data/lib/appsignal/version.rb +1 -1
  41. data/resources/cacert.pem +1404 -1804
  42. data/spec/lib/appsignal/auth_check_spec.rb +1 -1
  43. data/spec/lib/appsignal/cli/diagnose_spec.rb +54 -11
  44. data/spec/lib/appsignal/cli/helpers_spec.rb +11 -3
  45. data/spec/lib/appsignal/cli/install_spec.rb +30 -1
  46. data/spec/lib/appsignal/cli/notify_of_deploy_spec.rb +4 -2
  47. data/spec/lib/appsignal/config_spec.rb +85 -14
  48. data/spec/lib/appsignal/event_formatter_spec.rb +5 -4
  49. data/spec/lib/appsignal/hooks/action_cable_spec.rb +1 -5
  50. data/spec/lib/appsignal/hooks/rake_spec.rb +41 -39
  51. data/spec/lib/appsignal/hooks/sidekiq_spec.rb +2 -15
  52. data/spec/lib/appsignal/integrations/grape_spec.rb +10 -0
  53. data/spec/lib/appsignal/integrations/object_spec.rb +2 -2
  54. data/spec/lib/appsignal/integrations/que_spec.rb +26 -39
  55. data/spec/lib/appsignal/integrations/resque_active_job_spec.rb +108 -46
  56. data/spec/lib/appsignal/integrations/resque_spec.rb +40 -39
  57. data/spec/lib/appsignal/logger_spec.rb +25 -0
  58. data/spec/lib/appsignal/minutely_spec.rb +7 -7
  59. data/spec/lib/appsignal/rack/js_exception_catcher_spec.rb +23 -5
  60. data/spec/lib/appsignal/system_spec.rb +36 -0
  61. data/spec/lib/appsignal/transaction_spec.rb +37 -26
  62. data/spec/lib/appsignal/transmitter_spec.rb +3 -1
  63. data/spec/lib/appsignal_spec.rb +13 -10
  64. data/spec/spec_helper.rb +26 -12
  65. data/spec/support/fixtures/projects/broken/config/appsignal.yml +1 -0
  66. data/spec/support/helpers/cli_helpers.rb +15 -1
  67. data/spec/support/helpers/log_helpers.rb +13 -6
  68. data/spec/support/helpers/transaction_helpers.rb +53 -0
  69. data/spec/support/helpers/wait_for_helper.rb +2 -2
  70. data/spec/support/matchers/be_completed.rb +5 -0
  71. data/spec/support/matchers/have_colorized_text.rb +28 -0
  72. data/spec/support/testing.rb +113 -0
  73. data/support/check_versions +22 -0
  74. data/support/install_deps +9 -4
  75. metadata +32 -19
  76. data/.travis.yml +0 -149
@@ -3,10 +3,5 @@ source 'https://rubygems.org'
3
3
  gem 'capistrano', '< 3.0'
4
4
  gem 'net-ssh', '2.9.2'
5
5
  gem 'rack', '~> 1.6'
6
- if Gem::Version.new(RUBY_VERSION) <= Gem::Version.new("2.1.0")
7
- gem 'public_suffix', "~> 2.0.0"
8
- else
9
- gem 'public_suffix'
10
- end
11
6
 
12
7
  gemspec :path => '../'
@@ -4,10 +4,5 @@ gem 'capistrano', '~> 3.0'
4
4
  gem 'i18n', '~> 1.2.0'
5
5
  gem 'net-ssh', '2.9.2'
6
6
  gem 'rack', '~> 1.6'
7
- if Gem::Version.new(RUBY_VERSION) <= Gem::Version.new("2.1.0")
8
- gem 'public_suffix', "~> 2.0.0"
9
- else
10
- gem 'public_suffix'
11
- end
12
7
 
13
8
  gemspec :path => '../'
@@ -3,10 +3,5 @@ source 'https://rubygems.org'
3
3
  gem 'grape', '0.14.0'
4
4
  gem 'rack', '~> 1.6'
5
5
  gem 'activesupport', '~> 4.2'
6
- if Gem::Version.new(RUBY_VERSION) <= Gem::Version.new("2.1.0")
7
- gem 'public_suffix', "~> 2.0.0"
8
- else
9
- gem 'public_suffix'
10
- end
11
6
 
12
7
  gemspec :path => '../'
@@ -1,10 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'rack', '~> 1.6'
4
- if Gem::Version.new(RUBY_VERSION) <= Gem::Version.new("2.1.0")
5
- gem 'public_suffix', "~> 2.0.0"
6
- else
7
- gem 'public_suffix'
8
- end
9
4
 
10
5
  gemspec :path => '../'
@@ -2,11 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'padrino', '~> 0.13.0'
4
4
  gem 'rack', '~> 1.6'
5
- gem 'activesupport', '~> 4.2'
6
- if Gem::Version.new(RUBY_VERSION) <= Gem::Version.new("2.1.0")
7
- gem 'public_suffix', "~> 2.0.0"
8
- else
9
- gem 'public_suffix'
10
- end
11
5
 
12
6
  gemspec :path => '../'
@@ -1,10 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'que'
4
- if Gem::Version.new(RUBY_VERSION) <= Gem::Version.new("2.1.0")
5
- gem 'public_suffix', "~> 2.0.0"
6
- else
7
- gem 'public_suffix'
8
- end
9
4
 
10
5
  gemspec :path => '../'
@@ -1,10 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'que', '1.0.0.beta3'
4
- if Gem::Version.new(RUBY_VERSION) <= Gem::Version.new("2.1.0")
5
- gem 'public_suffix', "~> 2.0.0"
6
- else
7
- gem 'public_suffix'
8
- end
9
4
 
10
5
  gemspec :path => '../'
@@ -2,10 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rails', '~> 3.2.14'
4
4
  gem 'test-unit'
5
- if Gem::Version.new(RUBY_VERSION) <= Gem::Version.new("2.1.0")
6
- gem 'public_suffix', "~> 2.0.0"
7
- else
8
- gem 'public_suffix'
9
- end
10
5
 
11
6
  gemspec :path => '../'
@@ -2,10 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rails', '~> 4.0.0'
4
4
  gem 'mime-types', '~> 2.6'
5
- if Gem::Version.new(RUBY_VERSION) <= Gem::Version.new("2.1.0")
6
- gem 'public_suffix', "~> 2.0.0"
7
- else
8
- gem 'public_suffix'
9
- end
10
5
 
11
6
  gemspec :path => '../'
@@ -2,10 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rails', '~> 4.1.0'
4
4
  gem 'mime-types', '~> 2.6'
5
- if Gem::Version.new(RUBY_VERSION) <= Gem::Version.new("2.1.0")
6
- gem 'public_suffix', "~> 2.0.0"
7
- else
8
- gem 'public_suffix'
9
- end
10
5
 
11
6
  gemspec :path => '../'
@@ -8,8 +8,3 @@ gemspec :path => '../'
8
8
  if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.1.0")
9
9
  gem 'nokogiri', '~> 1.6.0'
10
10
  end
11
- if Gem::Version.new(RUBY_VERSION) <= Gem::Version.new("2.1.0")
12
- gem 'public_suffix', "~> 2.0.0"
13
- else
14
- gem 'public_suffix'
15
- end
@@ -1,7 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'resque'
4
- gem 'rails', '~> 4.2.0'
5
4
  gem 'sinatra'
6
5
  gem 'mime-types', '~> 2.6'
7
6
 
@@ -10,8 +9,3 @@ gemspec :path => '../'
10
9
  if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.1.0")
11
10
  gem 'nokogiri', '~> 1.6.0'
12
11
  end
13
- if Gem::Version.new(RUBY_VERSION) <= Gem::Version.new("2.1.0")
14
- gem 'public_suffix', "~> 2.0.0"
15
- else
16
- gem 'public_suffix'
17
- end
@@ -1,11 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "json"
4
- require "logger"
5
4
  require "securerandom"
6
5
 
6
+ require "appsignal/logger"
7
7
  require "appsignal/helpers/instrumentation"
8
8
  require "appsignal/helpers/metrics"
9
+ require "appsignal/utils/deprecation_message"
9
10
 
10
11
  # AppSignal for Ruby gem's main module.
11
12
  #
@@ -15,9 +16,9 @@ require "appsignal/helpers/metrics"
15
16
  # {Appsignal::Helpers::Metrics}) for ease of use.
16
17
  module Appsignal
17
18
  class << self
18
- extend Gem::Deprecate
19
19
  include Helpers::Instrumentation
20
20
  include Helpers::Metrics
21
+ include Utils::DeprecationMessage
21
22
 
22
23
  # Accessor for the AppSignal configuration.
23
24
  # Return the current AppSignal configuration.
@@ -195,7 +196,7 @@ module Appsignal
195
196
  end
196
197
 
197
198
  def logger
198
- @logger ||= Logger.new(in_memory_log).tap do |l|
199
+ @logger ||= Appsignal::Logger.new(in_memory_log).tap do |l|
199
200
  l.level = Logger::INFO
200
201
  l.formatter = log_formatter("appsignal")
201
202
  end
@@ -280,26 +281,28 @@ module Appsignal
280
281
 
281
282
  # @deprecated No replacement
282
283
  def is_ignored_error?(error) # rubocop:disable Naming/PredicateName
284
+ deprecation_message "Appsignal.is_ignored_error? is deprecated " \
285
+ "with no replacement and will be removed in version 3.0."
283
286
  Appsignal.config[:ignore_errors].include?(error.class.name)
284
287
  end
285
288
  alias :is_ignored_exception? :is_ignored_error?
286
- deprecate :is_ignored_error?, :none, 2017, 3
287
289
 
288
290
  # @deprecated No replacement
289
291
  def is_ignored_action?(action) # rubocop:disable Naming/PredicateName
292
+ deprecation_message "Appsignal.is_ignored_action? is deprecated " \
293
+ "with no replacement and will be removed in version 3.0."
290
294
  Appsignal.config[:ignore_actions].include?(action)
291
295
  end
292
- deprecate :is_ignored_action?, :none, 2017, 3
293
296
 
294
297
  private
295
298
 
296
299
  def start_stdout_logger
297
- @logger = Logger.new($stdout)
300
+ @logger = Appsignal::Logger.new($stdout)
298
301
  logger.formatter = log_formatter("appsignal")
299
302
  end
300
303
 
301
304
  def start_file_logger(path)
302
- @logger = Logger.new(path)
305
+ @logger = Appsignal::Logger.new(path)
303
306
  logger.formatter = log_formatter
304
307
  rescue SystemCallError => error
305
308
  start_stdout_logger
@@ -32,7 +32,7 @@ module Appsignal
32
32
  when :diagnose
33
33
  Appsignal::CLI::Diagnose.run(options)
34
34
  when :install
35
- Appsignal::CLI::Install.run(argv.shift)
35
+ Appsignal::CLI::Install.run(argv.shift, options)
36
36
  when :notify_of_deploy
37
37
  Appsignal::CLI::NotifyOfDeploy.run(options)
38
38
  end
@@ -85,8 +85,15 @@ module Appsignal
85
85
  o.on "--[no-]send-report", "Confirm sending the report to AppSignal automatically" do |arg|
86
86
  options[:send_report] = arg
87
87
  end
88
+ o.on "--[no-]color", "Colorize the output of the diagnose command" do |arg|
89
+ options[:color] = arg
90
+ end
91
+ end,
92
+ "install" => OptionParser.new do |o|
93
+ o.on "--[no-]color", "Colorize the output of the diagnose command" do |arg|
94
+ options[:color] = arg
95
+ end
88
96
  end,
89
- "install" => OptionParser.new,
90
97
  "notify_of_deploy" => OptionParser.new do |o|
91
98
  o.banner = "Usage: appsignal notify_of_deploy [options]"
92
99
 
@@ -77,6 +77,7 @@ module Appsignal
77
77
  # @return [void]
78
78
  # @api private
79
79
  def run(options = {})
80
+ self.coloring = options.delete(:color) { true }
80
81
  $stdout.sync = true
81
82
  header
82
83
  print_empty_line
@@ -200,7 +201,7 @@ module Appsignal
200
201
  def run_agent_diagnose_mode
201
202
  puts "Agent diagnostics"
202
203
  unless Appsignal.extension_loaded?
203
- puts " Extension is not loaded. No agent report created."
204
+ puts colorize(" Extension is not loaded. No agent report created.", :red)
204
205
  return
205
206
  end
206
207
 
@@ -336,7 +337,7 @@ module Appsignal
336
337
  path = File.expand_path("../../../../ext/install.report", __FILE__)
337
338
  raw_report = File.read(path)
338
339
  Utils.parse_yaml(raw_report)
339
- rescue => e
340
+ rescue StandardError, Psych::SyntaxError => e # rubocop:disable Lint/ShadowedException
340
341
  {
341
342
  "parsing_error" => {
342
343
  "error" => "#{e.class}: #{e}",
@@ -461,10 +462,11 @@ module Appsignal
461
462
  print " Environment: #{format_config_option(env)}"
462
463
 
463
464
  if env == ""
464
- puts "\n Warning: No environment set, no config loaded!"
465
- puts " Please make sure appsignal diagnose is run within your "
466
- puts " project directory with an environment."
467
- puts " appsignal diagnose --environment=production"
465
+ message = " Warning: No environment set, no config loaded!\n" \
466
+ " Please make sure appsignal diagnose is run within your\n" \
467
+ " project directory with an environment.\n" \
468
+ " appsignal diagnose --environment=production"
469
+ puts "\n#{colorize(message, :red)}"
468
470
  else
469
471
  puts sources_label
470
472
  end
@@ -531,20 +533,19 @@ module Appsignal
531
533
 
532
534
  def check_api_key
533
535
  puts "Validation"
534
- data_section :validation do
535
- auth_check = ::Appsignal::AuthCheck.new(Appsignal.config)
536
- status, error = auth_check.perform_with_result
537
- result =
538
- case status
539
- when "200"
540
- "valid"
541
- when "401"
542
- "invalid"
543
- else
544
- "Failed with status #{status}\n#{error.inspect}"
545
- end
546
- puts_and_save :push_api_key, "Validating Push API key", result
547
- end
536
+ auth_check = ::Appsignal::AuthCheck.new(Appsignal.config)
537
+ status, error = auth_check.perform_with_result
538
+ result, color =
539
+ case status
540
+ when "200"
541
+ ["valid", :green]
542
+ when "401"
543
+ ["invalid", :red]
544
+ else
545
+ ["Failed with status #{status}\n#{error.inspect}", :red]
546
+ end
547
+ data[:validation][:push_api_key] = result
548
+ puts_value "Validating Push API key", colorize(result, color)
548
549
  end
549
550
 
550
551
  def print_paths_section(report)
@@ -7,24 +7,36 @@ module Appsignal
7
7
  module Helpers
8
8
  private
9
9
 
10
+ COLOR_CODES = {
11
+ :red => 31,
12
+ :green => 32,
13
+ :yellow => 33,
14
+ :blue => 34,
15
+ :pink => 35,
16
+ :default => 0
17
+ }.freeze
18
+
10
19
  def ruby_2_6_or_up?
11
20
  Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.6.0")
12
21
  end
13
22
 
23
+ def coloring=(value)
24
+ @coloring = value
25
+ end
26
+
27
+ def coloring?
28
+ return true unless defined?(@coloring)
29
+ @coloring
30
+ end
31
+
14
32
  def colorize(text, color)
33
+ return text unless coloring?
15
34
  return text if Gem.win_platform?
16
35
 
17
- color_code =
18
- case color
19
- when :red then 31
20
- when :green then 32
21
- when :yellow then 33
22
- when :blue then 34
23
- when :pink then 35
24
- else 0
25
- end
36
+ reset_color_code = COLOR_CODES.fetch(:default)
37
+ color_code = COLOR_CODES.fetch(color, reset_color_code)
26
38
 
27
- "\e[#{color_code}m#{text}\e[0m"
39
+ "\e[#{color_code}m#{text}\e[#{reset_color_code}m"
28
40
  end
29
41
 
30
42
  def periods
@@ -13,7 +13,8 @@ module Appsignal
13
13
  EXCLUDED_ENVIRONMENTS = ["test"].freeze
14
14
 
15
15
  class << self
16
- def run(push_api_key)
16
+ def run(push_api_key, options) # rubocop:disable Metrics/AbcSize
17
+ self.coloring = options.delete(:color) { true }
17
18
  $stdout.sync = true
18
19
 
19
20
  puts
@@ -94,7 +94,7 @@ module Appsignal
94
94
  "see our documentation for more information on the recommended " \
95
95
  "method: " \
96
96
  "https://docs.appsignal.com/application/markers/deploy-markers.html"
97
- deprecation_message message, Appsignal.logger
97
+ deprecation_message message
98
98
  end
99
99
 
100
100
  private
@@ -39,7 +39,8 @@ module Appsignal
39
39
  :enable_minutely_probes => true,
40
40
  :ca_file_path => File.expand_path(File.join("../../../resources/cacert.pem"), __FILE__),
41
41
  :dns_servers => [],
42
- :files_world_accessible => true
42
+ :files_world_accessible => true,
43
+ :transaction_debug_mode => false
43
44
  }.freeze
44
45
 
45
46
  ENV_TO_KEY_MAPPING = {
@@ -75,6 +76,7 @@ module Appsignal
75
76
  "APPSIGNAL_DNS_SERVERS" => :dns_servers,
76
77
  "APPSIGNAL_FILES_WORLD_ACCESSIBLE" => :files_world_accessible,
77
78
  "APPSIGNAL_REQUEST_HEADERS" => :request_headers,
79
+ "APPSIGNAL_TRANSACTION_DEBUG_MODE" => :transaction_debug_mode,
78
80
  "APP_REVISION" => :revision
79
81
  }.freeze
80
82
 
@@ -219,6 +221,7 @@ module Appsignal
219
221
  ENV["_APPSIGNAL_CA_FILE_PATH"] = config_hash[:ca_file_path].to_s
220
222
  ENV["_APPSIGNAL_DNS_SERVERS"] = config_hash[:dns_servers].join(",")
221
223
  ENV["_APPSIGNAL_FILES_WORLD_ACCESSIBLE"] = config_hash[:files_world_accessible].to_s
224
+ ENV["_APPSIGNAL_TRANSACTION_DEBUG_MODE"] = config_hash[:transaction_debug_mode].to_s
222
225
  ENV["_APP_REVISION"] = config_hash[:revision].to_s
223
226
  end
224
227
 
@@ -234,11 +237,12 @@ module Appsignal
234
237
  "#{endpoint_uri.scheme}://#{endpoint_uri.host}:#{endpoint_uri.port}"
235
238
  end
236
239
 
237
- if config_hash[:push_api_key]
238
- @valid = true
239
- else
240
+ push_api_key = config_hash[:push_api_key] || ""
241
+ if push_api_key.strip.empty?
240
242
  @valid = false
241
- @logger.error "Push api key not set after loading config"
243
+ @logger.error "Push API key not set after loading config"
244
+ else
245
+ @valid = true
242
246
  end
243
247
  end
244
248
 
@@ -253,8 +257,10 @@ module Appsignal
253
257
  {}.tap do |hash|
254
258
  hash[:log] = "stdout" if Appsignal::System.heroku?
255
259
 
256
- # Make active by default if APPSIGNAL_PUSH_API_KEY is present
257
- hash[:active] = true if ENV["APPSIGNAL_PUSH_API_KEY"]
260
+ # Make AppSignal active by default if APPSIGNAL_PUSH_API_KEY
261
+ # environment variable is present and not empty.
262
+ env_push_api_key = ENV["APPSIGNAL_PUSH_API_KEY"] || ""
263
+ hash[:active] = true unless env_push_api_key.strip.empty?
258
264
  end
259
265
  end
260
266
 
@@ -271,9 +277,17 @@ module Appsignal
271
277
 
272
278
  maintain_backwards_compatibility(config_for_this_env)
273
279
  else
274
- @logger.error "Not loading from config file: config for '#{env}' not found"
280
+ logger.error "Not loading from config file: config for '#{env}' not found"
275
281
  nil
276
282
  end
283
+ rescue => e
284
+ message = "An error occured while loading the AppSignal config file." \
285
+ " Skipping file config.\n" \
286
+ "File: #{config_file.inspect}\n" \
287
+ "#{e.class.name}: #{e}"
288
+ $stderr.puts "appsignal: #{message}"
289
+ logger.error "#{message}\n#{e.backtrace.join("\n")}"
290
+ nil
277
291
  end
278
292
 
279
293
  # Maintain backwards compatibility with config files generated by earlier
@@ -324,7 +338,7 @@ module Appsignal
324
338
  APPSIGNAL_ENABLE_ALLOCATION_TRACKING APPSIGNAL_ENABLE_GC_INSTRUMENTATION
325
339
  APPSIGNAL_RUNNING_IN_CONTAINER APPSIGNAL_ENABLE_HOST_METRICS
326
340
  APPSIGNAL_SEND_PARAMS APPSIGNAL_ENABLE_MINUTELY_PROBES
327
- APPSIGNAL_FILES_WORLD_ACCESSIBLE].each do |var|
341
+ APPSIGNAL_FILES_WORLD_ACCESSIBLE APPSIGNAL_TRANSACTION_DEBUG_MODE].each do |var|
328
342
  env_var = ENV[var]
329
343
  next unless env_var
330
344
  config[ENV_TO_KEY_MAPPING[var]] = env_var.casecmp("true").zero?