netuitive_rails_agent 0.10.0 → 1.0.1
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.
- data/README.md +18 -8
- data/config/agent.yml +36 -1
- data/lib/netuitive_rails_agent.rb +43 -17
- data/lib/netuitive_rails_agent/action_controller.rb +97 -0
- data/lib/netuitive_rails_agent/action_mailer.rb +29 -0
- data/lib/netuitive_rails_agent/action_view.rb +25 -0
- data/lib/netuitive_rails_agent/active_job.rb +25 -0
- data/lib/netuitive_rails_agent/active_record.rb +26 -0
- data/lib/netuitive_rails_agent/active_support.rb +46 -0
- data/lib/netuitive_rails_agent/api_interaction.rb +43 -0
- data/lib/netuitive_rails_agent/config_manager.rb +124 -0
- data/lib/netuitive_rails_agent/controller_utils.rb +17 -0
- data/lib/netuitive_rails_agent/error_tracker.rb +33 -0
- data/lib/netuitive_rails_agent/error_utils.rb +41 -0
- data/lib/netuitive_rails_agent/gc.rb +33 -0
- data/lib/netuitive_rails_agent/netuitive_logger.rb +49 -0
- data/lib/netuitive_rails_agent/objectspace.rb +19 -0
- data/lib/netuitive_rails_agent/request_data.rb +50 -0
- data/lib/netuitive_rails_agent/scheduler.rb +44 -0
- data/lib/netuitive_rails_agent/sidekiq.rb +67 -0
- metadata +23 -17
- data/lib/netuitive/action_controller.rb +0 -81
- data/lib/netuitive/action_mailer.rb +0 -22
- data/lib/netuitive/action_view.rb +0 -18
- data/lib/netuitive/active_job.rb +0 -18
- data/lib/netuitive/active_record.rb +0 -19
- data/lib/netuitive/active_support.rb +0 -39
- data/lib/netuitive/gc.rb +0 -23
- data/lib/netuitive/netuitive_rails_logger.rb +0 -24
- data/lib/netuitive/objectspace.rb +0 -13
- data/lib/netuitive/rails_config_manager.rb +0 -29
- data/lib/netuitive/scheduler.rb +0 -23
@@ -1,81 +0,0 @@
|
|
1
|
-
require 'netuitive/netuitive_rails_logger'
|
2
|
-
module NetuitiveActionControllerSub
|
3
|
-
def self.subscribe
|
4
|
-
ActiveSupport::Notifications.subscribe /process_action.action_controller/ do |*args|
|
5
|
-
event = ActiveSupport::Notifications::Event.new(*args)
|
6
|
-
controller = "#{event.payload[:controller]}"
|
7
|
-
action = "#{event.payload[:action]}"
|
8
|
-
format = "format:#{event.payload[:format] || 'all'}"
|
9
|
-
format = "format:all" if format == "format:*/*"
|
10
|
-
host = "host:#{ENV['INSTRUMENTATION_HOSTNAME']}"
|
11
|
-
status = event.payload[:status]
|
12
|
-
tags = [controller, action, format, host]
|
13
|
-
begin
|
14
|
-
NetuitiveRubyAPI::netuitivedServer.addSample("action_controller.#{controller}.#{action}.request.total_duration", event.duration)
|
15
|
-
NetuitiveRubyAPI::netuitivedServer.addSample("action_controller.#{controller}.#{action}.request.query_time", event.payload[:db_runtime])
|
16
|
-
NetuitiveRubyAPI::netuitivedServer.addSample("action_controller.#{controller}.#{action}.request.view_time", event.payload[:view_runtime])
|
17
|
-
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_controller.#{controller}.#{action}.total_requests", 1)
|
18
|
-
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_controller.#{controller}.total_requests", 1)
|
19
|
-
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_controller.total_requests", 1)
|
20
|
-
rescue
|
21
|
-
NetuitiveLogger.log.error "failure to communicate to netuitived"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
ActiveSupport::Notifications.subscribe /write_fragment.action_controller/ do |*args|
|
25
|
-
begin
|
26
|
-
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_controller.write_fragment", 1)
|
27
|
-
rescue
|
28
|
-
NetuitiveLogger.log.error "failure to communicate to netuitived"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
ActiveSupport::Notifications.subscribe /read_fragment.action_controller/ do |*args|
|
32
|
-
begin
|
33
|
-
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_controller.read_fragment", 1)
|
34
|
-
rescue
|
35
|
-
NetuitiveLogger.log.error "failure to communicate to netuitived"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
ActiveSupport::Notifications.subscribe /expire_fragment.action_controller/ do |*args|
|
39
|
-
begin
|
40
|
-
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_controller.expire_fragment", 1)
|
41
|
-
rescue
|
42
|
-
NetuitiveLogger.log.error "failure to communicate to netuitived"
|
43
|
-
end
|
44
|
-
end
|
45
|
-
ActiveSupport::Notifications.subscribe /write_page.action_controller/ do |*args|
|
46
|
-
begin
|
47
|
-
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_controller.write_page", 1)
|
48
|
-
rescue
|
49
|
-
NetuitiveLogger.log.error "failure to communicate to netuitived"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
ActiveSupport::Notifications.subscribe /expire_page.action_controller/ do |*args|
|
53
|
-
begin
|
54
|
-
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_controller.expire_page", 1)
|
55
|
-
rescue
|
56
|
-
NetuitiveLogger.log.error "failure to communicate to netuitived"
|
57
|
-
end
|
58
|
-
end
|
59
|
-
ActiveSupport::Notifications.subscribe /send_file.action_controller/ do |*args|
|
60
|
-
begin
|
61
|
-
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_controller.sent_file", 1)
|
62
|
-
rescue
|
63
|
-
NetuitiveLogger.log.error "failure to communicate to netuitived"
|
64
|
-
end
|
65
|
-
end
|
66
|
-
ActiveSupport::Notifications.subscribe /redirect_to.action_controller/ do |*args|
|
67
|
-
begin
|
68
|
-
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_controller.redirect", 1)
|
69
|
-
rescue
|
70
|
-
NetuitiveLogger.log.error "failure to communicate to netuitived"
|
71
|
-
end
|
72
|
-
end
|
73
|
-
ActiveSupport::Notifications.subscribe /halted_callback.action_controller/ do |*args|
|
74
|
-
begin
|
75
|
-
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_controller.halted_callback", 1)
|
76
|
-
rescue
|
77
|
-
NetuitiveLogger.log.error "failure to communicate to netuitived"
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module NetuitiveActionMailer
|
2
|
-
def self.subscribe
|
3
|
-
ActiveSupport::Notifications.subscribe /receive.action_mailer/ do |*args|
|
4
|
-
event = ActiveSupport::Notifications::Event.new(*args)
|
5
|
-
mailer = "#{event.payload[:mailer]}"
|
6
|
-
begin
|
7
|
-
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_mailer.#{mailer}.receive", 1)
|
8
|
-
rescue
|
9
|
-
NetuitiveLogger.log.error "failure to communicate to netuitived"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
ActiveSupport::Notifications.subscribe /deliver.action_mailer/ do |*args|
|
13
|
-
event = ActiveSupport::Notifications::Event.new(*args)
|
14
|
-
mailer = "#{event.payload[:mailer]}"
|
15
|
-
begin
|
16
|
-
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_mailer.#{mailer}.deliver", 1)
|
17
|
-
rescue
|
18
|
-
NetuitiveLogger.log.error "failure to communicate to netuitived"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module NetuitiveActionViewSub
|
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
|
-
NetuitiveLogger.log.error "failure to communicate to netuitived"
|
8
|
-
end
|
9
|
-
end
|
10
|
-
ActiveSupport::Notifications.subscribe /render_partial.action_view/ do |*args|
|
11
|
-
begin
|
12
|
-
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_view.render_partial", 1)
|
13
|
-
rescue
|
14
|
-
NetuitiveLogger.log.error "failure to communicate to netuitived"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
data/lib/netuitive/active_job.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
module NetuitiveActiveJobSub
|
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
|
-
NetuitiveLogger.log.error "failure to communicate to netuitived"
|
8
|
-
end
|
9
|
-
end
|
10
|
-
ActiveSupport::Notifications.subscribe /perform.active_job/ do |*args|
|
11
|
-
begin
|
12
|
-
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("active_job.perform", 1)
|
13
|
-
rescue
|
14
|
-
NetuitiveLogger.log.error "failure to communicate to netuitived"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module NetuitiveActiveRecordSub
|
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
|
-
NetuitiveLogger.log.error "failure to communicate to netuitived"
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
ActiveSupport::Notifications.subscribe /sql.active_record/ do |*args|
|
12
|
-
begin
|
13
|
-
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("active_record.sql.statement", 1)
|
14
|
-
rescue
|
15
|
-
NetuitiveLogger.log.error "failure to communicate to netuitived"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
module NetuitiveActiveSupportSub
|
2
|
-
def self.subscribe
|
3
|
-
ActiveSupport::Notifications.subscribe /cache_read.active_support/ do |*args|
|
4
|
-
begin
|
5
|
-
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("active_support.cache_read", 1)
|
6
|
-
rescue
|
7
|
-
NetuitiveLogger.log.error "failure to communicate to netuitived"
|
8
|
-
end
|
9
|
-
end
|
10
|
-
ActiveSupport::Notifications.subscribe /cache_generate.active_support/ do |*args|
|
11
|
-
begin
|
12
|
-
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("active_support.cache_generate", 1)
|
13
|
-
rescue
|
14
|
-
NetuitiveLogger.log.error "failure to communicate to netuitived"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
ActiveSupport::Notifications.subscribe /cache_fetch_hit.active_support/ do |*args|
|
18
|
-
begin
|
19
|
-
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("active_support.cache_fetch_hit", 1)
|
20
|
-
rescue
|
21
|
-
NetuitiveLogger.log.error "failure to communicate to netuitived"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
ActiveSupport::Notifications.subscribe /cache_write.active_support/ do |*args|
|
25
|
-
begin
|
26
|
-
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("active_support.cache_write", 1)
|
27
|
-
rescue
|
28
|
-
NetuitiveLogger.log.error "failure to communicate to netuitived"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
ActiveSupport::Notifications.subscribe /cache_delete.active_support/ do |*args|
|
32
|
-
begin
|
33
|
-
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("active_support.cache_delete", 1)
|
34
|
-
rescue
|
35
|
-
NetuitiveLogger.log.error "failure to communicate to netuitived"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
data/lib/netuitive/gc.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
class GCStatsCollector
|
2
|
-
|
3
|
-
def self.collect()
|
4
|
-
if GC::Profiler.enabled?
|
5
|
-
begin
|
6
|
-
GC.stat.each do |key, value|
|
7
|
-
NetuitiveLogger.log.debug "GC stat key: #{key}"
|
8
|
-
if key.to_s == "total_allocated_object" or key.to_s == "total_freed_object" or key.to_s == "count"
|
9
|
-
NetuitiveLogger.log.debug "sending aggregateCounterMetric GC.stat.#{key}"
|
10
|
-
NetuitiveRubyAPI::netuitivedServer.aggregateCounterMetric("GC.stat.#{key}", value)
|
11
|
-
else
|
12
|
-
NetuitiveLogger.log.debug "sending aggregateMetric GC.stat.#{key}"
|
13
|
-
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("GC.stat.#{key}", value)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
NetuitiveLogger.log.debug "sending aggregateCounterMetric GC.profiler.total_time"
|
17
|
-
NetuitiveRubyAPI::netuitivedServer.aggregateCounterMetric("GC.profiler.total_time", GC::Profiler.total_time)
|
18
|
-
rescue
|
19
|
-
NetuitiveLogger.log.error "failure to communicate to netuitived"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'logger'
|
2
|
-
class CheaterLogger
|
3
|
-
attr_accessor :level
|
4
|
-
def debug(message)
|
5
|
-
end
|
6
|
-
def error(message)
|
7
|
-
end
|
8
|
-
def info(message)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
class NetuitiveLogger
|
13
|
-
begin
|
14
|
-
@@log = Logger.new("#{File.expand_path("../../..", __FILE__)}/log/netuitive.log",'daily', 10)
|
15
|
-
rescue
|
16
|
-
puts "netuitive unable to open log file"
|
17
|
-
@@log = CheaterLogger.new
|
18
|
-
end
|
19
|
-
class << self
|
20
|
-
def log
|
21
|
-
return @@log
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
class ObjectSpaceStatsCollector
|
2
|
-
|
3
|
-
def self.collect()
|
4
|
-
begin
|
5
|
-
ObjectSpace.count_objects.each do |key, value|
|
6
|
-
NetuitiveLogger.log.debug "ObjectSpace.count_objects.#{key}"
|
7
|
-
NetuitiveRubyAPI::netuitivedServer.aggregateMetric("ObjectSpace.count_objects.#{key}", value)
|
8
|
-
end
|
9
|
-
rescue
|
10
|
-
NetuitiveLogger.log.error "failure to communicate to netuitived"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'netuitive/netuitive_rails_logger'
|
2
|
-
class ConfigManager
|
3
|
-
|
4
|
-
class << self
|
5
|
-
def setup()
|
6
|
-
readConfig()
|
7
|
-
end
|
8
|
-
|
9
|
-
def readConfig()
|
10
|
-
gem_root= File.expand_path("../../..", __FILE__)
|
11
|
-
data=YAML.load_file "#{gem_root}/config/agent.yml"
|
12
|
-
debugLevelString=ENV["NETUITIVE_RAILS_DEBUG_LEVEL"]
|
13
|
-
if(debugLevelString == nil or debugLevelString == "")
|
14
|
-
debugLevelString=data["debugLevel"]
|
15
|
-
end
|
16
|
-
if debugLevelString == "error"
|
17
|
-
NetuitiveLogger.log.level = Logger::ERROR
|
18
|
-
elsif debugLevelString == "info"
|
19
|
-
NetuitiveLogger.log.level = Logger::INFO
|
20
|
-
elsif debugLevelString == "debug"
|
21
|
-
NetuitiveLogger.log.level = Logger::DEBUG
|
22
|
-
else
|
23
|
-
NetuitiveLogger.log.level = Logger::ERROR
|
24
|
-
end
|
25
|
-
NetuitiveLogger.log.debug "read config file. Results:
|
26
|
-
debugLevel: #{debugLevelString}"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
data/lib/netuitive/scheduler.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'netuitive/netuitive_rails_logger'
|
2
|
-
require 'netuitive/gc'
|
3
|
-
require 'netuitive/objectspace'
|
4
|
-
class Scheduler
|
5
|
-
def self.startSchedule
|
6
|
-
Thread.new do
|
7
|
-
while true do
|
8
|
-
interval = 60
|
9
|
-
begin
|
10
|
-
interval = NetuitiveRubyAPI::netuitivedServer.interval
|
11
|
-
rescue
|
12
|
-
NetuitiveLogger.log.info "unable to retrieve netuitived interval defaulting to 60"
|
13
|
-
end
|
14
|
-
collectMetrics
|
15
|
-
sleep(interval)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
def self.collectMetrics
|
20
|
-
GCStatsCollector::collect
|
21
|
-
ObjectSpaceStatsCollector::collect
|
22
|
-
end
|
23
|
-
end
|