apminsight 1.0.1 → 1.8.6

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.
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
@@ -17,12 +17,13 @@ module ManageEngine
17
17
  @metrics.dup
18
18
  end
19
19
 
20
- def removeData key, strt_indx,end_indx
21
- if @metrics.has_key?(key)
22
- val = @metrics[key]
23
- val = val.drop(end_indx)
24
- @metrics[key]=val
25
- end
20
+ def removeData key
21
+ # if @metrics.has_key?(key)
22
+ # val = @metrics[key]
23
+ # val = val.drop(end_indx)
24
+ # @metrics[key]=val
25
+ # end
26
+ @metrics.delete(key)
26
27
  end
27
28
 
28
29
  end
@@ -0,0 +1,24 @@
1
+ module APMInsight
2
+ module Errors
3
+ class ExceptionRecord
4
+
5
+ attr_reader :time, :message, :exception
6
+
7
+ def initialize(exception, time = Time.now)
8
+ @time = time.to_f * 1000;
9
+ @message = exception.message
10
+ @exception = exception
11
+ end
12
+
13
+ def ==(obj)
14
+ return obj != nil && @exception == obj.exception
15
+ end
16
+
17
+ def hash
18
+ return @exception.hash
19
+ end
20
+
21
+
22
+ end
23
+ end
24
+ end
@@ -1,5 +1,6 @@
1
1
  require "agent/am_objectholder"
2
2
  require "agent/server/worker/am_worker"
3
+ require "agent/server/instrument/environment"
3
4
 
4
5
  require 'socket'
5
6
 
@@ -12,13 +13,17 @@ module ManageEngine
12
13
 
13
14
  if !@obj.shutdown && @obj.agent_initialized
14
15
  @obj.log.info "Agent Initialization - DONE"
15
- @obj.instrumenter.doSubscribe
16
+ ManageEngine::Environment.new.detect_and_instrument
17
+
16
18
  doDispatcherActions
17
19
  doCollect
18
- puts "ManageEngine APM Ruby Agent Started"
20
+ puts "APM Insight Ruby Agent Started. Agent files are located at #{@obj.constants.conf_location}"
21
+ puts "Agent log file apm.log is generated at #{@obj.log.getLogFilePath}"
19
22
  else
20
23
  @obj.log.info "Agent Initialization Failed - Going to shutdown"
21
- @obj.instrumenter.doSubscribe
24
+ #While parsing the response from /arh/connect we set instrumenter to nil on delete request
25
+ #Server startup fails when the below instruction is executed
26
+ #@obj.instrumenter.doUnSubscribe
22
27
  @obj.shutdownagent
23
28
  end
24
29
 
@@ -34,25 +39,32 @@ module ManageEngine
34
39
  resp = nil
35
40
  if @obj.config.alreadyconnected
36
41
  @obj.log.debug "[doConnect] Already Connected - Make Contact - Instance id = #{@obj.config.instance_id}"
37
- resp = startConnect "?instance_id="+@obj.config.instance_id,agentInfo
42
+ resp = startConnect "?license.key="+@obj.config.license_key+"&instance_id="+@obj.config.instance_id,agentInfo
38
43
  else
39
44
  @obj.log.debug "[doConnect] Going to connect - New "
40
- resp = startConnect "",agentInfo
41
- if resp.has_key?("instance-info")
42
- aData = resp["instance-info"]
43
- aData["agent.id"]=aData.delete("instanceid")
44
- aData["agent.enabled"]=true
45
- @obj.config.updateAgentInfoFile(aData)
46
- @obj.log.debug "[doConnect] Connected - InstanceID : #{@obj.config.instance_id}"
45
+ # if @obj.config.site24x7
46
+ # resp = startConnect "?license.key="+@obj.config.license_key,agentInfo
47
+ # else
48
+ # resp = startConnect "",agentInfo
49
+ # end
50
+ # Checking the license pattern for APM as per team requirement
51
+ if !@obj.config.site24x7 && !@obj.config.license_key.match?("APMI_[A-Fa-f0-9]{64}")
52
+ @obj.log.info "Invalid license key for App Manager, aborting agent init"
53
+ @obj.shutdown=true
47
54
  else
48
- @obj.log.info "[doConnect] [ Problem in connecting server] [ Going to shutdown ]"
49
- @obj.shutdown=true
55
+ resp = startConnect "?license.key="+@obj.config.license_key,agentInfo
50
56
  end
51
57
  end
52
-
53
- if resp==nil
54
- @obj.log.info "[doConnect] [ Error in Response while connecting Server . [ Going to shutdown ]"
55
- @obj.shutdown= true
58
+
59
+ if (resp == nil || !resp.has_key?("instance-info"))
60
+ @obj.log.info "[doConnect] [ Problem in connecting server] [ Going to shutdown ]"
61
+ @obj.shutdown=true
62
+ else
63
+ aData = resp["instance-info"]
64
+ aData["agent.id"]=aData.delete("instanceid")
65
+ aData["agent.enabled"]=true
66
+ @obj.config.updateAgentInfoFile(aData)
67
+ @obj.log.info "[doConnect] Agent successfully connected - InstanceID : #{@obj.config.instance_id}"
56
68
  end
57
69
 
58
70
  if(!@obj.shutdown)
@@ -82,6 +94,7 @@ module ManageEngine
82
94
  end
83
95
 
84
96
  def doDispatcherActions
97
+ @obj.log.info "Dispatcher: #{@obj.config.app_dispatcher}"
85
98
  case @obj.config.app_dispatcher
86
99
  when 'passenger'
87
100
  #starting a new process
@@ -99,6 +112,22 @@ module ManageEngine
99
112
  ManageEngine::APMWorker.getInstance.stop
100
113
  @obj.log.info "stopping_worker_process :Process ID :#{Process.pid} ----> #$$ "
101
114
  end
115
+ when 'unicorn'
116
+ Unicorn::HttpServer.class_eval do
117
+ old_object = instance_method(:worker_loop)
118
+ define_method(:worker_loop) do |worker|
119
+ ::ManageEngine::APMObjectHolder.instance.agent.doCollect
120
+ old_object.bind(self).call(worker)
121
+ end
122
+ end
123
+ when 'rainbows'
124
+ Rainbows::HttpServer.class_eval do
125
+ old_object = instance_method(:worker_loop)
126
+ define_method(:worker_loop) do |worker|
127
+ ::ManageEngine::APMObjectHolder.instance.agent.doCollect
128
+ old_object.bind(self).call(worker)
129
+ end
130
+ end
102
131
  else#case
103
132
 
104
133
  end#case
@@ -2,7 +2,7 @@ require 'net/http'
2
2
  require 'net/https'
3
3
  require 'uri'
4
4
  require 'json'
5
- require "agent/server/instrument/am_instrumenter"
5
+ #require "agent/server/instrument/am_instrumenter"
6
6
 
7
7
  module ManageEngine
8
8
  class APMConnector
@@ -66,11 +66,25 @@ module ManageEngine
66
66
 
67
67
  def url(uri)
68
68
  ru=nil
69
- p="http"
70
- if(@obj.config.is_secured)
71
- p="https"
69
+ p="https"
70
+ if(!@obj.config.is_secured)
71
+ p="http"
72
72
  end
73
- u = p+"://"+@obj.config.apmhost+":#{@obj.config.apmport}/"+uri
73
+ if(@obj.config.license_key != nil)
74
+ if(!@obj.config.license_key.empty?)
75
+ if(@obj.config.apmhost != nil && !@obj.config.apmhost.empty?)
76
+ u = @obj.config.apmhost+uri
77
+ else
78
+ u = @obj.config.site24x7url+uri
79
+ end
80
+ else
81
+ #empty license key - print error
82
+ @obj.log.info "license key is present, but empty"
83
+ end
84
+ else
85
+ @obj.log.info "license key is null"
86
+ u = p+"://"+@obj.config.apmhost+":#{@obj.config.apmport}/"+uri
87
+ end
74
88
  begin
75
89
  ru = URI.parse(u)
76
90
  rescue
@@ -89,19 +103,22 @@ module ManageEngine
89
103
  @obj.log.debug "[connect] Through Proxy"
90
104
  con = Net::HTTP::Proxy(@obj.config.proxy_host, @obj.config.proxy_port,@obj.config.proxy_user,@obj.config.proxy_pass).new(url.host, url.port)
91
105
  else
92
- #@obj.log.info "Proxy Not Needed"
106
+ #@obj.log.info "Proxy Not Needed #{url.host} #{url.port}"
93
107
  con = Net::HTTP.new(url.host, url.port)
108
+ #con.use_ssl=true
109
+ #con.verify_mode=OpenSSL::SSL::VERIFY_NONE
110
+ #@obj.log.info "connection = #{con}"
94
111
  end
95
- con=getScheme(con)
112
+ con=getScheme(con, url)
96
113
  con.open_timeout = @obj.constants.connection_open_timeout
97
114
  con.read_timeout = @obj.constants.connection_read_timeout
98
115
  con
99
116
  end
100
117
 
101
- def getScheme(con)
102
- if(@obj.config.is_secured)
118
+ def getScheme(con, url)
119
+ if(url.to_s.start_with?("https"))
103
120
  #@obj.log.info "[connect] Secured"
104
- con = Net::HTTP::Proxy(@obj.config.proxy_host, @obj.config.proxy_port,@obj.config.proxy_user,@obj.config.proxy_pass).new(url.host, url.port)
121
+ #con = Net::HTTP::Proxy(@obj.config.proxy_host, @obj.config.proxy_port,@obj.config.proxy_user,@obj.config.proxy_pass).new(url.host, url.port)
105
122
  con.use_ssl=true
106
123
  con.verify_mode=OpenSSL::SSL::VERIFY_NONE
107
124
  end
@@ -109,7 +126,7 @@ module ManageEngine
109
126
  end
110
127
 
111
128
  def responseParser resp
112
- if resp == Net::HTTPSuccess || Net::HTTPOK
129
+ if resp.kind_of? Net::HTTPOK
113
130
  rawData = resp.body
114
131
  if rawData.length>=2
115
132
  rBody = JSON.parse(rawData)
@@ -123,10 +140,18 @@ module ManageEngine
123
140
  end
124
141
 
125
142
  end
126
- if data!=nil && data.has_key?(@obj.constants.response_code)
127
-
128
- srCode = data[@obj.constants.response_code]
129
- response_action srCode
143
+ if data!=nil
144
+ if data.has_key?(@obj.constants.response_code)
145
+ srCode = data[@obj.constants.response_code]
146
+ response_action srCode
147
+ end
148
+ if data.has_key?(@obj.constants.custom_config_info)
149
+ config_info = data[@obj.constants.custom_config_info]
150
+ if data.has_key?(@obj.constants.agent_specific_info)
151
+ config_info = config_info.merge(data[@obj.constants.agent_specific_info])
152
+ end
153
+ update_config config_info
154
+ end
130
155
  end
131
156
  return data
132
157
  end
@@ -159,10 +184,32 @@ module ManageEngine
159
184
  end
160
185
  end
161
186
 
187
+ def update_config configInfo
188
+ existingConfigInfo = @obj.config.getAgentConfigData
189
+ sendUpdate = "false"
190
+ existingConfigInfo.each do|key,value|
191
+ if key != "last.modified.time"
192
+ newValue = configInfo[key]
193
+ if key == "sql.capture.enabled" || key == "transaction.trace.enabled" || key == "transaction.trace.sql.parametrize"
194
+ if newValue
195
+ newValue = 1
196
+ else
197
+ newValue = 0
198
+ end
199
+ end
200
+ if value != newValue
201
+ sendUpdate = "true"
202
+ end
203
+ end
204
+ end
205
+ if sendUpdate == "true"
206
+ @obj.log.info "Action from Server - Agent configuration updated from UI. Going to update the same in apminsight.conf file"
207
+ @obj.log.info "config info = #{configInfo}"
208
+ @obj.config.update_config configInfo
209
+ end
210
+ end
211
+
162
212
  def unManage
163
- @obj.instrumenter.doUnSubscribe
164
- @obj.instrumenter =nil
165
- @obj.instrumenter = ManageEngine::APMInstrumenter.new
166
213
  uManage = Hash.new
167
214
  uManage["agent.id"]=@obj.config.instance_id
168
215
  uManage["agent.enabled"]=false
@@ -170,7 +217,6 @@ module ManageEngine
170
217
  end
171
218
 
172
219
  def manage
173
- @obj.instrumenter.doSubscribe
174
220
  uManage = Hash.new
175
221
  uManage["agent.id"]=@obj.config.instance_id
176
222
  uManage["agent.enabled"]=true
@@ -178,8 +224,6 @@ module ManageEngine
178
224
  end
179
225
 
180
226
  def deleteAgent
181
- @obj.instrumenter.doUnSubscribe
182
- @obj.instrumenter =nil
183
227
  uManage = Hash.new
184
228
  uManage["agent.id"]=@obj.config.instance_id
185
229
  uManage["agent.enabled"]=false
@@ -0,0 +1,64 @@
1
+ require 'agent/am_objectholder'
2
+ require 'agent/trackers/default_tracker'
3
+ require 'agent/handler/tracker_handler'
4
+
5
+ module ManageEngine
6
+ module Instrumentation
7
+ class ActionView
8
+
9
+ def present?
10
+ defined?(::Rails)
11
+ end
12
+
13
+ def name
14
+ 'ActiveView'
15
+ end
16
+
17
+ def instrument
18
+ @obj = ManageEngine::APMObjectHolder.instance
19
+ @obj.log.info "Instrumenting ActiveView"
20
+
21
+ ActiveSupport::Notifications.subscribe('render_template.action_view') do |name, start, finish, id, payload|
22
+ collect_data(name, start, finish, payload)
23
+ end ## subscribe
24
+
25
+ ActiveSupport::Notifications.subscribe('render_partial.action_view') do |name, start, finish, id, payload|
26
+ collect_data(name, start, finish, payload)
27
+ end ## subscribe
28
+
29
+ ActiveSupport::Notifications.subscribe('render_collection.action_view') do |name, start, finish, id, payload|
30
+ collect_data(name, start, finish, payload)
31
+ end ## subscribe
32
+
33
+ end ## def instrument
34
+
35
+ def collect_data(name, start, finish, payload)
36
+ begin
37
+
38
+ if name != 'render_template.action_view'
39
+ name = "Partial # #{payload[:identifier]}"
40
+ else
41
+ name = "Rendering # #{payload[:identifier]}"
42
+ end
43
+
44
+ tracker = ManageEngine::Tracker::DefaultTracker.new(name, start.to_f * 1000)
45
+ tracker = ManageEngine::Agent::TrackerHandler.invokeTracker(tracker)
46
+
47
+ if tracker != nil
48
+ tracker.finish(finish.to_f * 1000)
49
+
50
+ exception = payload[:exception_object]
51
+ if exception != nil
52
+ tracker.setError(exception)
53
+ end
54
+
55
+ ManageEngine::Agent::TrackerHandler.exitTracker(tracker)
56
+ end
57
+ rescue Exception => e
58
+ @obj.log.logException("Error processing #{name} payload", e)
59
+ end
60
+ end ## def collect_data
61
+
62
+ end ## class ActionView
63
+ end
64
+ end
@@ -0,0 +1,52 @@
1
+ require 'agent/am_objectholder'
2
+ require 'agent/trackers/database_tracker'
3
+ require 'agent/handler/tracker_handler'
4
+
5
+ module ManageEngine
6
+ module Instrumentation
7
+ class ActiveRecordSQL
8
+
9
+ def present?
10
+ defined?(::ActiveRecord::Base) && defined?(::ActiveSupport::Notifications)
11
+ end
12
+
13
+ def name
14
+ 'ActiveRecord'
15
+ end
16
+
17
+ def instrument
18
+ @obj = ManageEngine::APMObjectHolder.instance
19
+ @obj.log.info "Instrumenting ActiveRecord"
20
+
21
+ ActiveSupport::Notifications.subscribe('sql.active_record') do |name, start, finish, id, payload|
22
+ begin
23
+ if @obj.config.sql_capture && payload[:name] != "SCHEMA" # Dropping internal schema related queries
24
+ dbTracker = ManageEngine::Tracker::DatabaseTracker.new(payload[:name], start.to_f * 1000)
25
+ dbTracker.sql(payload[:sql])
26
+ dbTracker.params(payload[:binds])
27
+ dbTracker = ManageEngine::Agent::TrackerHandler.invokeTracker(dbTracker)
28
+
29
+ if dbTracker != nil
30
+ dbTracker.finish(finish.to_f * 1000)
31
+
32
+ if dbTracker.duration >= (@obj.config.sql_trace_t.to_f * 1000)
33
+ dbTracker.sqlBacktrace(caller(10))
34
+ end
35
+
36
+ exception = payload[:exception_object]
37
+ if exception != nil
38
+ dbTracker.setError(exception)
39
+ end
40
+
41
+ ManageEngine::Agent::TrackerHandler.exitTracker(dbTracker)
42
+ end
43
+ end
44
+ rescue Exception => e
45
+ @obj.log.logException("Error processing #{name} payload", e)
46
+ end
47
+ end #subscribe
48
+ end #def instrument
49
+
50
+ end #class ActiveRecordSQL
51
+ end
52
+ end
@@ -1,99 +1,109 @@
1
- require 'agent/am_objectholder'
2
- @obj = ManageEngine::APMObjectHolder.instance
3
- class Class
4
- alias old_new new
5
- def new(*args, &block)
6
- result =nil;
7
- begin
8
- if(block==nil || block=="")
9
- result = old_new(*args)
10
- elsif
11
- result = old_new(*args,&block)
12
- end
13
- rescue Excetion=>exe
14
- raise exe
15
- result = self
16
- end
17
- me_apm_injector(self,result)
18
-
19
- return result
20
- end
21
- end
1
+ ##
2
+ ##
3
+ # Currently disabling this class, since it will be called for every class's instance creation (Class.new is aliased here)
4
+ # This can be used for custom instrumentation.
5
+ ##
6
+ ##
22
7
 
23
- def me_apm_injector(s,result)
24
- begin
25
- if(ManageEngine::APMObjectHolder.instance.config.include_packages.index(s.name)!=nil)
26
- ms =s.instance_methods(false)
27
- cms = s.methods(false)
28
- begin
29
- ms.each do |m|
30
- if( m.to_s.index("APMTEST"))
31
- return;
32
- end
33
- end
34
- cms.each do |m|
35
- if( m.to_s.index("APMTEST"))
36
- return;
37
- end
38
- end
39
- rescue Exception=>e
40
- return;
41
- end
42
- ManageEngine::APMObjectHolder.instance.log.debug "Injection Method : #{ms} "
43
- ManageEngine::APMObjectHolder.instance.log.debug "Injection Class Method : #{cms} "
44
- ms.each do |m|
45
- mn = m.to_s
46
- #ManageEngine::APMObjectHolder.instance.log.info "ManageEngine Monitor Method : #{s.name} # #{m.to_s}"
47
- omn = "APMTEST"+mn+"APMTEST"
48
- s.class_eval %{
49
- alias_method :#{omn}, :#{mn}
50
- def #{mn} *args, &block
51
- begin
52
- ActiveSupport::Notifications.instrument("apm.methodstart", {:method=>"#{mn}",:args=>args})
53
- res = #{omn} *args, &block
54
- ActiveSupport::Notifications.instrument("apm.methodend", {:method=>"#{mn}",:args=>args})
55
- return res
56
- rescue Exception => exe
57
- puts "error in calling method"
58
- raise exe
59
- ensure
60
- end
61
- end
62
- }
63
- end#do
64
- default_methods = Array.new
65
- default_methods.push("_helpers");
66
- default_methods.push("middleware_stack");
67
- default_methods.push("helpers_path");
68
- default_methods.push("_wrapper_options");
69
- cms.each do |m|
70
- if(default_methods.index(m.to_s)==nil)
71
- mn = m.to_s
72
- #ManageEngine::APMObjectHolder.instance.log.debug "ManageEngine Monitor Singleton Method : #{s.name} ---> #{m.to_s}"
73
- omn = "APMTEST"+mn+"APMTEST"
74
- s.instance_eval %{
75
- class << self
76
- alias_method :#{omn}, :#{mn}
77
- end
78
- def self.#{mn} *args, &block
79
- begin
80
- ActiveSupport::Notifications.instrument("apm.methodstart", {:method=>"#{mn}",:args=>args})
81
- res = #{omn} *args, &block
82
- ActiveSupport::Notifications.instrument("apm.methodend", {:method=>"#{mn}",:args=>args})
83
- return res
84
- rescue Exception=>exe
85
- puts "Instrument : error in calling class method"
86
- raise exe
87
- ensure
88
- end
89
- end
90
- }
91
- end
92
- end#do
93
- end#if
94
- rescue Exception=>e
95
- puts "Exception in instrument : #{e}"
96
- ensure
97
- end
98
- end
8
+
9
+
10
+
11
+ #require 'agent/am_objectholder'
12
+ #@obj = ManageEngine::APMObjectHolder.instance
13
+ #class Class
14
+ # alias old_new new
15
+ # def new(*args, &block)
16
+ # result =nil;
17
+ # begin
18
+ # if(block==nil || block=="")
19
+ # result = old_new(*args)
20
+ # elsif
21
+ # result = old_new(*args,&block)
22
+ # end
23
+ # rescue Exception=>exe
24
+ # raise exe
25
+ # result = self
26
+ # end
27
+ # me_apm_injector(self,result)
28
+ #
29
+ # return result
30
+ # end
31
+ # end
32
+ #
33
+ #def me_apm_injector(s,result)
34
+ # begin
35
+ # if(ManageEngine::APMObjectHolder.instance.config.include_packages.index(s.name)!=nil)
36
+ # ms =s.instance_methods(false)
37
+ # cms = s.methods(false)
38
+ # begin
39
+ # ms.each do |m|
40
+ # if( m.to_s.index("APMTEST"))
41
+ # return;
42
+ # end
43
+ # end
44
+ # cms.each do |m|
45
+ # if( m.to_s.index("APMTEST"))
46
+ # return;
47
+ # end
48
+ # end
49
+ # rescue Exception=>e
50
+ # return;
51
+ # end
52
+ # ManageEngine::APMObjectHolder.instance.log.debug "Injection Method : #{ms} "
53
+ # ManageEngine::APMObjectHolder.instance.log.debug "Injection Class Method : #{cms} "
54
+ # ms.each do |m|
55
+ # mn = m.to_s
56
+ # #ManageEngine::APMObjectHolder.instance.log.info "ManageEngine Monitor Method : #{s.name} # #{m.to_s}"
57
+ # omn = "APMTEST"+mn+"APMTEST"
58
+ # s.class_eval %{
59
+ # alias_method :#{omn}, :#{mn}
60
+ # def #{mn} *args, &block
61
+ # begin
62
+ # ActiveSupport::Notifications.instrument("apm.methodstart", {:method=>"#{mn}",:args=>args})
63
+ # res = #{omn} *args, &block
64
+ # ActiveSupport::Notifications.instrument("apm.methodend", {:method=>"#{mn}",:args=>args})
65
+ # return res
66
+ # rescue Exception => exe
67
+ # puts "error in calling method"
68
+ # raise exe
69
+ # ensure
70
+ # end
71
+ # end
72
+ # }
73
+ # end#do
74
+ # default_methods = Array.new
75
+ # default_methods.push("_helpers");
76
+ # default_methods.push("middleware_stack");
77
+ # default_methods.push("helpers_path");
78
+ # default_methods.push("_wrapper_options");
79
+ # cms.each do |m|
80
+ # if(default_methods.index(m.to_s)==nil)
81
+ # mn = m.to_s
82
+ # #ManageEngine::APMObjectHolder.instance.log.debug "ManageEngine Monitor Singleton Method : #{s.name} ---> #{m.to_s}"
83
+ # omn = "APMTEST"+mn+"APMTEST"
84
+ # s.instance_eval %{
85
+ # class << self
86
+ # alias_method :#{omn}, :#{mn}
87
+ # end
88
+ # def self.#{mn} *args, &block
89
+ # begin
90
+ # ActiveSupport::Notifications.instrument("apm.methodstart", {:method=>"#{mn}",:args=>args})
91
+ # res = #{omn} *args, &block
92
+ # ActiveSupport::Notifications.instrument("apm.methodend", {:method=>"#{mn}",:args=>args})
93
+ # return res
94
+ # rescue Exception=>exe
95
+ # puts "Instrument : error in calling class method"
96
+ # raise exe
97
+ # ensure
98
+ # end
99
+ # end
100
+ # }
101
+ # end
102
+ # end#do
103
+ # end#if
104
+ # rescue Exception=>e
105
+ # puts "Exception in instrument : #{e}"
106
+ # ensure
107
+ # end
108
+ #end
99
109