alacrity-rails 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/alacrity-rails.rb +1 -1
- data/lib/alacrity-rails/diagnostic.rb +92 -0
- data/lib/alacrity-rails/version.rb +1 -1
- data/lib/tasks/diagnostic.rake +8 -0
- metadata +5 -5
- data/lib/alacrity-rails/connection_tester.rb +0 -55
- data/lib/tasks/test_connection.rake +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58e658428b282d216168227c976cacf6e5c59eb8
|
4
|
+
data.tar.gz: 876cce8bbef6fa0aec2d731ab399789553838eb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4245addabe189a55fdbb0d5855fd7adc13a61c75e9b00eaa8f72526d35c15322deecbf8f7d5fc68fe177df833a340cd662c93b72de8bc593d10f4913d7185739
|
7
|
+
data.tar.gz: e98059154aa4aa71e622b12eb55a8f11e0754ce91ceaac0d687a716df44000ec54ad73ade80da93dfc3164ca4e63e4ad8d2200098ca5648ff62446297b4195c6
|
data/lib/alacrity-rails.rb
CHANGED
@@ -5,8 +5,8 @@ end
|
|
5
5
|
|
6
6
|
module AlacrityRails
|
7
7
|
autoload :Config, 'alacrity-rails/config'
|
8
|
-
autoload :ConnectionTester, 'alacrity-rails/connection_tester'
|
9
8
|
autoload :Client, 'alacrity-rails/client'
|
9
|
+
autoload :Diagnostic, 'alacrity-rails/diagnostic'
|
10
10
|
autoload :Middleware, 'alacrity-rails/middleware'
|
11
11
|
autoload :ServerConfig, 'alacrity-rails/server_config'
|
12
12
|
autoload :VERSION, 'alacrity-rails/version'
|
@@ -0,0 +1,92 @@
|
|
1
|
+
module AlacrityRails
|
2
|
+
class Diagnostic
|
3
|
+
def self.run; new.run end
|
4
|
+
|
5
|
+
def logger; @logger ||= Logger.new(STDOUT) end
|
6
|
+
|
7
|
+
def run
|
8
|
+
run_check :api_token_present
|
9
|
+
run_check :valid_api_token
|
10
|
+
run_check :middleware_present
|
11
|
+
run_check :middleware_appears_first
|
12
|
+
|
13
|
+
puts success_message
|
14
|
+
puts assistance_message
|
15
|
+
end
|
16
|
+
|
17
|
+
def run_check(check_name)
|
18
|
+
logger << "CHECK: #{check_name.to_s.humanize}..."
|
19
|
+
|
20
|
+
successful, display_message = public_send(check_name)
|
21
|
+
|
22
|
+
if successful
|
23
|
+
logger << "PASSED\n"
|
24
|
+
else
|
25
|
+
logger << "FAILED\n"
|
26
|
+
logger << display_message
|
27
|
+
logger << assistance_message
|
28
|
+
exit
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def api_token_present
|
33
|
+
[
|
34
|
+
Config.api_token.present?,
|
35
|
+
%<
|
36
|
+
The API token could not be found in the server environment.
|
37
|
+
|
38
|
+
You can find it on https://alacrityapp.com then set it in your server config as `ALACRITY_API_TOKEN`.
|
39
|
+
>
|
40
|
+
]
|
41
|
+
end
|
42
|
+
|
43
|
+
def valid_api_token
|
44
|
+
response = Client.transmit(Transaction::ConnectionTest.new)
|
45
|
+
|
46
|
+
[
|
47
|
+
response.code == '200',
|
48
|
+
%<
|
49
|
+
Oh no! Its seems like we have a problem!
|
50
|
+
|
51
|
+
#{JSON.parse(response.body)['message']}
|
52
|
+
>
|
53
|
+
]
|
54
|
+
end
|
55
|
+
|
56
|
+
def middleware_present
|
57
|
+
[
|
58
|
+
Rails.application.config.middleware.include?(AlacrityRails::Middleware),
|
59
|
+
%<
|
60
|
+
The AlacrityRails::Middleware is absent from your middleware stack.
|
61
|
+
Make sure your application is not overriding the middleware stack in an initializer.
|
62
|
+
>
|
63
|
+
]
|
64
|
+
end
|
65
|
+
|
66
|
+
def middleware_appears_first
|
67
|
+
[
|
68
|
+
Rails.application.config.middleware.first == (AlacrityRails::Middleware),
|
69
|
+
%<
|
70
|
+
The AlacrityRails::Middleware is not first in your middleware stack.
|
71
|
+
Anything appearing above it will not be included in metrics tracking.
|
72
|
+
|
73
|
+
#{Rails.application.config.middleware.map(&:to_s).to_yaml}
|
74
|
+
>
|
75
|
+
]
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
def success_message
|
81
|
+
%<
|
82
|
+
Everything looks good!
|
83
|
+
|
84
|
+
You should see data on https://alacrityapp.com shortly after your app receives traffic.
|
85
|
+
>
|
86
|
+
end
|
87
|
+
|
88
|
+
def assistance_message
|
89
|
+
"\nIf you need assistance or have any questions, send an email to support@alacrityapp.com or tweet @alacrityapp and we'll help you out!\n"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alacrity-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alacrity, LLC
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04
|
11
|
+
date: 2017-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -37,7 +37,7 @@ files:
|
|
37
37
|
- lib/alacrity-rails.rb
|
38
38
|
- lib/alacrity-rails/client.rb
|
39
39
|
- lib/alacrity-rails/config.rb
|
40
|
-
- lib/alacrity-rails/
|
40
|
+
- lib/alacrity-rails/diagnostic.rb
|
41
41
|
- lib/alacrity-rails/middleware.rb
|
42
42
|
- lib/alacrity-rails/probe/action_controller.rb
|
43
43
|
- lib/alacrity-rails/probe/action_view.rb
|
@@ -52,7 +52,7 @@ files:
|
|
52
52
|
- lib/alacrity-rails/transaction/server_startup.rb
|
53
53
|
- lib/alacrity-rails/transaction/web_transaction.rb
|
54
54
|
- lib/alacrity-rails/version.rb
|
55
|
-
- lib/tasks/
|
55
|
+
- lib/tasks/diagnostic.rake
|
56
56
|
homepage: https://www.alacrityapp.com
|
57
57
|
licenses:
|
58
58
|
- GPL
|
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
73
|
version: '0'
|
74
74
|
requirements: []
|
75
75
|
rubyforge_project:
|
76
|
-
rubygems_version: 2.
|
76
|
+
rubygems_version: 2.6.8
|
77
77
|
signing_key:
|
78
78
|
specification_version: 4
|
79
79
|
summary: Rails Agent for the Alacrity Application Health Platform
|
@@ -1,55 +0,0 @@
|
|
1
|
-
module AlacrityRails
|
2
|
-
class ConnectionTester
|
3
|
-
def self.run; new.run end
|
4
|
-
|
5
|
-
def run
|
6
|
-
if Config.api_token.blank?
|
7
|
-
puts missing_api_token_message
|
8
|
-
else
|
9
|
-
response = Client.transmit(Transaction::ConnectionTest.new)
|
10
|
-
|
11
|
-
if response.code == '200'
|
12
|
-
puts success_message
|
13
|
-
else
|
14
|
-
puts bad_response_message(JSON.parse(response.body)['message'])
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
puts assistance_message
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def missing_api_token_message
|
24
|
-
%<
|
25
|
-
Your API token could not be found in the configuration. You can find it on https://alacrityapp.com.
|
26
|
-
|
27
|
-
Then add it to your server's environment as `ALACRITY_API_TOKEN`
|
28
|
-
|
29
|
-
OR
|
30
|
-
|
31
|
-
Set it manually with an initializer (config/alacrity.rb)
|
32
|
-
AlacrityRails::Config.api_token = 'your token'>
|
33
|
-
end
|
34
|
-
|
35
|
-
def bad_response_message(server_message)
|
36
|
-
%<
|
37
|
-
Oh no! Its seems like we have a problem!
|
38
|
-
|
39
|
-
#{server_message}>
|
40
|
-
end
|
41
|
-
|
42
|
-
def success_message
|
43
|
-
%<
|
44
|
-
Everything looks good!
|
45
|
-
|
46
|
-
You should see data on https://alacrityapp.com shortly after your app receives traffic.>
|
47
|
-
end
|
48
|
-
|
49
|
-
def assistance_message
|
50
|
-
%<
|
51
|
-
If you need assistance or have any questions, send an email to support@alacrityapp.com or tweet @alacrityapp and we'll help you out!
|
52
|
-
>
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|