appsignal 2.11.0.beta.2-java → 2.11.1.beta.2-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.semaphore/semaphore.yml +57 -1
  3. data/CHANGELOG.md +28 -0
  4. data/README.md +11 -5
  5. data/Rakefile +27 -9
  6. data/appsignal.gemspec +1 -1
  7. data/build_matrix.yml +2 -2
  8. data/ext/Rakefile +2 -0
  9. data/ext/agent.yml +17 -25
  10. data/ext/appsignal_extension.c +1 -1
  11. data/ext/base.rb +7 -0
  12. data/ext/extconf.rb +2 -0
  13. data/lib/appsignal.rb +1 -0
  14. data/lib/appsignal/auth_check.rb +4 -2
  15. data/lib/appsignal/cli/diagnose.rb +1 -1
  16. data/lib/appsignal/config.rb +82 -17
  17. data/lib/appsignal/extension.rb +6 -5
  18. data/lib/appsignal/extension/jruby.rb +6 -5
  19. data/lib/appsignal/hooks.rb +24 -0
  20. data/lib/appsignal/hooks/action_mailer.rb +22 -0
  21. data/lib/appsignal/hooks/active_job.rb +53 -5
  22. data/lib/appsignal/hooks/active_support_notifications.rb +72 -0
  23. data/lib/appsignal/hooks/puma.rb +0 -1
  24. data/lib/appsignal/hooks/sidekiq.rb +1 -2
  25. data/lib/appsignal/integrations/delayed_job_plugin.rb +1 -1
  26. data/lib/appsignal/probes.rb +7 -0
  27. data/lib/appsignal/probes/puma.rb +1 -1
  28. data/lib/appsignal/probes/sidekiq.rb +3 -1
  29. data/lib/appsignal/utils/deprecation_message.rb +1 -1
  30. data/lib/appsignal/version.rb +1 -1
  31. data/spec/lib/appsignal/auth_check_spec.rb +23 -0
  32. data/spec/lib/appsignal/capistrano2_spec.rb +1 -1
  33. data/spec/lib/appsignal/capistrano3_spec.rb +1 -1
  34. data/spec/lib/appsignal/cli/diagnose_spec.rb +42 -0
  35. data/spec/lib/appsignal/config_spec.rb +39 -1
  36. data/spec/lib/appsignal/extension/jruby_spec.rb +31 -28
  37. data/spec/lib/appsignal/extension_install_failure_spec.rb +23 -0
  38. data/spec/lib/appsignal/hooks/action_mailer_spec.rb +54 -0
  39. data/spec/lib/appsignal/hooks/active_support_notifications/finish_with_state_shared_examples.rb +35 -0
  40. data/spec/lib/appsignal/hooks/active_support_notifications/instrument_shared_examples.rb +145 -0
  41. data/spec/lib/appsignal/hooks/active_support_notifications/start_finish_shared_examples.rb +69 -0
  42. data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +9 -137
  43. data/spec/lib/appsignal/hooks/activejob_spec.rb +143 -10
  44. data/spec/lib/appsignal/hooks/delayed_job_spec.rb +3 -14
  45. data/spec/lib/appsignal/hooks/sidekiq_spec.rb +7 -5
  46. data/spec/lib/appsignal/hooks_spec.rb +57 -0
  47. data/spec/lib/appsignal/marker_spec.rb +1 -1
  48. data/spec/spec_helper.rb +5 -0
  49. data/spec/support/helpers/config_helpers.rb +3 -2
  50. data/spec/support/helpers/dependency_helper.rb +4 -0
  51. data/spec/support/helpers/transaction_helpers.rb +1 -1
  52. data/spec/support/testing.rb +19 -19
  53. metadata +19 -7
data/README.md CHANGED
@@ -9,7 +9,7 @@ issues.
9
9
  - [Ruby code documentation][ruby-doc]
10
10
  - [Support][contact]
11
11
 
12
- [![Build status](https://appsignal.semaphoreci.com/badges/appsignal-ruby/branches/master.svg)](https://appsignal.semaphoreci.com/projects/appsignal-ruby)
12
+ [![Build status](https://appsignal.semaphoreci.com/badges/appsignal-ruby/branches/main.svg)](https://appsignal.semaphoreci.com/projects/appsignal-ruby)
13
13
  [![Gem Version](https://badge.fury.io/rb/appsignal.svg)](http://badge.fury.io/rb/appsignal)
14
14
  [![Code Climate](https://codeclimate.com/github/appsignal/appsignal.png)](https://codeclimate.com/github/appsignal/appsignal)
15
15
 
@@ -183,7 +183,7 @@ installing the AppSignal C-extension.
183
183
  # Gemfile
184
184
  gem "appsignal",
185
185
  :git => "https://github.com/appsignal/appsignal-ruby.git",
186
- :branch => "master"
186
+ :branch => "main"
187
187
  ```
188
188
 
189
189
  When you need to use a git source of the gem in your JRuby install, you'll need
@@ -219,12 +219,18 @@ BUNDLE_GEMFILE=gemfiles/capistrano3.gemfile bundle exec rspec
219
219
  BUNDLE_GEMFILE=gemfiles/grape.gemfile bundle exec rspec
220
220
  BUNDLE_GEMFILE=gemfiles/no_dependencies.gemfile bundle exec rspec
221
221
  BUNDLE_GEMFILE=gemfiles/padrino.gemfile bundle exec rspec
222
+ BUNDLE_GEMFILE=gemfiles/que.gemfile bundle exec rspec
223
+ BUNDLE_GEMFILE=gemfiles/que_beta.gemfile bundle exec rspec
222
224
  BUNDLE_GEMFILE=gemfiles/rails-3.2.gemfile bundle exec rspec
223
225
  BUNDLE_GEMFILE=gemfiles/rails-4.0.gemfile bundle exec rspec
224
226
  BUNDLE_GEMFILE=gemfiles/rails-4.1.gemfile bundle exec rspec
225
227
  BUNDLE_GEMFILE=gemfiles/rails-4.2.gemfile bundle exec rspec
226
228
  BUNDLE_GEMFILE=gemfiles/rails-5.0.gemfile bundle exec rspec
227
- BUNDLE_GEMFILE=gemfiles/resque.gemfile bundle exec rspec
229
+ BUNDLE_GEMFILE=gemfiles/rails-5.1.gemfile bundle exec rspec
230
+ BUNDLE_GEMFILE=gemfiles/rails-5.2.gemfile bundle exec rspec
231
+ BUNDLE_GEMFILE=gemfiles/rails-6.0.gemfile bundle exec rspec
232
+ BUNDLE_GEMFILE=gemfiles/resque-1.gemfile bundle exec rspec
233
+ BUNDLE_GEMFILE=gemfiles/resque-2.gemfile bundle exec rspec
228
234
  BUNDLE_GEMFILE=gemfiles/sequel-435.gemfile bundle exec rspec
229
235
  BUNDLE_GEMFILE=gemfiles/sequel.gemfile bundle exec rspec
230
236
  BUNDLE_GEMFILE=gemfiles/sinatra.gemfile bundle exec rspec
@@ -242,12 +248,12 @@ a number of different Ruby versions.
242
248
 
243
249
  This gem uses [Semantic Versioning][semver].
244
250
 
245
- The `master` branch corresponds to the current stable release of the gem.
251
+ The `main` branch corresponds to the current stable release of the gem.
246
252
 
247
253
  The `develop` branch is used for development of features that will end up in
248
254
  the next minor release.
249
255
 
250
- Open a Pull Request on the `master` branch if you're fixing a bug. For new new
256
+ Open a Pull Request on the `main` branch if you're fixing a bug. For new new
251
257
  features, open a Pull Request on the `develop` branch.
252
258
 
253
259
  Every stable and unstable release is tagged in git with a version tag.
data/Rakefile CHANGED
@@ -39,6 +39,10 @@ def build_task(ruby_version, type = nil)
39
39
  }
40
40
  end
41
41
 
42
+ def gems_with_gemfiles
43
+ YAML.load_file("build_matrix.yml")["matrix"]["gems"].map { |g| g["gem"] }.freeze
44
+ end
45
+
42
46
  namespace :build_matrix do
43
47
  namespace :semaphore do
44
48
  task :generate do
@@ -70,7 +74,10 @@ namespace :build_matrix do
70
74
  job = {
71
75
  "name" => "Ruby #{ruby_version} for #{gem["gem"]}",
72
76
  "env_vars" => env,
73
- "commands" => ["./support/bundler_wrapper exec rake test"]
77
+ "commands" => [
78
+ "./support/bundler_wrapper exec rake test",
79
+ "./support/bundler_wrapper exec rake test:failure"
80
+ ]
74
81
  }
75
82
  if gem["gem"] == "no_dependencies"
76
83
  ruby_primary_block["task"]["jobs"] << job
@@ -307,17 +314,19 @@ task :publish => [
307
314
  desc "Install the AppSignal gem, extension and all possible dependencies."
308
315
  task :install => "extension:install" do
309
316
  Bundler.with_clean_env do
310
- GEMFILES.each do |gemfile|
317
+ gems_with_gemfiles.each do |gemfile|
311
318
  system "bundle --gemfile gemfiles/#{gemfile}.gemfile"
312
319
  end
313
320
  end
314
321
  end
315
322
 
316
323
  task :spec_all_gemfiles do
317
- GEMFILES.each do |gemfile|
318
- puts "Running tests for #{gemfile}"
319
- unless system("env BUNDLE_GEMFILE=gemfiles/#{gemfile}.gemfile bundle exec rspec")
320
- raise "Not successful"
324
+ Bundler.with_clean_env do
325
+ gems_with_gemfiles.each do |gemfile|
326
+ puts "Running tests for #{gemfile}"
327
+ unless system("env BUNDLE_GEMFILE=gemfiles/#{gemfile}.gemfile bundle exec rspec")
328
+ raise "Not successful"
329
+ end
321
330
  end
322
331
  end
323
332
  end
@@ -364,11 +373,20 @@ end
364
373
 
365
374
  begin
366
375
  require "rspec/core/rake_task"
376
+ is_jruby = defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
377
+ unless is_jruby
378
+ jruby_opts = "--exclude-pattern=spec/lib/appsignal/extension/jruby_spec.rb"
379
+ end
380
+
367
381
  desc "Run the AppSignal gem test suite."
368
382
  RSpec::Core::RakeTask.new :test do |t|
369
- is_jruby = defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
370
- unless is_jruby
371
- t.rspec_opts = "--exclude-pattern=spec/lib/appsignal/extension/jruby_spec.rb"
383
+ t.rspec_opts = jruby_opts
384
+ end
385
+
386
+ namespace :test do
387
+ desc "Run the Appsignal gem test in an extension failure scenario"
388
+ RSpec::Core::RakeTask.new :failure do |t|
389
+ t.rspec_opts = "#{jruby_opts} --tag extension_installation_failure"
372
390
  end
373
391
  end
374
392
  rescue LoadError # rubocop:disable Lint/HandleExceptions
@@ -29,7 +29,7 @@ Gem::Specification.new do |gem| # rubocop:disable Metrics/BlockLength
29
29
  gem.metadata = {
30
30
  "bug_tracker_uri" => "https://github.com/appsignal/appsignal-ruby/issues",
31
31
  "changelog_uri" =>
32
- "https://github.com/appsignal/appsignal-ruby/blob/master/CHANGELOG.md",
32
+ "https://github.com/appsignal/appsignal-ruby/blob/main/CHANGELOG.md",
33
33
  "documentation_uri" => "https://docs.appsignal.com/ruby/",
34
34
  "homepage_uri" => "https://docs.appsignal.com/ruby/",
35
35
  "source_code_uri" => "https://github.com/appsignal/appsignal-ruby"
@@ -10,8 +10,8 @@ semaphore: # Default `.semaphore/semaphore.yml` contents
10
10
  # Cancel all running and queued workflows before this one
11
11
  auto_cancel:
12
12
  running:
13
- # Ignore master AND develop branch as we want it to build all workflows
14
- when: "branch != 'master' AND branch != 'develop'"
13
+ # Ignore main AND develop branch as we want it to build all workflows
14
+ when: "branch != 'main' AND branch != 'develop'"
15
15
 
16
16
  global_job_config:
17
17
  env_vars:
@@ -11,6 +11,8 @@ end
11
11
 
12
12
  task :default do
13
13
  begin
14
+ fail_install_on_purpose_in_test!
15
+
14
16
  library_type = "dynamic"
15
17
  report["language"]["implementation"] = "jruby"
16
18
  report["build"]["library_type"] = library_type
@@ -1,70 +1,62 @@
1
1
  ---
2
- version: a5b5db2
2
+ version: 361340a
3
3
  mirrors:
4
4
  - https://appsignal-agent-releases.global.ssl.fastly.net
5
5
  - https://d135dj0rjqvssy.cloudfront.net
6
6
  triples:
7
7
  x86_64-darwin:
8
8
  static:
9
- checksum: 60236d6cfe998d5d9e8a8d1c493b0be956c35b449dd16c47c1b9d4dada73c57e
9
+ checksum: 4e08cb0cef0ea7e30f8d507380b923f6cfa14adaea12c81804e118acd6395b57
10
10
  filename: appsignal-x86_64-darwin-all-static.tar.gz
11
11
  dynamic:
12
- checksum: e69a6fab6b854345bcecba2eb06de38f00d8a9fc67bb04502feab13e987699b4
12
+ checksum: 1a9c3e26bd453fe60a2f511d536e64bdeddb1f939664bda90d6a41eaeedf5250
13
13
  filename: appsignal-x86_64-darwin-all-dynamic.tar.gz
14
14
  universal-darwin:
15
15
  static:
16
- checksum: 60236d6cfe998d5d9e8a8d1c493b0be956c35b449dd16c47c1b9d4dada73c57e
16
+ checksum: 4e08cb0cef0ea7e30f8d507380b923f6cfa14adaea12c81804e118acd6395b57
17
17
  filename: appsignal-x86_64-darwin-all-static.tar.gz
18
18
  dynamic:
19
- checksum: e69a6fab6b854345bcecba2eb06de38f00d8a9fc67bb04502feab13e987699b4
19
+ checksum: 1a9c3e26bd453fe60a2f511d536e64bdeddb1f939664bda90d6a41eaeedf5250
20
20
  filename: appsignal-x86_64-darwin-all-dynamic.tar.gz
21
21
  i686-linux:
22
22
  static:
23
- checksum: 31d4400ec70ab05a1cf960b7e3bd46c3e8b3e0d4e2cf3be9bd20ed97ff5291e6
23
+ checksum: 01c027b3e472cb39d844284fcc8ba532628c00731b912e0e9718646ed124ae6e
24
24
  filename: appsignal-i686-linux-all-static.tar.gz
25
25
  dynamic:
26
- checksum: a2625de08adbf2804230774bb9d7ad7b4c568a5525a5300d41a450334c4b5528
26
+ checksum: 30696eac3ae5646bcb21ff86a1824dd4511a41dd323514e4a97a41b5ff09e2f8
27
27
  filename: appsignal-i686-linux-all-dynamic.tar.gz
28
28
  x86-linux:
29
29
  static:
30
- checksum: 31d4400ec70ab05a1cf960b7e3bd46c3e8b3e0d4e2cf3be9bd20ed97ff5291e6
30
+ checksum: 01c027b3e472cb39d844284fcc8ba532628c00731b912e0e9718646ed124ae6e
31
31
  filename: appsignal-i686-linux-all-static.tar.gz
32
32
  dynamic:
33
- checksum: a2625de08adbf2804230774bb9d7ad7b4c568a5525a5300d41a450334c4b5528
33
+ checksum: 30696eac3ae5646bcb21ff86a1824dd4511a41dd323514e4a97a41b5ff09e2f8
34
34
  filename: appsignal-i686-linux-all-dynamic.tar.gz
35
- i686-linux-musl:
36
- static:
37
- checksum: 18a5648c469718676e0c4b2925fbdd04a6d9b916ff778571a48d4ff0ffa944b6
38
- filename: appsignal-i686-linux-musl-all-static.tar.gz
39
- x86-linux-musl:
40
- static:
41
- checksum: 18a5648c469718676e0c4b2925fbdd04a6d9b916ff778571a48d4ff0ffa944b6
42
- filename: appsignal-i686-linux-musl-all-static.tar.gz
43
35
  x86_64-linux:
44
36
  static:
45
- checksum: df100f661e19266fe92a19ae44407f413e14f1bb975261542e3b738c5215889a
37
+ checksum: fe2038d6fa468fc23900fea6d8179d2b37d41d54f4ff33c573116183ac1cb491
46
38
  filename: appsignal-x86_64-linux-all-static.tar.gz
47
39
  dynamic:
48
- checksum: 4d988176e9419fe553cbab10ebc4eab617fdd3806682cbb35ab01d1f02bcd297
40
+ checksum: bcbf9546b078fb8bbaae5e7df4ed84831346c814bc865a47d32a3a095a84acbb
49
41
  filename: appsignal-x86_64-linux-all-dynamic.tar.gz
50
42
  x86_64-linux-musl:
51
43
  static:
52
- checksum: 265d42b764789b105cc5a8b5117ec1dbc07265f870e936661a8b6211c04de05a
44
+ checksum: b2ee5579a62b76a1d2f41f4e06749c4c549f9aaa40764862eff49c5a6a8841f1
53
45
  filename: appsignal-x86_64-linux-musl-all-static.tar.gz
54
46
  dynamic:
55
- checksum: 0b96c3f03b6c2943b2b51bfcdd56aa90e0869a5890dedf7ce30df9a8fe4f6d9a
47
+ checksum: 53cd2464853e61c2d8f911ec32ff98cb48f824293ffd575da6743bc34625a7eb
56
48
  filename: appsignal-x86_64-linux-musl-all-dynamic.tar.gz
57
49
  x86_64-freebsd:
58
50
  static:
59
- checksum: 0ffbe3fa91e5b1687693fa9af8e9c6bdccb98ffd6122d8ccd86bb81fbea91e3f
51
+ checksum: f228dd2f2cf951c9eb9f04487be50fdfdc3d29a956e639787a4022bd73f02e53
60
52
  filename: appsignal-x86_64-freebsd-all-static.tar.gz
61
53
  dynamic:
62
- checksum: d0f02acf08c3ab4601b2a1e26c899bc14274b742d6af1b5701646781c6c0e50c
54
+ checksum: 030b322b2cb15607260cbb0424c03f6e41646dca7aacc43a30279ad63a336541
63
55
  filename: appsignal-x86_64-freebsd-all-dynamic.tar.gz
64
56
  amd64-freebsd:
65
57
  static:
66
- checksum: 0ffbe3fa91e5b1687693fa9af8e9c6bdccb98ffd6122d8ccd86bb81fbea91e3f
58
+ checksum: f228dd2f2cf951c9eb9f04487be50fdfdc3d29a956e639787a4022bd73f02e53
67
59
  filename: appsignal-x86_64-freebsd-all-static.tar.gz
68
60
  dynamic:
69
- checksum: d0f02acf08c3ab4601b2a1e26c899bc14274b742d6af1b5701646781c6c0e50c
61
+ checksum: 030b322b2cb15607260cbb0424c03f6e41646dca7aacc43a30279ad63a336541
70
62
  filename: appsignal-x86_64-freebsd-all-dynamic.tar.gz
@@ -485,7 +485,7 @@ static VALUE data_append_boolean(VALUE self, VALUE value) {
485
485
  return Qnil;
486
486
  }
487
487
 
488
- static VALUE data_append_nil(VALUE self, VALUE value) {
488
+ static VALUE data_append_nil(VALUE self) {
489
489
  appsignal_data_t* data;
490
490
 
491
491
  Data_Get_Struct(self, appsignal_data_t, data);
@@ -183,3 +183,10 @@ end
183
183
  def http_proxy
184
184
  Gem.configuration[:http_proxy] || ENV["http_proxy"] || ENV["HTTP_PROXY"]
185
185
  end
186
+
187
+ # Fail the installation on purpose in a specific test environment.
188
+ def fail_install_on_purpose_in_test!
189
+ return unless ENV["_TEST_APPSIGNAL_EXTENSION_FAILURE"]
190
+
191
+ raise "AppSignal internal test failure"
192
+ end
@@ -7,6 +7,8 @@ def local_build?
7
7
  end
8
8
 
9
9
  def install
10
+ fail_install_on_purpose_in_test!
11
+
10
12
  library_type = "static"
11
13
  report["language"]["implementation"] = "ruby"
12
14
  report["build"]["library_type"] = library_type
@@ -339,6 +339,7 @@ require "appsignal/auth_check"
339
339
  require "appsignal/config"
340
340
  require "appsignal/event_formatter"
341
341
  require "appsignal/hooks"
342
+ require "appsignal/probes"
342
343
  require "appsignal/marker"
343
344
  require "appsignal/minutely"
344
345
  require "appsignal/garbage_collection_profiler"
@@ -25,8 +25,10 @@ module Appsignal
25
25
  def initialize(config, logger = nil)
26
26
  @config = config
27
27
  if logger # rubocop:disable Style/GuardClause
28
- warn "Deprecated: `logger` argument will be removed in the next " \
29
- "major version."
28
+ Appsignal::Utils::DeprecationMessage.message \
29
+ "`Appsignal::AuthCheck.new`'s `logger` argument will be removed " \
30
+ "in the next major version. Please configure the logger " \
31
+ "using `Appsignal.logger`."
30
32
  end
31
33
  end
32
34
 
@@ -371,7 +371,7 @@ module Appsignal
371
371
  end
372
372
 
373
373
  def print_installation_result_report(report)
374
- report = report.fetch("download", {})
374
+ report = report.fetch("result", {})
375
375
  puts " Installation result"
376
376
  puts " Status: #{report["status"]}"
377
377
  puts " Message: #{report["message"]}" if report["message"]
@@ -81,6 +81,50 @@ module Appsignal
81
81
  "APPSIGNAL_TRANSACTION_DEBUG_MODE" => :transaction_debug_mode,
82
82
  "APP_REVISION" => :revision
83
83
  }.freeze
84
+ # @api private
85
+ ENV_STRING_KEYS = %w[
86
+ APPSIGNAL_APP_NAME
87
+ APPSIGNAL_CA_FILE_PATH
88
+ APPSIGNAL_DNS_SERVERS
89
+ APPSIGNAL_FRONTEND_ERROR_CATCHING_PATH
90
+ APPSIGNAL_HOSTNAME
91
+ APPSIGNAL_HTTP_PROXY
92
+ APPSIGNAL_LOG
93
+ APPSIGNAL_LOG_PATH
94
+ APPSIGNAL_PUSH_API_ENDPOINT
95
+ APPSIGNAL_PUSH_API_KEY
96
+ APPSIGNAL_WORKING_DIRECTORY_PATH
97
+ APPSIGNAL_WORKING_DIR_PATH
98
+ APP_REVISION
99
+ ].freeze
100
+ # @api private
101
+ ENV_BOOLEAN_KEYS = %w[
102
+ APPSIGNAL_ACTIVE
103
+ APPSIGNAL_DEBUG
104
+ APPSIGNAL_ENABLE_ALLOCATION_TRACKING
105
+ APPSIGNAL_ENABLE_FRONTEND_ERROR_CATCHING
106
+ APPSIGNAL_ENABLE_GC_INSTRUMENTATION
107
+ APPSIGNAL_ENABLE_HOST_METRICS
108
+ APPSIGNAL_ENABLE_MINUTELY_PROBES
109
+ APPSIGNAL_FILES_WORLD_ACCESSIBLE
110
+ APPSIGNAL_INSTRUMENT_NET_HTTP
111
+ APPSIGNAL_INSTRUMENT_REDIS
112
+ APPSIGNAL_INSTRUMENT_SEQUEL
113
+ APPSIGNAL_RUNNING_IN_CONTAINER
114
+ APPSIGNAL_SEND_ENVIRONMENT_METADATA
115
+ APPSIGNAL_SEND_PARAMS
116
+ APPSIGNAL_SKIP_SESSION_DATA
117
+ APPSIGNAL_TRANSACTION_DEBUG_MODE
118
+ ].freeze
119
+ # @api private
120
+ ENV_ARRAY_KEYS = %w[
121
+ APPSIGNAL_FILTER_PARAMETERS
122
+ APPSIGNAL_FILTER_SESSION_DATA
123
+ APPSIGNAL_IGNORE_ACTIONS
124
+ APPSIGNAL_IGNORE_ERRORS
125
+ APPSIGNAL_IGNORE_NAMESPACES
126
+ APPSIGNAL_REQUEST_HEADERS
127
+ ].freeze
84
128
 
85
129
  # Mapping of old and deprecated AppSignal configuration keys
86
130
  DEPRECATED_CONFIG_KEY_MAPPING = {
@@ -121,8 +165,41 @@ module Appsignal
121
165
  :initial_config, :file_config, :env_config
122
166
  attr_accessor :logger
123
167
 
124
- def initialize(root_path, env, initial_config = {}, logger = Appsignal.logger)
168
+ # Initialize a new configuration object for AppSignal.
169
+ #
170
+ # If this is manually initialized, and not by {Appsignal.start}, it needs
171
+ # to be assigned to the {Appsignal.config} attribute.
172
+ #
173
+ # @example
174
+ # require "appsignal"
175
+ # Appsignal.config = Appsignal::Config.new(
176
+ # app_path,
177
+ # "production"
178
+ # )
179
+ # Appsignal.start
180
+ #
181
+ # @param root_path [String] Root path of the app.
182
+ # @param env [String] The environment to load when AppSignal is started. It
183
+ # will look for an environment with this name in the `config/appsignal.yml`
184
+ # config file.
185
+ # @param initial_config [Hash<String, Object>] The initial configuration to
186
+ # use. This will be overwritten by the file config and environment
187
+ # variables config.
188
+ # @param logger [Logger] The logger to use for the AppSignal gem. This is
189
+ # used by the configuration class only. Default: {Appsignal.logger}. See
190
+ # also {Appsignal.start_logger}.
191
+ # @param config_file [String] Custom config file location. Default
192
+ # `config/appsignal.yml`.
193
+ #
194
+ # @see https://docs.appsignal.com/ruby/configuration/
195
+ # Configuration documentation
196
+ # @see https://docs.appsignal.com/ruby/configuration/load-order.html
197
+ # Configuration load order
198
+ # @see https://docs.appsignal.com/ruby/instrumentation/integrating-appsignal.html
199
+ # How to integrate AppSignal manually
200
+ def initialize(root_path, env, initial_config = {}, logger = Appsignal.logger, config_file = nil)
125
201
  @root_path = root_path
202
+ @config_file = config_file
126
203
  @logger = logger
127
204
  @valid = false
128
205
  @config_hash = Hash[DEFAULT_CONFIG]
@@ -288,7 +365,7 @@ module Appsignal
288
365
  " Skipping file config.\n" \
289
366
  "File: #{config_file.inspect}\n" \
290
367
  "#{e.class.name}: #{e}"
291
- $stderr.puts "appsignal: #{message}"
368
+ Kernel.warn "appsignal: #{message}"
292
369
  logger.error "#{message}\n#{e.backtrace.join("\n")}"
293
370
  nil
294
371
  end
@@ -325,33 +402,21 @@ module Appsignal
325
402
  config = {}
326
403
 
327
404
  # Configuration with string type
328
- %w[APPSIGNAL_PUSH_API_KEY APPSIGNAL_APP_NAME APPSIGNAL_PUSH_API_ENDPOINT
329
- APPSIGNAL_FRONTEND_ERROR_CATCHING_PATH APPSIGNAL_HTTP_PROXY
330
- APPSIGNAL_LOG APPSIGNAL_LOG_PATH APPSIGNAL_WORKING_DIR_PATH
331
- APPSIGNAL_HOSTNAME APPSIGNAL_CA_FILE_PATH APP_REVISION].each do |var|
405
+ ENV_STRING_KEYS.each do |var|
332
406
  env_var = ENV[var]
333
407
  next unless env_var
334
408
  config[ENV_TO_KEY_MAPPING[var]] = env_var
335
409
  end
336
410
 
337
411
  # Configuration with boolean type
338
- %w[APPSIGNAL_ACTIVE APPSIGNAL_DEBUG APPSIGNAL_INSTRUMENT_NET_HTTP
339
- APPSIGNAL_INSTRUMENT_REDIS APPSIGNAL_INSTRUMENT_SEQUEL
340
- APPSIGNAL_SKIP_SESSION_DATA APPSIGNAL_ENABLE_FRONTEND_ERROR_CATCHING
341
- APPSIGNAL_ENABLE_ALLOCATION_TRACKING APPSIGNAL_ENABLE_GC_INSTRUMENTATION
342
- APPSIGNAL_RUNNING_IN_CONTAINER APPSIGNAL_ENABLE_HOST_METRICS
343
- APPSIGNAL_SEND_ENVIRONMENT_METADATA APPSIGNAL_SEND_PARAMS
344
- APPSIGNAL_ENABLE_MINUTELY_PROBES APPSIGNAL_FILES_WORLD_ACCESSIBLE
345
- APPSIGNAL_TRANSACTION_DEBUG_MODE].each do |var|
412
+ ENV_BOOLEAN_KEYS.each do |var|
346
413
  env_var = ENV[var]
347
414
  next unless env_var
348
415
  config[ENV_TO_KEY_MAPPING[var]] = env_var.casecmp("true").zero?
349
416
  end
350
417
 
351
418
  # Configuration with array of strings type
352
- %w[APPSIGNAL_IGNORE_ACTIONS APPSIGNAL_IGNORE_ERRORS
353
- APPSIGNAL_IGNORE_NAMESPACES APPSIGNAL_FILTER_PARAMETERS
354
- APPSIGNAL_FILTER_SESSION_DATA APPSIGNAL_REQUEST_HEADERS].each do |var|
419
+ ENV_ARRAY_KEYS.each do |var|
355
420
  env_var = ENV[var]
356
421
  next unless env_var
357
422
  config[ENV_TO_KEY_MAPPING[var]] = env_var.split(",")
@@ -10,11 +10,12 @@ begin
10
10
  require "appsignal_extension"
11
11
  Appsignal.extension_loaded = true
12
12
  end
13
- rescue LoadError => err
14
- Appsignal.logger.error(
15
- "Failed to load extension (#{err}), please run `appsignal diagnose` " \
16
- "and email us at support@appsignal.com"
17
- )
13
+ rescue LoadError => error
14
+ error_message = "ERROR: AppSignal failed to load extension. " \
15
+ "Please run `appsignal diagnose` and email us at support@appsignal.com\n" \
16
+ "#{error.class}: #{error.message}"
17
+ Appsignal.logger.error(error_message)
18
+ Kernel.warn error_message
18
19
  Appsignal.extension_loaded = false
19
20
  end
20
21