apminsight 1.0.1 → 1.8.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. data/VERSION +1 -1
  2. data/apm-agent.gemspec +64 -0
  3. data/conf/apminsight.conf +15 -24
  4. data/lib/agent/am_objectholder.rb +25 -19
  5. data/lib/agent/api/custom_tracker.rb +79 -0
  6. data/lib/agent/configuration/am_configuration.rb +284 -41
  7. data/lib/agent/handler/custom_api_handler.rb +40 -0
  8. data/lib/agent/handler/sequence_book.rb +125 -0
  9. data/lib/agent/handler/tracker_handler.rb +58 -0
  10. data/lib/agent/logging/am_logger.rb +20 -11
  11. data/lib/agent/metrics/am_metricsformatter.rb +117 -59
  12. data/lib/agent/metrics/am_metricsparser.rb +195 -468
  13. data/lib/agent/metrics/am_metricstore.rb +7 -6
  14. data/lib/agent/metrics/exception_record.rb +24 -0
  15. data/lib/agent/server/am_agent.rb +46 -17
  16. data/lib/agent/server/am_connector.rb +65 -21
  17. data/lib/agent/server/instrument/action_view.rb +64 -0
  18. data/lib/agent/server/instrument/active_record.rb +52 -0
  19. data/lib/agent/server/instrument/am_apm.rb +107 -97
  20. data/lib/agent/server/instrument/am_instrumenter.rb +54 -42
  21. data/lib/agent/server/instrument/environment.rb +42 -0
  22. data/lib/agent/server/instrument/rails.rb +56 -0
  23. data/lib/agent/server/instrument/sinatra.rb +97 -0
  24. data/lib/agent/server/worker/am_worker.rb +93 -49
  25. data/lib/agent/trackers/database_tracker.rb +107 -0
  26. data/lib/agent/trackers/default_tracker.rb +62 -0
  27. data/lib/agent/trackers/root_tracker.rb +43 -0
  28. data/lib/agent/util/am_constants.rb +53 -8
  29. data/lib/agent/util/am_util.rb +64 -1
  30. data/lib/agent/util/transaction_util.rb +35 -0
  31. data/lib/agent/version.rb +13 -0
  32. data/lib/apminsight.rb +4 -1
  33. metadata +114 -76
@@ -0,0 +1,43 @@
1
+ require 'agent/trackers/default_tracker'
2
+
3
+ module ManageEngine
4
+ module Tracker
5
+ class RootTracker < DefaultTracker
6
+
7
+ attr_accessor :status, :url
8
+
9
+ def url=(url = "unknown")
10
+ @url = ManageEngine::APMObjectHolder.instance.txn_util.normalizeName(url)
11
+ end
12
+
13
+ def http_method(method)
14
+ @http_method = method
15
+ end
16
+
17
+ def http_params(params)
18
+ @http_params = params
19
+ end
20
+
21
+ def queryString(querystring)
22
+ @queryString = querystring
23
+ end
24
+
25
+ def setStatus(httpcode)
26
+ @status = httpcode
27
+ end
28
+
29
+ def getAdditionalInfo
30
+ info = super
31
+ if (@http_method != nil && @queryString != nil && @status != nil)
32
+ if (info == nil)
33
+ info = Hash.new
34
+ end
35
+ info["http_method_name"] = @http_method
36
+ info["http_query_str"] = @queryString
37
+ info["httpcode"] = @status
38
+ end
39
+ info
40
+ end
41
+ end
42
+ end
43
+ end
@@ -2,25 +2,33 @@
2
2
  module ManageEngine
3
3
  class APMConstants
4
4
 
5
- attr_reader :apm_gem,:apm_conf,:agent_conf,:connection_open_timeout,:connection_read_timeout,:connect_uri,:connect_data_uri,:connect_trace_uri
6
- attr_reader :licence_exceeds,:licence_expired,:unmanage_agent,:manage_agent,:error_notfound,:error_server,:delete_agent,:response_code
7
- attr_reader :mf_transaction,:mf_separator,:mf_db,:mf_apdex,:mf_namespace,:mf_name,:mf_all,:agent_store,:agent_lock
5
+ attr_reader :conf_location, :apm_gem,:s247_apm_gem,:apm_conf,:agent_conf,:connection_open_timeout,:connection_read_timeout,:connect_uri,:connect_data_uri,:connect_trace_uri,:connect_config_update_uri,:mergepattern_conf
6
+ attr_reader :site24x7USurl, :site24x7EUurl, :site24x7CNurl, :site24x7INurl, :site24x7AUurl, :site24x7GDurl, :site24x7JPurl
7
+ attr_reader :licence_exceeds,:licence_expired,:unmanage_agent,:manage_agent,:agent_config_updated,:error_notfound,:error_server,:delete_agent,:response_code,:custom_config_info, :agent_specific_info
8
+ attr_reader :mf_transaction,:mf_separator,:mf_db,:mf_apdex,:mf_namespace,:mf_name,:mf_all,:agent_store,:agent_lock,:mf_overflow
9
+ attr_reader :mf_logmetric, :mf_logmetric_warning, :mf_exception_st, :mf_err_st, :mf_loginfo, :mf_loginfo_time, :mf_loginfo_level, :mf_loginfo_str, :mf_loginfo_err_clz, :mf_loginfo_st, :mf_loginfo_level_warn
10
+ attr_reader :en_alphabets, :en_numerals
8
11
 
9
12
  def initialize
10
-
13
+ @conf_location=ENV.has_key?('APMINSIGHT_HOME') ? ENV['APMINSIGHT_HOME']+"/" : "./"
11
14
  #File path for APM Conf file
12
15
  @apm_gem="apminsight"
16
+ @s247_apm_gem="site24x7_apminsight"
17
+
13
18
  #File path for APM Conf file
14
- @apm_conf="apminsight.conf"
19
+ @apm_conf=@conf_location + "apminsight.conf"
15
20
 
16
21
  #file path for agent id, enable details
17
- @agent_conf="apminsight.info"
22
+ @agent_conf=@conf_location + "apminsight.info"
18
23
 
19
24
  #file path for agent data store lock
20
- @agent_lock="apminsight.lock"
25
+ @agent_lock=@conf_location + "apminsight.lock"
21
26
 
22
27
  #file path for agent data store lock
23
- @agent_store="apminsight.store"
28
+ @agent_store=@conf_location + "apminsight.store"
29
+
30
+ #file name for url merge patterns
31
+ @mergepattern_conf=@conf_location + "transaction_merge_patterns.conf"
24
32
 
25
33
 
26
34
  #Timeout for opening Connections
@@ -38,15 +46,30 @@ module ManageEngine
38
46
  #Connection uri for trace
39
47
  @connect_trace_uri="arh/trace?instance_id="
40
48
 
49
+ #Connection uri for config update
50
+ @connect_config_update_uri="arh/agent_config_update?instance_id="
51
+
52
+ #Site24x7 url for agent communication
53
+ @site24x7USurl = "https://plusinsight.site24x7.com/"
54
+ @site24x7EUurl = "https://plusinsight.site24x7.eu/"
55
+ @site24x7CNurl = "https://plusinsight.site24x7.cn/"
56
+ @site24x7AUurl = "https://plusinsight.site24x7.net.au/"
57
+ @site24x7INurl = "https://plusinsight.site24x7.in/"
58
+ @site24x7GDurl = "https://gdplusinsight.site24x7.com/"
59
+ @site24x7JPurl = "https://plusinsight.site24x7.jp/"
60
+
41
61
  #Response Codes
42
62
  @licence_expired = 701
43
63
  @licence_exceeds = 702
44
64
  @delete_agent = 900
45
65
  @unmanage_agent =910
46
66
  @manage_agent = 911
67
+ @agent_config_updated = 920
47
68
  @error_notfound = 404
48
69
  @error_server = 500
49
70
  @response_code = "response-code"
71
+ @custom_config_info = "custom_config_info"
72
+ @agent_specific_info = "agent_specific_info"
50
73
 
51
74
  #Metrics Formatter -mf
52
75
  @mf_apdex = "apdex"
@@ -57,8 +80,30 @@ module ManageEngine
57
80
  @mf_separator = "/"
58
81
  @mf_transaction = "transaction" + @mf_separator + "http"
59
82
  @mf_db = "db"
83
+ @mf_overflow = "0verf10w"
84
+
85
+ @mf_logmetric = "logmetric"
86
+ @mf_logmetric_warning = "warning"
87
+ @mf_err_st = "err_st"
88
+ @mf_exception_st = "exception_st"
89
+ @mf_loginfo = "loginfo"
90
+ @mf_loginfo_time = "time"
91
+ @mf_loginfo_level = "level"
92
+ @mf_loginfo_str = "str"
93
+ @mf_loginfo_err_clz = "err_clz"
94
+ @mf_loginfo_st = "st"
95
+ @mf_loginfo_level_warn = "WARN"
60
96
 
97
+ @en_alphabets = "YXBtaWza"
98
+ @en_numerals = "24876981"
99
+
100
+ end
61
101
 
102
+ def setLicenseKey lkey
103
+ @apm_gem="site24x7_apminsight"
104
+ @connect_data_uri="arh/data?license.key="+lkey+"&instance_id="
105
+ @connect_trace_uri="arh/trace?license.key="+lkey+"&instance_id="
106
+ @connect_config_update_uri="arh/agent_config_update?license.key="+lkey+"&instance_id="
62
107
  end
63
108
  end
64
109
  end
@@ -1,11 +1,50 @@
1
+ require "agent/am_objectholder"
2
+
1
3
  require 'socket'
4
+ require 'openssl'
5
+ require 'base64'
6
+
2
7
  module ManageEngine
3
8
  class APMUtil
4
-
9
+
5
10
  def setLogger log
6
11
  @log = log
7
12
  end
8
13
 
14
+ def encrypt text, key
15
+ if (text == nil || key == nil)
16
+ return nil
17
+ end
18
+ cipher_text = nil
19
+ begin
20
+ key = key.length > 16 ? key[(key.length-16)..-1] : key
21
+ cipher = OpenSSL::Cipher.new('AES-128-CBC').encrypt
22
+ cipher.key = key
23
+ cipher.iv = ManageEngine::APMObjectHolder.instance.constants.en_alphabets + ManageEngine::APMObjectHolder.instance.constants.en_numerals
24
+ cipher_text = Base64.encode64(cipher.update(text) + cipher.final)
25
+ rescue Exception=>e
26
+ cipher_text = nil
27
+ end
28
+ return cipher_text
29
+ end
30
+
31
+ def decrypt cipher_text, key
32
+ if (cipher_text == nil || key == nil)
33
+ return nil
34
+ end
35
+ plain_text = nil
36
+ begin
37
+ key = key.length > 16 ? key[(key.length-16)..-1] : key
38
+ cipher = OpenSSL::Cipher.new('AES-128-CBC').decrypt
39
+ cipher.key = key
40
+ cipher.iv = ManageEngine::APMObjectHolder.instance.constants.en_alphabets + ManageEngine::APMObjectHolder.instance.constants.en_numerals
41
+ plain_text = cipher.update(Base64.decode64(cipher_text)) + cipher.final
42
+ rescue Exception=>e
43
+ plain_text = nil
44
+ end
45
+ return plain_text
46
+ end
47
+
9
48
  #Reads the Property Files and returns a Hashes
10
49
  def readProperties filepath
11
50
  props = {}
@@ -126,5 +165,29 @@ module ManageEngine
126
165
  qry
127
166
  end
128
167
 
168
+ def formatStacktrace(stacktrace)
169
+ strace = Array.new
170
+
171
+ if (stacktrace != nil)
172
+ begin
173
+ stacktrace.each do |stackelement|
174
+ temp = Array.new
175
+ temp[0] = stackelement
176
+ temp[1] = ""
177
+ temp[2] = ""
178
+ temp[3] = ""
179
+ strace.push(temp)
180
+ if (strace.size == 10)
181
+ break;
182
+ end
183
+ end
184
+ rescue Exception=>e
185
+ @log.logException "Error while formatting stack trace. #{e.message}", e
186
+ end
187
+ end
188
+
189
+ strace
190
+ end
191
+
129
192
  end#c
130
193
  end#m
@@ -0,0 +1,35 @@
1
+ module ManageEngine
2
+ class TransactionUtil
3
+
4
+ def initialize
5
+ @obj = ManageEngine::APMObjectHolder.instance
6
+ end
7
+
8
+ def normalizeName(txnName)
9
+ if (txnName != nil)
10
+ txnName.gsub!(/\/\d+/, "/*") # Replace all numbers with *
11
+ # Transaction merge patterns - provided by user
12
+ @obj.config.url_merge_pattern.each do |key, val|
13
+ if (txnName.match(key) != nil)
14
+ txnName=val
15
+ break
16
+ end
17
+ end # do
18
+ end # if (txnName != nil)
19
+ txnName
20
+ end # def normalizeName
21
+
22
+ def listen?(txnName)
23
+ if (txnName != nil)
24
+ @obj.config.txn_skip_listen.each do |pattern|
25
+ pattern = pattern.start_with?('.*') ? pattern : ('.' + pattern)
26
+ if (txnName.match(pattern) != nil)
27
+ return false
28
+ end
29
+ end # do
30
+ end
31
+ true
32
+ end # def listen?
33
+
34
+ end
35
+ end
@@ -0,0 +1,13 @@
1
+ # Holds the major and minor versions of the agent
2
+ # These values are used in gemspec and in agent communication
3
+ # This is one point change, no need to update version numbers at multiple places
4
+ #
5
+ # NOTE: Changing version in 'VERSION' file is optional.
6
+
7
+ module ManageEngine
8
+ class APMInsight
9
+ VERSION = '1.8.6'
10
+ MAJOR_VERSION = '1.8'
11
+ MINOR_VERSION = '6'
12
+ end
13
+ end
data/lib/apminsight.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  require "agent/server/instrument/am_apm"
2
2
  require "agent/am_objectholder"
3
3
  module ManageEngine
4
- ManageEngine::APMObjectHolder.instance
4
+ # Starts a new thread to initialize the agent gem
5
+ Thread.new do
6
+ ManageEngine::APMObjectHolder.instance
7
+ end
5
8
  end
metadata CHANGED
@@ -1,132 +1,170 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: apminsight
3
- version: !ruby/object:Gem::Version
4
- version: 1.0.1
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 8
8
+ - 6
9
+ version: 1.8.6
6
10
  platform: ruby
7
- authors:
8
- - Sabarinathan P
11
+ authors:
12
+ - Adithyan P
9
13
  autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
- date: 2012-07-06 00:00:00.000000000Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
16
+
17
+ date: 2022-08-26 00:00:00 +05:30
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: shoulda
16
- requirement: &29464548 !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
17
24
  none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
22
31
  type: :development
23
- prerelease: false
24
- version_requirements: *29464548
25
- - !ruby/object:Gem::Dependency
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
26
34
  name: bundler
27
- requirement: &29464260 !ruby/object:Gem::Requirement
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
28
37
  none: false
29
- requirements:
38
+ requirements:
30
39
  - - ~>
31
- - !ruby/object:Gem::Version
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 1
43
+ - 0
44
+ - 0
32
45
  version: 1.0.0
33
46
  type: :development
34
- prerelease: false
35
- version_requirements: *29464260
36
- - !ruby/object:Gem::Dependency
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
37
49
  name: jeweler
38
- requirement: &29463972 !ruby/object:Gem::Requirement
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
39
52
  none: false
40
- requirements:
53
+ requirements:
41
54
  - - ~>
42
- - !ruby/object:Gem::Version
55
+ - !ruby/object:Gem::Version
56
+ segments:
57
+ - 1
58
+ - 6
59
+ - 4
43
60
  version: 1.6.4
44
61
  type: :development
45
- prerelease: false
46
- version_requirements: *29463972
47
- - !ruby/object:Gem::Dependency
62
+ version_requirements: *id003
63
+ - !ruby/object:Gem::Dependency
48
64
  name: rcov
49
- requirement: &29463684 !ruby/object:Gem::Requirement
65
+ prerelease: false
66
+ requirement: &id004 !ruby/object:Gem::Requirement
50
67
  none: false
51
- requirements:
52
- - - ! '>='
53
- - !ruby/object:Gem::Version
54
- version: '0'
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ segments:
72
+ - 0
73
+ version: "0"
55
74
  type: :development
56
- prerelease: false
57
- version_requirements: *29463684
58
- - !ruby/object:Gem::Dependency
75
+ version_requirements: *id004
76
+ - !ruby/object:Gem::Dependency
59
77
  name: rails
60
- requirement: &29463396 !ruby/object:Gem::Requirement
78
+ prerelease: false
79
+ requirement: &id005 !ruby/object:Gem::Requirement
61
80
  none: false
62
- requirements:
63
- - - ! '>='
64
- - !ruby/object:Gem::Version
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ segments:
85
+ - 3
86
+ - 0
87
+ - 0
65
88
  version: 3.0.0
66
89
  type: :development
67
- prerelease: false
68
- version_requirements: *29463396
69
- description: ! 'ManageEngine Applications Manager APM Insight gives you end-to-end
70
- web-transaction awareness of Rails applications enabling you to isolate performance
71
- issues and resolve them quickly. To monitor Rails application performance, download
72
- and deploy Applications Manager''s Ruby agent(apminsight) in your Application Server.
73
- This agent allows you to send information about Ruby applications. You can install
74
- APM Insight Agent via Rubygems or download it from Applications Manager''s website:
75
- http://www.manageengine.com/products/applications_manager/apm-insight-agent-installation.html'
90
+ version_requirements: *id005
91
+ description: "ManageEngine Applications Manager APM Insight gives you end-to-end web-transaction awareness of Rails applications enabling you to isolate performance issues and resolve them quickly. To monitor Rails application performance, download and deploy Applications Manager's Ruby agent(apminsight) in your Application Server. This agent allows you to send information about Ruby applications. You can install APM Insight Agent via Rubygems or download it from Applications Manager's website: http://www.manageengine.com/products/applications_manager/apm-insight-agent-installation.html"
76
92
  email: apm-insight@zohocorp.com
77
93
  executables: []
94
+
78
95
  extensions: []
79
- extra_rdoc_files:
96
+
97
+ extra_rdoc_files:
80
98
  - LICENSE.txt
81
99
  - README.rdoc
82
- files:
100
+ files:
83
101
  - LICENSE.txt
84
102
  - README.rdoc
85
103
  - Rakefile
86
104
  - VERSION
105
+ - apm-agent.gemspec
87
106
  - conf/apminsight.conf
88
107
  - lib/apminsight.rb
89
108
  - lib/agent/am_objectholder.rb
90
- - lib/agent/logging/am_logger.rb
109
+ - lib/agent/api/custom_tracker.rb
91
110
  - lib/agent/configuration/am_configuration.rb
92
- - lib/agent/util/am_constants.rb
93
- - lib/agent/util/am_util.rb
94
- - lib/agent/metrics/am_metricsformatter.rb
95
- - lib/agent/metrics/am_metricstore.rb
111
+ - lib/agent/handler/custom_api_handler.rb
112
+ - lib/agent/handler/sequence_book.rb
113
+ - lib/agent/handler/tracker_handler.rb
114
+ - lib/agent/logging/am_logger.rb
96
115
  - lib/agent/metrics/am_metricscollector.rb
116
+ - lib/agent/metrics/am_metricsformatter.rb
97
117
  - lib/agent/metrics/am_metricsparser.rb
118
+ - lib/agent/metrics/am_metricstore.rb
119
+ - lib/agent/metrics/exception_record.rb
98
120
  - lib/agent/server/am_agent.rb
99
121
  - lib/agent/server/am_connector.rb
100
- - lib/agent/server/worker/am_worker.rb
122
+ - lib/agent/server/instrument/action_view.rb
123
+ - lib/agent/server/instrument/active_record.rb
101
124
  - lib/agent/server/instrument/am_apm.rb
102
125
  - lib/agent/server/instrument/am_instrumenter.rb
126
+ - lib/agent/server/instrument/environment.rb
127
+ - lib/agent/server/instrument/rails.rb
128
+ - lib/agent/server/instrument/sinatra.rb
129
+ - lib/agent/server/worker/am_worker.rb
130
+ - lib/agent/trackers/database_tracker.rb
131
+ - lib/agent/trackers/default_tracker.rb
132
+ - lib/agent/trackers/root_tracker.rb
133
+ - lib/agent/util/am_constants.rb
134
+ - lib/agent/util/am_util.rb
135
+ - lib/agent/util/transaction_util.rb
136
+ - lib/agent/version.rb
137
+ has_rdoc: true
103
138
  homepage: http://www.manageengine.com/products/applications_manager/ruby-webtransaction-monitoring.html
104
139
  licenses: []
140
+
105
141
  post_install_message:
106
142
  rdoc_options: []
107
- require_paths:
143
+
144
+ require_paths:
108
145
  - lib
109
- required_ruby_version: !ruby/object:Gem::Requirement
146
+ required_ruby_version: !ruby/object:Gem::Requirement
110
147
  none: false
111
- requirements:
112
- - - ! '>='
113
- - !ruby/object:Gem::Version
114
- version: '0'
115
- required_rubygems_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ segments:
152
+ - 0
153
+ version: "0"
154
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
155
  none: false
117
- requirements:
118
- - - ! '>='
119
- - !ruby/object:Gem::Version
120
- version: '0'
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ segments:
160
+ - 0
161
+ version: "0"
121
162
  requirements: []
163
+
122
164
  rubyforge_project:
123
- rubygems_version: 1.7.2
165
+ rubygems_version: 1.3.7
124
166
  signing_key:
125
167
  specification_version: 3
126
- summary: ! 'ManageEngine Applications Manager APM Insight gives you end-to-end web-transaction
127
- awareness of Rails applications enabling you to isolate performance issues and resolve
128
- them quickly. To monitor Rails application performance, download and deploy Applications
129
- Manager''s Ruby agent(apminsight) in your Application Server. This agent allows
130
- you to send information about Ruby applications. You can install APM Insight Agent
131
- via Rubygems or download it from Applications Manager''s website : http://www.manageengine.com/products/applications_manager/apm-insight-agent-installation.html'
168
+ summary: "ManageEngine Applications Manager APM Insight gives you end-to-end web-transaction awareness of Rails applications enabling you to isolate performance issues and resolve them quickly. To monitor Rails application performance, download and deploy Applications Manager's Ruby agent(apminsight) in your Application Server. This agent allows you to send information about Ruby applications. You can install APM Insight Agent via Rubygems or download it from Applications Manager's website : http://www.manageengine.com/products/applications_manager/apm-insight-agent-installation.html"
132
169
  test_files: []
170
+