appsignal 2.8.0.alpha.1 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0cbf3f5ed33439ee3dc6064386cb6cd890d9cf92c7e0eec933eb4614d3a3fdb6
4
- data.tar.gz: facbbd23780eb8ae0858e416a48345849a0cd4342c3e403fe0768940f2193602
3
+ metadata.gz: 44c65af079aaf661799b20d076f1c5f11eb6bdb47ccdc6aa58dc85781c46d8c7
4
+ data.tar.gz: 3448422ae801b26eb40ba300016331a85e233fa33e5332971c1529b95fe934d6
5
5
  SHA512:
6
- metadata.gz: 35d0b062ac15881ca9a27750ed36da8430e2f1f8c2e01d1ec9ee4e62ca6d939982233e49c8b7fa8045c4dc807aef6c5e1b9d2ebc5a28bbca1d1aa318107055fb
7
- data.tar.gz: 2babcf1d9922648c79be50668e2ed6ce7e6e2563f24e2d75187f49960d790500fcc7a7bba38bcd6cb9bec6ac6bf89985dd2996a21b75f02cd61e47b60505426b
6
+ metadata.gz: 610f635119df8b05bdaa3b01cd646594235dd51addde01d96d9433caac12b3c347518e70d941a3a14b594623698952501e09758c9207984aa1209af0bdd8032f
7
+ data.tar.gz: 4995bd83545cc983821c90e9f1dae888bf6199a703e98a8026b4e8771ec7cf326f8344c2cd9328482c2ca78e785a0ed11f085f63832430cb6c92247056cc6655
@@ -12,11 +12,9 @@ cache:
12
12
 
13
13
  rvm:
14
14
  - "2.0.0"
15
- - "2.1.8"
16
- - "2.2.4"
17
- - "2.3.0"
18
- - "2.4.0"
19
- - "2.5.1"
15
+ - "2.3.8"
16
+ - "2.4.5"
17
+ - "2.5.3"
20
18
  - "jruby-19mode"
21
19
 
22
20
  gemfile:
@@ -41,32 +39,33 @@ gemfile:
41
39
  matrix:
42
40
  fast_finish: true
43
41
  include:
44
- - rvm: "2.3.0"
42
+ - rvm: "2.1.8"
43
+ gemfile: "gemfiles/no_dependencies.gemfile"
44
+ - rvm: "2.2.4"
45
+ gemfile: "gemfiles/no_dependencies.gemfile"
46
+ - rvm: "2.5.3"
45
47
  gemfile: "gemfiles/no_dependencies.gemfile"
46
48
  script: "bundle exec rubocop"
47
49
  exclude:
48
50
  # Rails 5 doesn't support Ruby < 2.2
49
51
  - rvm: "2.0.0"
50
52
  gemfile: "gemfiles/rails-5.0.gemfile"
51
- - rvm: "2.1.8"
52
- gemfile: "gemfiles/rails-5.0.gemfile"
53
53
  - rvm: "2.0.0"
54
54
  gemfile: "gemfiles/rails-5.1.gemfile"
55
- - rvm: "2.1.8"
56
- gemfile: "gemfiles/rails-5.1.gemfile"
57
- - rvm: "2.5.1"
55
+ - rvm: "2.5.3"
58
56
  gemfile: "gemfiles/rails-4.0.gemfile"
59
- - rvm: "2.5.1"
57
+ - rvm: "2.5.3"
60
58
  gemfile: "gemfiles/rails-4.1.gemfile"
61
59
 
62
60
  allow_failures:
63
- - rvm: "2.4.0"
61
+ - rvm: "2.4.5"
64
62
  gemfile: "gemfiles/rails-4.0.gemfile"
65
- - rvm: "2.4.0"
63
+ - rvm: "2.4.5"
66
64
  gemfile: "gemfiles/rails-4.1.gemfile"
67
65
 
68
66
  env:
69
67
  global:
68
+ - "RUNNING_IN_CI=true"
70
69
  - "RAILS_ENV=test"
71
70
  - "JRUBY_OPTS=''" # Workaround https://github.com/travis-ci/travis-ci/issues/6471
72
71
 
@@ -1,9 +1,31 @@
1
- # 2.8.0 (unreleased)
2
- - Support memory host metrics collection for containers. PR #428
3
-
4
- # 2.7.1 (unreleased)
1
+ # 2.8.0
2
+ - Group extension and agent tests in diagnose output. PR #437
3
+ - Add diagnose --[no-]send-report option. PR #438
4
+ - Print deprecation warnings to STDOUT as well. PR #439
5
+ - Diagnose command starts the AppSignal logger. PR #440
6
+ - Send appsignal.log file contents with diagnose report. PR #442
7
+ - Track source of config option for diagnose report. PR #444
8
+ - Link back to AppSignal diagnose report page. Claim you reports. PR #445
9
+ - Print only last 10 lines of files in diagnose report output. PR #442 & #447
10
+ - Support container memory host metrics better. PR #448
11
+ - Build dynamic musl extension library. Supports JRuby for musl builds. PR #448
12
+ - Change `files_world_accessible` permissions to not make files executable.
13
+ PR #448
14
+ - Make agent debug logging for disk IO metrics more robust. PR #448
15
+
16
+ # 2.7.3 Beta
17
+ - Add user and group context to diagnose report. PR #436
18
+ - Add user and group context to agent logs. PR #436
19
+ - Fixes for running with multiple users
20
+
21
+ # 2.7.2
22
+ - Change the order of instructions in the install script for Rails. PR #433
23
+ - Fix linking issues on multi-stage build setups. PR #434
24
+
25
+ # 2.7.1
5
26
  - Improve error log on unsupported architecture and build combination on
6
27
  install. PR #426
28
+ - Improve performance when garbage collection profiling is disabled. PR #429
7
29
 
8
30
  # 2.7.0
9
31
  - Detect Kubernetes containers as containers for `running_in_container`
@@ -522,7 +544,7 @@ Yanked
522
544
  * Debug log about missing name in config
523
545
 
524
546
  # 0.10.4
525
- * Add REQUEST_URI and PATH_INFO to env params whitelist
547
+ * Add REQUEST_URI and PATH_INFO to env params allowlist
526
548
 
527
549
  # 0.10.3
528
550
  * Shut down all operations when agent is not active
@@ -1,64 +1,67 @@
1
1
  ---
2
- version: 01362a4
2
+ version: 86b6269
3
3
  triples:
4
4
  x86_64-darwin:
5
5
  static:
6
- checksum: a33aa14ae9b8c58c379667e7f79807bdc843354baf635abc334a14c3b984114d
7
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/01362a4/appsignal-x86_64-darwin-all-static.tar.gz
6
+ checksum: e253a63c279747c52013e7d0a9b402c879a345d5ab9c06c6f50314b6211d9e4e
7
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/86b6269/appsignal-x86_64-darwin-all-static.tar.gz
8
8
  dynamic:
9
- checksum: 9956fc35234bbd0f01095ee9032dbf3631d424bdf51536b50c59e8f765834ce1
10
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/01362a4/appsignal-x86_64-darwin-all-dynamic.tar.gz
9
+ checksum: 321b5e96fcafc3016858ae6588916613009cfe5c1ace288773c868151252dd6a
10
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/86b6269/appsignal-x86_64-darwin-all-dynamic.tar.gz
11
11
  universal-darwin:
12
12
  static:
13
- checksum: a33aa14ae9b8c58c379667e7f79807bdc843354baf635abc334a14c3b984114d
14
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/01362a4/appsignal-x86_64-darwin-all-static.tar.gz
13
+ checksum: e253a63c279747c52013e7d0a9b402c879a345d5ab9c06c6f50314b6211d9e4e
14
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/86b6269/appsignal-x86_64-darwin-all-static.tar.gz
15
15
  dynamic:
16
- checksum: 9956fc35234bbd0f01095ee9032dbf3631d424bdf51536b50c59e8f765834ce1
17
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/01362a4/appsignal-x86_64-darwin-all-dynamic.tar.gz
16
+ checksum: 321b5e96fcafc3016858ae6588916613009cfe5c1ace288773c868151252dd6a
17
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/86b6269/appsignal-x86_64-darwin-all-dynamic.tar.gz
18
18
  i686-linux:
19
19
  static:
20
- checksum: 44d729dd8b3c6bf3041ee32dee1c155bfd19b5309cbf6ef95959fc026819915c
21
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/01362a4/appsignal-i686-linux-all-static.tar.gz
20
+ checksum: 11bf57ab3f845e41d90d4cf78fc727103c3a214dcbc18aecde9aa5f9bd0a105f
21
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/86b6269/appsignal-i686-linux-all-static.tar.gz
22
22
  dynamic:
23
- checksum: 30fa55577862addebe16b0fddfdd73c6613f321d769606f15bbd14be8850aa68
24
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/01362a4/appsignal-i686-linux-all-dynamic.tar.gz
23
+ checksum: bca8626460eab556fac29d64e97f3a521aa82fb0e2323f9970c5e840c676d35d
24
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/86b6269/appsignal-i686-linux-all-dynamic.tar.gz
25
25
  x86-linux:
26
26
  static:
27
- checksum: 44d729dd8b3c6bf3041ee32dee1c155bfd19b5309cbf6ef95959fc026819915c
28
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/01362a4/appsignal-i686-linux-all-static.tar.gz
27
+ checksum: 11bf57ab3f845e41d90d4cf78fc727103c3a214dcbc18aecde9aa5f9bd0a105f
28
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/86b6269/appsignal-i686-linux-all-static.tar.gz
29
29
  dynamic:
30
- checksum: 30fa55577862addebe16b0fddfdd73c6613f321d769606f15bbd14be8850aa68
31
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/01362a4/appsignal-i686-linux-all-dynamic.tar.gz
30
+ checksum: bca8626460eab556fac29d64e97f3a521aa82fb0e2323f9970c5e840c676d35d
31
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/86b6269/appsignal-i686-linux-all-dynamic.tar.gz
32
32
  i686-linux-musl:
33
33
  static:
34
- checksum: 0bb69e60781db9bd0867ccece63a029706cf0d5a26d34d70668bc2264b531ce4
35
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/01362a4/appsignal-i686-linux-musl-all-static.tar.gz
34
+ checksum: fed88ea2a0a0885fd98e3f52a48b925aaca3946d39150dd9897af0b2a934660a
35
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/86b6269/appsignal-i686-linux-musl-all-static.tar.gz
36
36
  x86-linux-musl:
37
37
  static:
38
- checksum: 0bb69e60781db9bd0867ccece63a029706cf0d5a26d34d70668bc2264b531ce4
39
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/01362a4/appsignal-i686-linux-musl-all-static.tar.gz
38
+ checksum: fed88ea2a0a0885fd98e3f52a48b925aaca3946d39150dd9897af0b2a934660a
39
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/86b6269/appsignal-i686-linux-musl-all-static.tar.gz
40
40
  x86_64-linux:
41
41
  static:
42
- checksum: 92b3662722978b39176c9d2e986fb8cc527772470dd0d9d7a8ea808cd4780b70
43
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/01362a4/appsignal-x86_64-linux-all-static.tar.gz
42
+ checksum: 6d80a9d03c905926c14ba6ffd5d0d4c736a8d065c9055d8dd6d85e114f2a4d8e
43
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/86b6269/appsignal-x86_64-linux-all-static.tar.gz
44
44
  dynamic:
45
- checksum: 3a9af3a4280b9842702d8af6cc4af84acc452b910fc8d753ee5907807de8f58c
46
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/01362a4/appsignal-x86_64-linux-all-dynamic.tar.gz
45
+ checksum: 3678f0d2b05af9173c333eb4994b316678648d12df9a4cbe685eaedd8a190f3b
46
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/86b6269/appsignal-x86_64-linux-all-dynamic.tar.gz
47
47
  x86_64-linux-musl:
48
48
  static:
49
- checksum: 41624a50b603eeb4f875ee19dde41bb0877a0a039f6f2f560a9efc3d6b73a195
50
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/01362a4/appsignal-x86_64-linux-musl-all-static.tar.gz
49
+ checksum: ecde0cc6349b68bf57a632f19a1e2f9fcdc42e8a9ce646fb1bd651837b06d01b
50
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/86b6269/appsignal-x86_64-linux-musl-all-static.tar.gz
51
+ dynamic:
52
+ checksum: 2c3c123e854bb284f0df536d796826fa5403fddc7d67f1556634fa331e0b7729
53
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/86b6269/appsignal-x86_64-linux-musl-all-dynamic.tar.gz
51
54
  x86_64-freebsd:
52
55
  static:
53
- checksum: 14cdca07045a53b2c69647f1255cbc2f9fe322ddf6040c2e1a6ba36aa482cdf2
54
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/01362a4/appsignal-x86_64-freebsd-all-static.tar.gz
56
+ checksum: 4c880e9ef3f1a6da8cd9914ee2346422e6fb927772bd1586c4afbcf990023a69
57
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/86b6269/appsignal-x86_64-freebsd-all-static.tar.gz
55
58
  dynamic:
56
- checksum: 0433b4cd9e0af92b8b4efdb797de43129f754b71a04c2313786d571866092675
57
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/01362a4/appsignal-x86_64-freebsd-all-dynamic.tar.gz
59
+ checksum: 70f9b378afa50d04d14aa9e8bbc4cbee99f9755c9e09bcdfc7c70f82ca5825ea
60
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/86b6269/appsignal-x86_64-freebsd-all-dynamic.tar.gz
58
61
  amd64-freebsd:
59
62
  static:
60
- checksum: 14cdca07045a53b2c69647f1255cbc2f9fe322ddf6040c2e1a6ba36aa482cdf2
61
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/01362a4/appsignal-x86_64-freebsd-all-static.tar.gz
63
+ checksum: 4c880e9ef3f1a6da8cd9914ee2346422e6fb927772bd1586c4afbcf990023a69
64
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/86b6269/appsignal-x86_64-freebsd-all-static.tar.gz
62
65
  dynamic:
63
- checksum: 0433b4cd9e0af92b8b4efdb797de43129f754b71a04c2313786d571866092675
64
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/01362a4/appsignal-x86_64-freebsd-all-dynamic.tar.gz
66
+ checksum: 70f9b378afa50d04d14aa9e8bbc4cbee99f9755c9e09bcdfc7c70f82ca5825ea
67
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/86b6269/appsignal-x86_64-freebsd-all-dynamic.tar.gz
@@ -23,6 +23,18 @@ def install
23
23
  elsif !find_executable("appsignal-agent", EXT_PATH)
24
24
  installation_failed "Aborting installation, appsignal-agent not found"
25
25
  else
26
+ with_static_link = [
27
+ Appsignal::System::LINUX_TARGET,
28
+ Appsignal::System::MUSL_TARGET
29
+ ].include?(PLATFORM)
30
+ if with_static_link
31
+ # Statically link libgcc and libgcc_s libraries.
32
+ # Dependencies of the libappsignal extension library.
33
+ # If the gem is installed on a host with build tools installed, but is
34
+ # run on one that isn't the missing libraries will cause the extension
35
+ # to fail on start.
36
+ $LDFLAGS += " -static-libgcc" # rubocop:disable Style/GlobalVars
37
+ end
26
38
  create_makefile "appsignal_extension"
27
39
  logger.info "Successfully created Makefile for appsignal extension"
28
40
  end
@@ -82,6 +82,9 @@ module Appsignal
82
82
  o.on "--environment=<app_env>", "The environment to diagnose" do |arg|
83
83
  options[:environment] = arg
84
84
  end
85
+ o.on "--[no-]send-report", "Confirm sending the report to AppSignal automatically" do |arg|
86
+ options[:send_report] = arg
87
+ end
85
88
  end,
86
89
  "install" => OptionParser.new,
87
90
  "notify_of_deploy" => OptionParser.new do |o|
@@ -4,6 +4,8 @@ require "rbconfig"
4
4
  require "bundler/cli"
5
5
  require "bundler/cli/common"
6
6
  require "etc"
7
+ require "appsignal/cli/diagnose/utils"
8
+ require "appsignal/cli/diagnose/paths"
7
9
 
8
10
  module Appsignal
9
11
  class CLI
@@ -34,8 +36,14 @@ module Appsignal
34
36
  # @example With a specific environment
35
37
  # appsignal diagnose --environment=production
36
38
  #
37
- # @see http://docs.appsignal.com/support/debugging.html Debugging AppSignal
38
- # @see http://docs.appsignal.com/ruby/command-line/diagnose.html
39
+ # @example Automatically send the diagnose report without prompting
40
+ # appsignal diagnose --send-report
41
+ #
42
+ # @example Don't prompt about sending the report and don't sent it
43
+ # appsignal diagnose --no-send-report
44
+ #
45
+ # @see https://docs.appsignal.com/support/debugging.html Debugging AppSignal
46
+ # @see https://docs.appsignal.com/ruby/command-line/diagnose.html
39
47
  # AppSignal diagnose documentation
40
48
  # @since 1.1.0
41
49
  class Diagnose
@@ -73,44 +81,58 @@ module Appsignal
73
81
  def run(options = {})
74
82
  $stdout.sync = true
75
83
  header
76
- empty_line
84
+ print_empty_line
77
85
 
78
86
  library_information
79
- empty_line
87
+ print_empty_line
80
88
 
81
89
  host_information
82
- empty_line
90
+ print_empty_line
83
91
 
84
92
  configure_appsignal(options)
85
93
  run_agent_diagnose_mode
86
- empty_line
94
+ print_empty_line
87
95
 
88
- config
89
- empty_line
96
+ print_config_section
97
+ print_empty_line
90
98
 
91
99
  check_api_key
92
- empty_line
100
+ print_empty_line
93
101
 
94
- paths_section
95
- empty_line
102
+ data[:process] = process_user
96
103
 
97
- log_files
104
+ paths_report = Paths.new
105
+ data[:paths] = paths_report.report
106
+ print_paths_section(paths_report)
107
+ print_empty_line
98
108
 
99
- transmit_report_to_appsignal if send_report_to_appsignal?
109
+ transmit_report_to_appsignal if send_report_to_appsignal?(options)
100
110
  end
101
111
 
102
112
  private
103
113
 
104
- def send_report_to_appsignal?
114
+ def send_report_to_appsignal?(options)
105
115
  puts "\nDiagnostics report"
106
116
  puts " Do you want to send this diagnostics report to AppSignal?"
107
- puts " If you share this diagnostics report you will be given\n" \
108
- " a support token you can use to refer to your diagnotics \n" \
109
- " report when you contact us at support@appsignal.com\n\n"
110
- send_diagnostics = yes_or_no(
111
- " Send diagnostics report to AppSignal? (Y/n): ",
112
- :default => "y"
113
- )
117
+ puts " If you share this report you will be given a link to \n" \
118
+ " AppSignal.com to validate the report.\n" \
119
+ " You can also contact us at support@appsignal.com\n" \
120
+ " with your support token.\n\n"
121
+ send_diagnostics =
122
+ if options.key?(:send_report)
123
+ if options[:send_report]
124
+ puts " Confirmed sending report using --send-report option."
125
+ true
126
+ else
127
+ puts " Not sending report. (Specified with the --no-send-report option.)"
128
+ false
129
+ end
130
+ else
131
+ yes_or_no(
132
+ " Send diagnostics report to AppSignal? (Y/n): ",
133
+ :default => "y"
134
+ )
135
+ end
114
136
  unless send_diagnostics
115
137
  puts " Not sending diagnostics information to AppSignal."
116
138
  return false
@@ -119,7 +141,7 @@ module Appsignal
119
141
  end
120
142
 
121
143
  def transmit_report_to_appsignal
122
- puts "\n Transmitting diagnostics report"
144
+ puts " Transmitting diagnostics report"
123
145
  transmitter = Transmitter.new(
124
146
  DIAGNOSE_ENDPOINT,
125
147
  Appsignal.config
@@ -134,11 +156,10 @@ module Appsignal
134
156
  return
135
157
  end
136
158
 
137
- puts " Please email us at support@appsignal.com with the following"
138
- puts " support token."
139
159
  begin
140
160
  response_data = JSON.parse(response.body)
141
- puts " Your support token: #{response_data["token"]}"
161
+ puts "\n Your support token: #{response_data["token"]}"
162
+ puts " View this report: https://appsignal.com/diagnose/#{response_data["token"]}"
142
163
  rescue JSON::ParserError
143
164
  puts " Error: Couldn't decode server response."
144
165
  puts " #{response.body}"
@@ -171,6 +192,8 @@ module Appsignal
171
192
  initial_config
172
193
  )
173
194
  Appsignal.config.write_to_environment
195
+ Appsignal.start_logger
196
+ Appsignal.logger.info("Starting AppSignal diagnose")
174
197
  end
175
198
 
176
199
  def run_agent_diagnose_mode
@@ -205,11 +228,12 @@ module Appsignal
205
228
  return
206
229
  end
207
230
 
208
- agent_diagnostic_test_definition.each do |part, categories|
209
- categories.each do |category, tests|
231
+ agent_diagnostic_test_definition.each do |component, component_definition|
232
+ puts " #{component_definition[:label]}"
233
+ component_definition[:tests].each do |category, tests|
210
234
  tests.each do |test_name, test_definition|
211
235
  test_report = report
212
- .fetch(part, {})
236
+ .fetch(component, {})
213
237
  .fetch(category, {})
214
238
  .fetch(test_name, {})
215
239
 
@@ -224,47 +248,63 @@ module Appsignal
224
248
  error = test["error"]
225
249
  output = test["output"]
226
250
 
227
- print " #{definition[:label]}: "
228
- display_value = definition[:values][value]
251
+ print " #{definition[:label]}: "
252
+ display_value =
253
+ definition[:values] ? definition[:values][value] : value
229
254
  print display_value.nil? ? "-" : display_value
230
- print "\n Error: #{error}" if error
231
- print "\n Output: #{output}" if output
255
+ print "\n Error: #{error}" if error
256
+ print "\n Output: #{output}" if output
232
257
  print "\n"
233
258
  end
234
259
 
235
260
  def agent_diagnostic_test_definition
236
261
  {
237
262
  "extension" => {
238
- "config" => {
239
- "valid" => {
240
- :label => "Extension config",
241
- :values => { true => "valid", false => "invalid" }
263
+ :label => "Extension tests",
264
+ :tests => {
265
+ "config" => {
266
+ "valid" => {
267
+ :label => "Configuration",
268
+ :values => { true => "valid", false => "invalid" }
269
+ }
242
270
  }
243
271
  }
244
272
  },
245
273
  "agent" => {
246
- "boot" => {
247
- "started" => {
248
- :label => "Agent started",
249
- :values => { true => "started", false => "not started" }
250
- }
251
- },
252
- "config" => {
253
- "valid" => {
254
- :label => "Agent config",
255
- :values => { true => "valid", false => "invalid" }
256
- }
257
- },
258
- "logger" => {
259
- "started" => {
260
- :label => "Agent logger",
261
- :values => { true => "started", false => "not started" }
262
- }
263
- },
264
- "lock_path" => {
265
- "created" => {
266
- :label => "Agent lock path",
267
- :values => { true => "writable", false => "not writable" }
274
+ :label => "Agent tests",
275
+ :tests => {
276
+ "boot" => {
277
+ "started" => {
278
+ :label => "Started",
279
+ :values => { true => "started", false => "not started" }
280
+ }
281
+ },
282
+ "host" => {
283
+ "uid" => { :label => "Process user id" },
284
+ "gid" => { :label => "Process user group id" }
285
+ },
286
+ "config" => {
287
+ "valid" => {
288
+ :label => "Configuration",
289
+ :values => { true => "valid", false => "invalid" }
290
+ }
291
+ },
292
+ "logger" => {
293
+ "started" => {
294
+ :label => "Logger",
295
+ :values => { true => "started", false => "not started" }
296
+ }
297
+ },
298
+ "working_directory_stat" => {
299
+ "uid" => { :label => "Working directory user id" },
300
+ "gid" => { :label => "Working directory user group id" },
301
+ "mode" => { :label => "Working directory permissions" }
302
+ },
303
+ "lock_path" => {
304
+ "created" => {
305
+ :label => "Lock path",
306
+ :values => { true => "writable", false => "not writable" }
307
+ }
268
308
  }
269
309
  }
270
310
  }
@@ -276,7 +316,7 @@ module Appsignal
276
316
  puts "=" * 80
277
317
  puts "Use this information to debug your configuration."
278
318
  puts "More information is available on the documentation site."
279
- puts "http://docs.appsignal.com/"
319
+ puts "https://docs.appsignal.com/"
280
320
  puts "Send this output to support@appsignal.com if you need help."
281
321
  puts "=" * 80
282
322
  end
@@ -289,7 +329,6 @@ module Appsignal
289
329
  puts_and_save :agent_version, "Agent version", Appsignal::Extension.agent_version
290
330
  puts_and_save :agent_architecture, "Agent architecture",
291
331
  Appsignal::System.installed_agent_architecture
292
- puts_and_save :package_install_path, "Gem install path", gem_path
293
332
  puts_and_save :extension_loaded, "Extension loaded", Appsignal.extension_loaded
294
333
  end
295
334
  end
@@ -319,75 +358,87 @@ module Appsignal
319
358
  end
320
359
  end
321
360
 
322
- def config
361
+ def print_config_section
323
362
  puts "Configuration"
324
- data_section :config do
325
- puts_environment
326
-
327
- Appsignal.config.config_hash.each do |key, value|
328
- puts_and_save key, key, value
329
- end
363
+ config = Appsignal.config
364
+ data[:config] = {
365
+ :options => config.config_hash.merge(:env => config.env),
366
+ :sources => {
367
+ :default => Appsignal::Config::DEFAULT_CONFIG,
368
+ :system => config.system_config,
369
+ :initial => config.initial_config,
370
+ :file => config.file_config,
371
+ :env => config.env_config
372
+ }
373
+ }
374
+ print_environment(config)
375
+ print_config_options(config)
376
+ end
377
+
378
+ def print_environment(config)
379
+ env = config.env
380
+ option = :env
381
+ option_sources = sources_for_option(option)
382
+ sources_label = config_sources_label(option, option_sources)
383
+ print " Environment: #{format_config_option(env)}"
384
+
385
+ if env == ""
386
+ puts "\n Warning: No environment set, no config loaded!"
387
+ puts " Please make sure appsignal diagnose is run within your "
388
+ puts " project directory with an environment."
389
+ puts " appsignal diagnose --environment=production"
390
+ else
391
+ puts sources_label
330
392
  end
331
393
  end
332
394
 
333
- def puts_environment
334
- env = Appsignal.config.env
335
- puts_and_save :env, "Environment", env
395
+ def print_config_options(config)
396
+ config.config_hash.each do |key, value|
397
+ option_sources = sources_for_option(key)
398
+ sources_label = config_sources_label(key, option_sources)
399
+ puts " #{key}: #{format_config_option(value)}#{sources_label}"
400
+ end
336
401
 
337
- return unless env == ""
338
- puts " Warning: No environment set, no config loaded!"
339
- puts " Please make sure appsignal diagnose is run within your "
340
- puts " project directory with an environment."
341
- puts " appsignal diagnose --environment=production"
402
+ puts "\nRead more about how the diagnose config output is rendered\n"\
403
+ "https://docs.appsignal.com/ruby/command-line/diagnose.html"
342
404
  end
343
405
 
344
- def paths_section
345
- puts "Paths"
346
- data[:process] = process_user
347
- data_section :paths do
348
- appsignal_paths.each do |name, path|
349
- path_info = {
350
- :path => path,
351
- :configured => !path.nil?,
352
- :exists => false,
353
- :writable => false
354
- }
355
- save name, path_info
356
-
357
- puts_value name, path.to_s.inspect
406
+ def sources_for_option(option)
407
+ config_sources = data[:config][:sources]
408
+ [].tap do |option_sources|
409
+ config_sources.each do |source, c|
410
+ option_sources << source if c.key?(option)
411
+ end
412
+ end
413
+ end
358
414
 
359
- unless path_info[:configured]
360
- puts_value "Configured?", "false", :level => 2
361
- next
362
- end
363
- unless File.exist?(path)
364
- puts_value "Exists?", "false", :level => 2
365
- next
415
+ def config_sources_label(option, sources)
416
+ return if sources == [:default]
417
+ if sources.length == 1
418
+ " (Loaded from: #{sources.join(", ")})"
419
+ elsif sources.any?
420
+ ["\n Sources:"].tap do |a|
421
+ max_source_length = sources.map(&:length).max + 1 # 1 is for ":"
422
+ sources.each do |source|
423
+ source_label = "#{source}:".ljust(max_source_length)
424
+ value = data[:config][:sources][source][option]
425
+ a << " #{source_label} #{format_config_option(value)}"
366
426
  end
367
-
368
- path_info[:exists] = true
369
- path_info[:writable] = File.writable?(path)
370
- puts_value "Writable?", path_info[:writable], :level => 2
371
-
372
- file_owner = path_ownership(path)
373
- path_info[:ownership] = file_owner
374
- save name, path_info
375
-
376
- owned = process_user[:uid] == file_owner[:uid]
377
- owner = "#{owned} " \
378
- "(file: #{file_owner[:user]}:#{file_owner[:uid]}, " \
379
- "process: #{process_user[:user]}:#{process_user[:uid]})"
380
- puts_value "Ownership?", owner, :level => 2
381
- end
427
+ end.join("\n")
428
+ else
429
+ " (Not configured)"
382
430
  end
383
431
  end
384
432
 
385
- def path_ownership(path)
386
- file_uid = File.stat(path).uid
387
- {
388
- :uid => file_uid,
389
- :user => username_for_uid(file_uid)
390
- }
433
+ def format_config_option(value)
434
+ case value
435
+ when NilClass
436
+ "nil"
437
+ when String
438
+ value.inspect
439
+ else
440
+ value
441
+ end
391
442
  end
392
443
 
393
444
  def process_user
@@ -396,18 +447,7 @@ module Appsignal
396
447
  process_uid = Process.uid
397
448
  @process_user = {
398
449
  :uid => process_uid,
399
- :user => username_for_uid(process_uid)
400
- }
401
- end
402
-
403
- def appsignal_paths
404
- config = Appsignal.config
405
- log_file_path = config.log_file_path
406
- {
407
- :working_dir => Dir.pwd,
408
- :root_path => config.root_path,
409
- :log_dir_path => log_file_path ? File.dirname(log_file_path) : "",
410
- :log_file_path => log_file_path
450
+ :user => Utils.username_for_uid(process_uid)
411
451
  }
412
452
  end
413
453
 
@@ -429,58 +469,37 @@ module Appsignal
429
469
  end
430
470
  end
431
471
 
432
- def log_files
433
- puts "Log files"
434
- data_section :logs do
435
- install_log
436
- empty_line
437
- mkmf_log
472
+ def print_paths_section(report)
473
+ puts "Paths"
474
+ report_paths = report.paths
475
+ data[:paths].each do |name, file|
476
+ print_path_details report_paths[name][:label], file
438
477
  end
439
478
  end
440
479
 
441
- def install_log
442
- puts " Extension install log"
443
- filename = File.join("ext", "install.log")
444
- log_info = log_file_info(File.join(gem_path, filename))
445
- save filename, log_info
446
- puts_log_file log_info
447
- end
448
-
449
- def mkmf_log
450
- puts " Makefile install log"
451
- filename = File.join("ext", "mkmf.log")
452
- log_info = log_file_info(File.join(gem_path, filename))
453
- save filename, log_info
454
- puts_log_file log_info
455
- end
480
+ def print_path_details(name, path)
481
+ puts " #{name}"
482
+ puts_value "Path", path[:path].to_s.inspect, :level => 2
456
483
 
457
- def log_file_info(log_file)
458
- {
459
- :path => log_file,
460
- :exists => File.exist?(log_file)
461
- }.tap do |info|
462
- next unless info[:exists]
463
- info[:content] = File.read(log_file).split("\n")
484
+ unless path[:exists]
485
+ puts_value "Exists?", path[:exists], :level => 2
486
+ return
464
487
  end
465
- end
466
488
 
467
- def puts_log_file(log_info)
468
- puts_value "Path", log_info[:path].to_s.inspect, :level => 2
469
- if log_info[:exists]
470
- puts " Contents:"
471
- puts log_info[:content].join("\n")
472
- else
473
- puts " File not found."
474
- end
475
- end
489
+ puts_value "Writable?", path[:writable], :level => 2
476
490
 
477
- def username_for_uid(uid)
478
- passwd_struct = Etc.getpwuid(uid)
479
- return unless passwd_struct
480
- passwd_struct.name
491
+ ownership = path[:ownership]
492
+ owned = process_user[:uid] == ownership[:uid]
493
+ owner = "#{owned} " \
494
+ "(file: #{ownership[:user]}:#{ownership[:uid]}, " \
495
+ "process: #{process_user[:user]}:#{process_user[:uid]})"
496
+ puts_value "Ownership?", owner, :level => 2
497
+ return unless path.key?(:content)
498
+ puts " Contents (last 10 lines):"
499
+ puts path[:content].last(10)
481
500
  end
482
501
 
483
- def empty_line
502
+ def print_empty_line
484
503
  puts "\n"
485
504
  end
486
505
 
@@ -491,11 +510,6 @@ module Appsignal
491
510
  rescue LoadError
492
511
  false
493
512
  end
494
-
495
- def gem_path
496
- @gem_path ||= \
497
- Bundler::CLI::Common.select_spec("appsignal").full_gem_path.strip
498
- end
499
513
  end
500
514
  end
501
515
  end