netuitive_rails_agent 0.9.2 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/config/agent.yml +0 -1
- data/lib/netuitive/action_controller.rb +65 -11
- data/lib/netuitive/action_mailer.rb +14 -2
- data/lib/netuitive/action_view.rb +20 -8
- data/lib/netuitive/active_job.rb +20 -8
- data/lib/netuitive/active_record.rb +21 -9
- data/lib/netuitive/active_support.rb +35 -5
- data/lib/netuitive/rails_config_manager.rb +49 -38
- data/lib/netuitive_rails_agent.rb +3 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3ae66dcd7a6e3ef12ca9e9c6dd8d2a1ea3cf4f2
|
4
|
+
data.tar.gz: b9c397490b14af33c021945a9a40aaa79c414642
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c771f4154017ebadb436b61633eb446aa0c6bd1f0ab7c01910d19411f2a97e6746f868c615219a6294bf07903ec2e1def5a08ae065d54830c3e0d76a94b6880
|
7
|
+
data.tar.gz: 638a8f083f936ab6d0d0b7caed8423edf4cf712dedf095415fe9fd82b3eb68c62da304d23a362219c4178968a641bddfde0457b69e110263b1d3df73790f3f8b
|
data/config/agent.yml
CHANGED
@@ -9,33 +9,87 @@ module NetuitiveActionControllerSub
|
|
9
9
|
host = "host:#{ENV['INSTRUMENTATION_HOSTNAME']}"
|
10
10
|
status = event.payload[:status]
|
11
11
|
tags = [controller, action, format, host]
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
begin
|
13
|
+
NetuitiveRubyAPI::netuitivedServer.addSample("#{controller}.#{action}.request.total_duration", event.duration)
|
14
|
+
NetuitiveRubyAPI::netuitivedServer.addSample("#{controller}.#{action}.request.query_time", event.payload[:db_runtime])
|
15
|
+
NetuitiveRubyAPI::netuitivedServer.addSample("#{controller}.#{action}.request.view_time", event.payload[:view_runtime])
|
16
|
+
rescue
|
17
|
+
if ConfigManager.isError?
|
18
|
+
puts "failure to communicate to netuitived"
|
19
|
+
end
|
20
|
+
end
|
15
21
|
end
|
16
22
|
ActiveSupport::Notifications.subscribe /write_fragment.action_controller/ do |*args|
|
17
|
-
|
23
|
+
begin
|
24
|
+
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_controller.write_fragment", 1)
|
25
|
+
rescue
|
26
|
+
if ConfigManager.isError?
|
27
|
+
puts "failure to communicate to netuitived"
|
28
|
+
end
|
29
|
+
end
|
18
30
|
end
|
19
31
|
ActiveSupport::Notifications.subscribe /read_fragment.action_controller/ do |*args|
|
20
|
-
|
32
|
+
begin
|
33
|
+
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_controller.read_fragment", 1)
|
34
|
+
rescue
|
35
|
+
if ConfigManager.isError?
|
36
|
+
puts "failure to communicate to netuitived"
|
37
|
+
end
|
38
|
+
end
|
21
39
|
end
|
22
40
|
ActiveSupport::Notifications.subscribe /expire_fragment.action_controller/ do |*args|
|
23
|
-
|
41
|
+
begin
|
42
|
+
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_controller.expire_fragment", 1)
|
43
|
+
rescue
|
44
|
+
if ConfigManager.isError?
|
45
|
+
puts "failure to communicate to netuitived"
|
46
|
+
end
|
47
|
+
end
|
24
48
|
end
|
25
49
|
ActiveSupport::Notifications.subscribe /write_page.action_controller/ do |*args|
|
26
|
-
|
50
|
+
begin
|
51
|
+
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_controller.write_page", 1)
|
52
|
+
rescue
|
53
|
+
if ConfigManager.isError?
|
54
|
+
puts "failure to communicate to netuitived"
|
55
|
+
end
|
56
|
+
end
|
27
57
|
end
|
28
58
|
ActiveSupport::Notifications.subscribe /expire_page.action_controller/ do |*args|
|
29
|
-
|
59
|
+
begin
|
60
|
+
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_controller.expire_page", 1)
|
61
|
+
rescue
|
62
|
+
if ConfigManager.isError?
|
63
|
+
puts "failure to communicate to netuitived"
|
64
|
+
end
|
65
|
+
end
|
30
66
|
end
|
31
67
|
ActiveSupport::Notifications.subscribe /send_file.action_controller/ do |*args|
|
32
|
-
|
68
|
+
begin
|
69
|
+
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_controller.sent_file", 1)
|
70
|
+
rescue
|
71
|
+
if ConfigManager.isError?
|
72
|
+
puts "failure to communicate to netuitived"
|
73
|
+
end
|
74
|
+
end
|
33
75
|
end
|
34
76
|
ActiveSupport::Notifications.subscribe /redirect_to.action_controller/ do |*args|
|
35
|
-
|
77
|
+
begin
|
78
|
+
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_controller.redirect", 1)
|
79
|
+
rescue
|
80
|
+
if ConfigManager.isError?
|
81
|
+
puts "failure to communicate to netuitived"
|
82
|
+
end
|
83
|
+
end
|
36
84
|
end
|
37
85
|
ActiveSupport::Notifications.subscribe /halted_callback.action_controller/ do |*args|
|
38
|
-
|
86
|
+
begin
|
87
|
+
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_controller.halted_callback", 1)
|
88
|
+
rescue
|
89
|
+
if ConfigManager.isError?
|
90
|
+
puts "failure to communicate to netuitived"
|
91
|
+
end
|
92
|
+
end
|
39
93
|
end
|
40
94
|
end
|
41
95
|
end
|
@@ -3,12 +3,24 @@ module NetuitiveActionMailer
|
|
3
3
|
ActiveSupport::Notifications.subscribe /receive.action_mailer/ do |*args|
|
4
4
|
event = ActiveSupport::Notifications::Event.new(*args)
|
5
5
|
mailer = "#{event.payload[:mailer]}"
|
6
|
-
|
6
|
+
begin
|
7
|
+
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_mailer.#{mailer}.receive", 1)
|
8
|
+
rescue
|
9
|
+
if ConfigManager.isError?
|
10
|
+
puts "failure to communicate to netuitived"
|
11
|
+
end
|
12
|
+
end
|
7
13
|
end
|
8
14
|
ActiveSupport::Notifications.subscribe /deliver.action_mailer/ do |*args|
|
9
15
|
event = ActiveSupport::Notifications::Event.new(*args)
|
10
16
|
mailer = "#{event.payload[:mailer]}"
|
11
|
-
|
17
|
+
begin
|
18
|
+
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_mailer.#{mailer}.deliver", 1)
|
19
|
+
rescue
|
20
|
+
if ConfigManager.isError?
|
21
|
+
puts "failure to communicate to netuitived"
|
22
|
+
end
|
23
|
+
end
|
12
24
|
end
|
13
25
|
end
|
14
26
|
end
|
@@ -1,10 +1,22 @@
|
|
1
1
|
module NetuitiveActionViewSub
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
2
|
+
def self.subscribe
|
3
|
+
ActiveSupport::Notifications.subscribe /render_template.action_view/ do |*args|
|
4
|
+
begin
|
5
|
+
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_view.render_template", 1)
|
6
|
+
rescue
|
7
|
+
if ConfigManager.isError?
|
8
|
+
puts "failure to communicate to netuitived"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
ActiveSupport::Notifications.subscribe /render_partial.action_view/ do |*args|
|
13
|
+
begin
|
14
|
+
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_view.render_partial", 1)
|
15
|
+
rescue
|
16
|
+
if ConfigManager.isError?
|
17
|
+
puts "failure to communicate to netuitived"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
10
22
|
end
|
data/lib/netuitive/active_job.rb
CHANGED
@@ -1,10 +1,22 @@
|
|
1
1
|
module NetuitiveActiveJobSub
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
2
|
+
def self.subscribe
|
3
|
+
ActiveSupport::Notifications.subscribe /enqueue.active_job/ do |*args|
|
4
|
+
begin
|
5
|
+
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("active_job.enqueue", 1)
|
6
|
+
rescue
|
7
|
+
if ConfigManager.isError?
|
8
|
+
puts "failure to communicate to netuitived"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
ActiveSupport::Notifications.subscribe /perform.active_job/ do |*args|
|
13
|
+
begin
|
14
|
+
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("active_job.perform", 1)
|
15
|
+
rescue
|
16
|
+
if ConfigManager.isError?
|
17
|
+
puts "failure to communicate to netuitived"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
10
22
|
end
|
@@ -1,11 +1,23 @@
|
|
1
1
|
module NetuitiveActiveRecordSub
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
2
|
+
def self.subscribe
|
3
|
+
ActiveSupport::Notifications.subscribe /instantiation.active_record/ do |*args|
|
4
|
+
begin
|
5
|
+
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("active_record.instantiation", 1)
|
6
|
+
rescue
|
7
|
+
if ConfigManager.isError?
|
8
|
+
puts "failure to communicate to netuitived"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
ActiveSupport::Notifications.subscribe /sql.active_record/ do |*args|
|
14
|
+
begin
|
15
|
+
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("active_record.sql.statement", 1)
|
16
|
+
rescue
|
17
|
+
if ConfigManager.isError?
|
18
|
+
puts "failure to communicate to netuitived"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
11
23
|
end
|
@@ -1,19 +1,49 @@
|
|
1
1
|
module NetuitiveActiveSupportSub
|
2
2
|
def self.subscribe
|
3
3
|
ActiveSupport::Notifications.subscribe /cache_read.active_support/ do |*args|
|
4
|
-
|
4
|
+
begin
|
5
|
+
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("active_support.cache_read", 1)
|
6
|
+
rescue
|
7
|
+
if ConfigManager.isError?
|
8
|
+
puts "failure to communicate to netuitived"
|
9
|
+
end
|
10
|
+
end
|
5
11
|
end
|
6
12
|
ActiveSupport::Notifications.subscribe /cache_generate.active_support/ do |*args|
|
7
|
-
|
13
|
+
begin
|
14
|
+
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("active_support.cache_generate", 1)
|
15
|
+
rescue
|
16
|
+
if ConfigManager.isError?
|
17
|
+
puts "failure to communicate to netuitived"
|
18
|
+
end
|
19
|
+
end
|
8
20
|
end
|
9
21
|
ActiveSupport::Notifications.subscribe /cache_fetch_hit.active_support/ do |*args|
|
10
|
-
|
22
|
+
begin
|
23
|
+
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("active_support.cache_fetch_hit", 1)
|
24
|
+
rescue
|
25
|
+
if ConfigManager.isError?
|
26
|
+
puts "failure to communicate to netuitived"
|
27
|
+
end
|
28
|
+
end
|
11
29
|
end
|
12
30
|
ActiveSupport::Notifications.subscribe /cache_write.active_support/ do |*args|
|
13
|
-
|
31
|
+
begin
|
32
|
+
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("active_support.cache_write", 1)
|
33
|
+
rescue
|
34
|
+
if ConfigManager.isError?
|
35
|
+
puts "failure to communicate to netuitived"
|
36
|
+
end
|
37
|
+
end
|
14
38
|
end
|
15
39
|
ActiveSupport::Notifications.subscribe /cache_delete.active_support/ do |*args|
|
16
|
-
|
40
|
+
begin
|
41
|
+
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("active_support.cache_delete", 1)
|
42
|
+
rescue
|
43
|
+
if ConfigManager.isError?
|
44
|
+
puts "failure to communicate to netuitived"
|
45
|
+
end
|
46
|
+
end
|
17
47
|
end
|
18
48
|
end
|
19
49
|
end
|
@@ -1,51 +1,62 @@
|
|
1
1
|
class ConfigManager
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
class << self
|
4
|
+
def setup()
|
5
|
+
@@error=0
|
6
|
+
@@info=1
|
7
|
+
@@debug=2
|
8
|
+
readConfig()
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
return true
|
11
|
+
def netuitivedAddr
|
12
|
+
@@netuitivedAddr
|
13
13
|
end
|
14
|
-
return false
|
15
|
-
end
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
return true
|
15
|
+
def netuitivedPort
|
16
|
+
@@netuitivedPort
|
20
17
|
end
|
21
|
-
return false
|
22
|
-
end
|
23
18
|
|
24
|
-
|
25
|
-
|
26
|
-
|
19
|
+
def isDebug?
|
20
|
+
if @@debugLevel >= @@debug
|
21
|
+
return true
|
22
|
+
end
|
23
|
+
return false
|
27
24
|
end
|
28
|
-
return false
|
29
|
-
end
|
30
25
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
@debugLevel=@error
|
37
|
-
elsif debugLevelString == "info"
|
38
|
-
@debugLevel=@info
|
39
|
-
elsif debugLevelString == "debug"
|
40
|
-
@debugLevel=@debug
|
41
|
-
else
|
42
|
-
@debugLevel=@error
|
26
|
+
def isInfo?
|
27
|
+
if @@debugLevel >= @@info
|
28
|
+
return true
|
29
|
+
end
|
30
|
+
return false
|
43
31
|
end
|
44
32
|
|
45
|
-
|
46
|
-
|
47
|
-
|
33
|
+
def isError?
|
34
|
+
if @@debugLevel >= @@error
|
35
|
+
return true
|
36
|
+
end
|
37
|
+
return false
|
48
38
|
end
|
49
|
-
end
|
50
39
|
|
51
|
-
|
40
|
+
def readConfig()
|
41
|
+
gem_root= File.expand_path("../../..", __FILE__)
|
42
|
+
data=YAML.load_file "#{gem_root}/config/agent.yml"
|
43
|
+
debugLevelString=data["debugLevel"]
|
44
|
+
if debugLevelString == "error"
|
45
|
+
@@debugLevel=@@error
|
46
|
+
elsif debugLevelString == "info"
|
47
|
+
@@debugLevel=@@info
|
48
|
+
elsif debugLevelString == "debug"
|
49
|
+
@@debugLevel=@@debug
|
50
|
+
else
|
51
|
+
@@debugLevel=@@error
|
52
|
+
end
|
53
|
+
|
54
|
+
if isDebug?
|
55
|
+
puts "read config file. Results:
|
56
|
+
netuitivedAddr: #{@@netuitivedAddr}
|
57
|
+
netuitivedPort: #{@@netuitivedPort}
|
58
|
+
debugLevel: #{debugLevelString}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -6,6 +6,7 @@ require 'netuitive/action_view'
|
|
6
6
|
require 'netuitive/action_mailer'
|
7
7
|
require 'netuitive/active_support'
|
8
8
|
require 'netuitive/active_job'
|
9
|
+
require 'netuitive/rails_config_manager'
|
9
10
|
|
10
11
|
NetuitiveActionControllerSub::subscribe
|
11
12
|
NetuitiveActiveRecordSub::subscribe
|
@@ -13,3 +14,5 @@ NetuitiveActionViewSub::subscribe
|
|
13
14
|
NetuitiveActionMailer::subscribe
|
14
15
|
NetuitiveActiveSupportSub::subscribe
|
15
16
|
NetuitiveActiveJobSub::subscribe
|
17
|
+
|
18
|
+
ConfigManager::setup
|