netuitive_rails_agent 0.9.3 → 0.9.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f3ae66dcd7a6e3ef12ca9e9c6dd8d2a1ea3cf4f2
4
- data.tar.gz: b9c397490b14af33c021945a9a40aaa79c414642
3
+ metadata.gz: 6589960bb1e14fd41908bcb7503bfe79e71c8e17
4
+ data.tar.gz: 4841fc9e063a1e9676dc1535030801a00636f700
5
5
  SHA512:
6
- metadata.gz: 4c771f4154017ebadb436b61633eb446aa0c6bd1f0ab7c01910d19411f2a97e6746f868c615219a6294bf07903ec2e1def5a08ae065d54830c3e0d76a94b6880
7
- data.tar.gz: 638a8f083f936ab6d0d0b7caed8423edf4cf712dedf095415fe9fd82b3eb68c62da304d23a362219c4178968a641bddfde0457b69e110263b1d3df73790f3f8b
6
+ metadata.gz: 585dd597e8ae4aceae385c50bffa5200f46e320204e601001de34addc88c16948940fe14b828c1303adae153eed999e0650abde5fa98698efd20ee1c3c4acd3a
7
+ data.tar.gz: 8c3d851eeb2464c6e3516e49a42f2313d1ad38ba820274ccd87d6be29d2f7ea1bbd15d9946c4f5429422db918be50d535416484e61448446b26e25477fd184b5
data/config/agent.yml CHANGED
@@ -1 +1,2 @@
1
- debugLevel: error #options (in ascending order of debugness) are: error, info, debug
1
+ #all are configurable using environment variables
2
+ debugLevel: error #options (in ascending order of debugness) are: error, info, debug. environment variable: NETUITIVE_RAILS_DEBUG_LEVEL
@@ -1,3 +1,4 @@
1
+ require 'netuitive/netuitive_rails_logger'
1
2
  module NetuitiveActionControllerSub
2
3
  def self.subscribe
3
4
  ActiveSupport::Notifications.subscribe /process_action.action_controller/ do |*args|
@@ -14,54 +15,42 @@ module NetuitiveActionControllerSub
14
15
  NetuitiveRubyAPI::netuitivedServer.addSample("#{controller}.#{action}.request.query_time", event.payload[:db_runtime])
15
16
  NetuitiveRubyAPI::netuitivedServer.addSample("#{controller}.#{action}.request.view_time", event.payload[:view_runtime])
16
17
  rescue
17
- if ConfigManager.isError?
18
- puts "failure to communicate to netuitived"
19
- end
18
+ NetuitiveLogger.log.error "failure to communicate to netuitived"
20
19
  end
21
20
  end
22
21
  ActiveSupport::Notifications.subscribe /write_fragment.action_controller/ do |*args|
23
22
  begin
24
23
  NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_controller.write_fragment", 1)
25
24
  rescue
26
- if ConfigManager.isError?
27
- puts "failure to communicate to netuitived"
28
- end
25
+ NetuitiveLogger.log.error "failure to communicate to netuitived"
29
26
  end
30
27
  end
31
28
  ActiveSupport::Notifications.subscribe /read_fragment.action_controller/ do |*args|
32
29
  begin
33
30
  NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_controller.read_fragment", 1)
34
31
  rescue
35
- if ConfigManager.isError?
36
- puts "failure to communicate to netuitived"
37
- end
32
+ NetuitiveLogger.log.error "failure to communicate to netuitived"
38
33
  end
39
34
  end
40
35
  ActiveSupport::Notifications.subscribe /expire_fragment.action_controller/ do |*args|
41
36
  begin
42
37
  NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_controller.expire_fragment", 1)
43
38
  rescue
44
- if ConfigManager.isError?
45
- puts "failure to communicate to netuitived"
46
- end
39
+ NetuitiveLogger.log.error "failure to communicate to netuitived"
47
40
  end
48
41
  end
49
42
  ActiveSupport::Notifications.subscribe /write_page.action_controller/ do |*args|
50
43
  begin
51
44
  NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_controller.write_page", 1)
52
45
  rescue
53
- if ConfigManager.isError?
54
- puts "failure to communicate to netuitived"
55
- end
46
+ NetuitiveLogger.log.error "failure to communicate to netuitived"
56
47
  end
57
48
  end
58
49
  ActiveSupport::Notifications.subscribe /expire_page.action_controller/ do |*args|
59
50
  begin
60
51
  NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_controller.expire_page", 1)
61
52
  rescue
62
- if ConfigManager.isError?
63
- puts "failure to communicate to netuitived"
64
- end
53
+ NetuitiveLogger.log.error "failure to communicate to netuitived"
65
54
  end
66
55
  end
67
56
  ActiveSupport::Notifications.subscribe /send_file.action_controller/ do |*args|
@@ -6,9 +6,7 @@ module NetuitiveActionMailer
6
6
  begin
7
7
  NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_mailer.#{mailer}.receive", 1)
8
8
  rescue
9
- if ConfigManager.isError?
10
- puts "failure to communicate to netuitived"
11
- end
9
+ NetuitiveLogger.log.error "failure to communicate to netuitived"
12
10
  end
13
11
  end
14
12
  ActiveSupport::Notifications.subscribe /deliver.action_mailer/ do |*args|
@@ -17,9 +15,7 @@ module NetuitiveActionMailer
17
15
  begin
18
16
  NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_mailer.#{mailer}.deliver", 1)
19
17
  rescue
20
- if ConfigManager.isError?
21
- puts "failure to communicate to netuitived"
22
- end
18
+ NetuitiveLogger.log.error "failure to communicate to netuitived"
23
19
  end
24
20
  end
25
21
  end
@@ -4,18 +4,14 @@ module NetuitiveActionViewSub
4
4
  begin
5
5
  NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_view.render_template", 1)
6
6
  rescue
7
- if ConfigManager.isError?
8
- puts "failure to communicate to netuitived"
9
- end
7
+ NetuitiveLogger.log.error "failure to communicate to netuitived"
10
8
  end
11
9
  end
12
10
  ActiveSupport::Notifications.subscribe /render_partial.action_view/ do |*args|
13
11
  begin
14
12
  NetuitiveRubyAPI::netuitivedServer.aggregateMetric("action_view.render_partial", 1)
15
13
  rescue
16
- if ConfigManager.isError?
17
- puts "failure to communicate to netuitived"
18
- end
14
+ NetuitiveLogger.log.error "failure to communicate to netuitived"
19
15
  end
20
16
  end
21
17
  end
@@ -4,18 +4,14 @@ module NetuitiveActiveJobSub
4
4
  begin
5
5
  NetuitiveRubyAPI::netuitivedServer.aggregateMetric("active_job.enqueue", 1)
6
6
  rescue
7
- if ConfigManager.isError?
8
- puts "failure to communicate to netuitived"
9
- end
7
+ NetuitiveLogger.log.error "failure to communicate to netuitived"
10
8
  end
11
9
  end
12
10
  ActiveSupport::Notifications.subscribe /perform.active_job/ do |*args|
13
11
  begin
14
12
  NetuitiveRubyAPI::netuitivedServer.aggregateMetric("active_job.perform", 1)
15
13
  rescue
16
- if ConfigManager.isError?
17
- puts "failure to communicate to netuitived"
18
- end
14
+ NetuitiveLogger.log.error "failure to communicate to netuitived"
19
15
  end
20
16
  end
21
17
  end
@@ -4,9 +4,7 @@ module NetuitiveActiveRecordSub
4
4
  begin
5
5
  NetuitiveRubyAPI::netuitivedServer.aggregateMetric("active_record.instantiation", 1)
6
6
  rescue
7
- if ConfigManager.isError?
8
- puts "failure to communicate to netuitived"
9
- end
7
+ NetuitiveLogger.log.error "failure to communicate to netuitived"
10
8
  end
11
9
  end
12
10
 
@@ -14,9 +12,7 @@ module NetuitiveActiveRecordSub
14
12
  begin
15
13
  NetuitiveRubyAPI::netuitivedServer.aggregateMetric("active_record.sql.statement", 1)
16
14
  rescue
17
- if ConfigManager.isError?
18
- puts "failure to communicate to netuitived"
19
- end
15
+ NetuitiveLogger.log.error "failure to communicate to netuitived"
20
16
  end
21
17
  end
22
18
  end
@@ -4,45 +4,35 @@ module NetuitiveActiveSupportSub
4
4
  begin
5
5
  NetuitiveRubyAPI::netuitivedServer.aggregateMetric("active_support.cache_read", 1)
6
6
  rescue
7
- if ConfigManager.isError?
8
- puts "failure to communicate to netuitived"
9
- end
7
+ NetuitiveLogger.log.error "failure to communicate to netuitived"
10
8
  end
11
9
  end
12
10
  ActiveSupport::Notifications.subscribe /cache_generate.active_support/ do |*args|
13
11
  begin
14
12
  NetuitiveRubyAPI::netuitivedServer.aggregateMetric("active_support.cache_generate", 1)
15
13
  rescue
16
- if ConfigManager.isError?
17
- puts "failure to communicate to netuitived"
18
- end
14
+ NetuitiveLogger.log.error "failure to communicate to netuitived"
19
15
  end
20
16
  end
21
17
  ActiveSupport::Notifications.subscribe /cache_fetch_hit.active_support/ do |*args|
22
18
  begin
23
19
  NetuitiveRubyAPI::netuitivedServer.aggregateMetric("active_support.cache_fetch_hit", 1)
24
20
  rescue
25
- if ConfigManager.isError?
26
- puts "failure to communicate to netuitived"
27
- end
21
+ NetuitiveLogger.log.error "failure to communicate to netuitived"
28
22
  end
29
23
  end
30
24
  ActiveSupport::Notifications.subscribe /cache_write.active_support/ do |*args|
31
25
  begin
32
26
  NetuitiveRubyAPI::netuitivedServer.aggregateMetric("active_support.cache_write", 1)
33
27
  rescue
34
- if ConfigManager.isError?
35
- puts "failure to communicate to netuitived"
36
- end
28
+ NetuitiveLogger.log.error "failure to communicate to netuitived"
37
29
  end
38
30
  end
39
31
  ActiveSupport::Notifications.subscribe /cache_delete.active_support/ do |*args|
40
32
  begin
41
33
  NetuitiveRubyAPI::netuitivedServer.aggregateMetric("active_support.cache_delete", 1)
42
34
  rescue
43
- if ConfigManager.isError?
44
- puts "failure to communicate to netuitived"
45
- end
35
+ NetuitiveLogger.log.error "failure to communicate to netuitived"
46
36
  end
47
37
  end
48
38
  end
@@ -0,0 +1,24 @@
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,62 +1,29 @@
1
+ require 'netuitive/netuitive_rails_logger'
1
2
  class ConfigManager
2
3
 
3
4
  class << self
4
5
  def setup()
5
- @@error=0
6
- @@info=1
7
- @@debug=2
8
6
  readConfig()
9
7
  end
10
8
 
11
- def netuitivedAddr
12
- @@netuitivedAddr
13
- end
14
-
15
- def netuitivedPort
16
- @@netuitivedPort
17
- end
18
-
19
- def isDebug?
20
- if @@debugLevel >= @@debug
21
- return true
22
- end
23
- return false
24
- end
25
-
26
- def isInfo?
27
- if @@debugLevel >= @@info
28
- return true
29
- end
30
- return false
31
- end
32
-
33
- def isError?
34
- if @@debugLevel >= @@error
35
- return true
36
- end
37
- return false
38
- end
39
-
40
9
  def readConfig()
41
10
  gem_root= File.expand_path("../../..", __FILE__)
42
11
  data=YAML.load_file "#{gem_root}/config/agent.yml"
43
- debugLevelString=data["debugLevel"]
12
+ debugLevelString=ENV["NETUITIVE_RAILS_DEBUG_LEVEL"]
13
+ if(debugLevelString == nil or debugLevelString == "")
14
+ debugLevelString=data["debugLevel"]
15
+ end
44
16
  if debugLevelString == "error"
45
- @@debugLevel=@@error
17
+ NetuitiveLogger.log.level = Logger::ERROR
46
18
  elsif debugLevelString == "info"
47
- @@debugLevel=@@info
19
+ NetuitiveLogger.log.level = Logger::INFO
48
20
  elsif debugLevelString == "debug"
49
- @@debugLevel=@@debug
21
+ NetuitiveLogger.log.level = Logger::DEBUG
50
22
  else
51
- @@debugLevel=@@error
23
+ NetuitiveLogger.log.level = Logger::ERROR
52
24
  end
53
-
54
- if isDebug?
55
- puts "read config file. Results:
56
- netuitivedAddr: #{@@netuitivedAddr}
57
- netuitivedPort: #{@@netuitivedPort}
25
+ NetuitiveLogger.log.debug "read config file. Results:
58
26
  debugLevel: #{debugLevelString}"
59
- end
60
27
  end
61
28
  end
62
29
  end
data/log/netuitive.log ADDED
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netuitive_rails_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - John King
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-02 00:00:00.000000000 Z
11
+ date: 2015-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: netuitive_ruby_api
@@ -36,10 +36,12 @@ files:
36
36
  - lib/netuitive/active_job.rb
37
37
  - lib/netuitive/active_record.rb
38
38
  - lib/netuitive/active_support.rb
39
+ - lib/netuitive/netuitive_rails_logger.rb
39
40
  - lib/netuitive/rails_config_manager.rb
40
41
  - lib/netuitive_rails_agent.rb
41
42
  - config/agent.yml
42
43
  - "./LICENSE"
44
+ - log/netuitive.log
43
45
  homepage: http://rubygems.org/gems/netuitive_rails_agent
44
46
  licenses:
45
47
  - Apache v2.0