site24x7_apminsight 1.5.3 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +1 -1
- data/README.rdoc +18 -20
- data/Rakefile +4 -4
- data/lib/agent/api/custom_tracker.rb +79 -0
- data/lib/agent/configuration/am_configuration.rb +31 -2
- data/lib/agent/handler/custom_api_handler.rb +40 -0
- data/lib/agent/handler/sequence_book.rb +115 -0
- data/lib/agent/handler/tracker_handler.rb +56 -0
- data/lib/agent/metrics/am_metricsformatter.rb +14 -4
- data/lib/agent/metrics/am_metricsparser.rb +88 -108
- data/lib/agent/metrics/exception_record.rb +24 -0
- data/lib/agent/server/am_connector.rb +1 -1
- data/lib/agent/server/instrument/action_view.rb +64 -0
- data/lib/agent/server/instrument/active_record.rb +10 -8
- data/lib/agent/server/instrument/environment.rb +11 -0
- data/lib/agent/server/instrument/rails.rb +11 -12
- data/lib/agent/server/instrument/sinatra.rb +11 -10
- data/lib/agent/server/worker/am_worker.rb +31 -31
- data/lib/agent/trackers/default_tracker.rb +10 -2
- data/lib/agent/trackers/root_tracker.rb +5 -8
- data/lib/agent/util/am_util.rb +16 -13
- data/lib/site24x7_apminsight.rb +4 -1
- data/lib/version.rb +3 -3
- metadata +37 -44
- checksums.yaml +0 -7
@@ -12,37 +12,34 @@ module ManageEngine
|
|
12
12
|
@obj = ManageEngine::APMObjectHolder.instance
|
13
13
|
parseddata = Hash.new
|
14
14
|
begin
|
15
|
-
data.each do |txn_name,
|
15
|
+
data.each do |txn_name, seqBag|
|
16
16
|
@obj.log.debug "[Processing started for - #{txn_name} ]"
|
17
17
|
|
18
|
-
|
18
|
+
seqBag.each do |seqData|
|
19
19
|
|
20
20
|
tdata = Hash.new #transaction data -> rt, path,..
|
21
21
|
exceptionInfo = Array.new # data to be sent in trace as 'loginfo'
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end # do - children
|
23
|
+
rootTracker = seqData["roottracker"]
|
24
|
+
|
25
|
+
tdata["td"] = getTransData(rootTracker,tdata)
|
26
|
+
tdata["db"] = getDBData(rootTracker, tdata, exceptionInfo)
|
27
|
+
|
28
|
+
exceptionBag = seqData["exceptions"]
|
29
|
+
if exceptionBag != nil
|
30
|
+
exceptionBag.each do |exceptionRecord|
|
31
|
+
updateExceptionMetric(exceptionRecord.exception,tdata)
|
32
|
+
updateExceptionInfo(exceptionInfo, exceptionRecord.time, exceptionRecord.exception, exceptionRecord.message)
|
33
|
+
end
|
35
34
|
end
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
parseddata = updateParsedData(txn_name, tdata.dup, parseddata)
|
36
|
+
parseddata = updateParsedData(txn_name, tdata.dup, parseddata)
|
40
37
|
|
41
|
-
if @obj.config.trans_trace && (
|
42
|
-
parseddata = updateTraceData(
|
38
|
+
if @obj.config.trans_trace && (rootTracker.duration >= (@obj.config.trans_trace_t.to_f*1000).to_i || rootTracker.error?)
|
39
|
+
parseddata = updateTraceData(rootTracker, parseddata, exceptionInfo)
|
43
40
|
end
|
44
41
|
|
45
|
-
end # do -
|
42
|
+
end # do - seqBag
|
46
43
|
|
47
44
|
@obj.store.removeData txn_name
|
48
45
|
@obj.log.debug "[Processing END for - #{txn_name} ]"
|
@@ -56,15 +53,13 @@ module ManageEngine
|
|
56
53
|
parseddata
|
57
54
|
end
|
58
55
|
|
59
|
-
def updateExceptionInfo (
|
60
|
-
|
61
|
-
logInfo = { @obj.constants.mf_loginfo_time => tracker.endtime.to_i,
|
56
|
+
def updateExceptionInfo (exceptionInfo, time, error, message = nil)
|
57
|
+
logInfo = { @obj.constants.mf_loginfo_time => time,
|
62
58
|
@obj.constants.mf_loginfo_level => @obj.constants.mf_loginfo_level_warn,
|
63
|
-
@obj.constants.mf_loginfo_str =>
|
64
|
-
@obj.constants.mf_loginfo_err_clz =>
|
65
|
-
@obj.constants.mf_loginfo_st => @obj.util.formatStacktrace(
|
66
|
-
|
67
|
-
end
|
59
|
+
@obj.constants.mf_loginfo_str => message != nil ? message : error.message,
|
60
|
+
@obj.constants.mf_loginfo_err_clz => error.class.to_s,
|
61
|
+
@obj.constants.mf_loginfo_st => @obj.util.formatStacktrace(error.backtrace) }
|
62
|
+
exceptionInfo.push(logInfo)
|
68
63
|
end
|
69
64
|
|
70
65
|
def updateParsedData (key, tdata, parseddata)
|
@@ -98,7 +93,7 @@ module ManageEngine
|
|
98
93
|
end
|
99
94
|
begin
|
100
95
|
trdata = getTrace(rootTracker)
|
101
|
-
trac = updateTrace(trdata, exceptionInfo)
|
96
|
+
trac = updateTrace(rootTracker.url, trdata, exceptionInfo)
|
102
97
|
if(parseddata.has_key?("trace-data"))
|
103
98
|
traceData = parseddata["trace-data"];
|
104
99
|
traceData.push(trac);
|
@@ -139,10 +134,9 @@ module ManageEngine
|
|
139
134
|
ret = tdata["td"]
|
140
135
|
ret["rt"] = ret["rt"] + rootTracker.duration
|
141
136
|
else
|
142
|
-
ret = {"rt"=> rootTracker.duration, "path"=>rootTracker.
|
137
|
+
ret = {"rt"=> rootTracker.duration, "path"=>rootTracker.url}
|
143
138
|
if (rootTracker.error?)
|
144
139
|
ret["error"] = true
|
145
|
-
updateExceptionMetric(rootTracker.error, ret)
|
146
140
|
end
|
147
141
|
end
|
148
142
|
rescue Exception=>e
|
@@ -153,24 +147,36 @@ module ManageEngine
|
|
153
147
|
end
|
154
148
|
|
155
149
|
# Generates DB metric
|
156
|
-
def getDBData(
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
150
|
+
def getDBData(tracker, tdata, exceptionInfo)
|
151
|
+
while (tracker != nil)
|
152
|
+
dbData = getDBData(tracker.child, tdata, exceptionInfo)
|
153
|
+
|
154
|
+
if tracker.kind_of?(ManageEngine::Tracker::DatabaseTracker)
|
155
|
+
if dbData == nil
|
156
|
+
dbData = Array.new
|
157
|
+
end
|
158
|
+
|
159
|
+
queryInfo = tracker.getQueryInfo
|
160
|
+
sqlStrip = queryInfo[0] + "/" + queryInfo[1] + "/dummydb"
|
161
|
+
|
162
|
+
ret ={"rt"=>tracker.duration, "sql"=>tracker.getRawQuery,
|
163
|
+
"sql-strip"=>sqlStrip, "name"=>tracker.name, "operation"=>queryInfo[0]}
|
164
|
+
|
165
|
+
if (tracker.error?)
|
166
|
+
ret["error"] = true
|
167
|
+
end
|
168
|
+
|
169
|
+
dbData.push(ret)
|
170
|
+
end ## DBTracker check
|
171
|
+
|
172
|
+
if (tracker.error?)
|
173
|
+
updateExceptionMetric(tracker.error, tdata) # <= previously it was 'ret'
|
174
|
+
updateExceptionInfo(exceptionInfo, tracker.endtime.to_i, tracker.error)
|
175
|
+
end
|
176
|
+
|
177
|
+
tracker = tracker.sibling
|
178
|
+
end ## while loop
|
161
179
|
|
162
|
-
queryInfo = databaseTracker.getQueryInfo
|
163
|
-
sqlStrip = queryInfo[0] + "/" + queryInfo[1] + "/dummydb"
|
164
|
-
|
165
|
-
ret ={"rt"=>databaseTracker.duration, "sql"=>databaseTracker.getRawQuery,
|
166
|
-
"sql-strip"=>sqlStrip, "name"=>databaseTracker.name, "operation"=>queryInfo[0]}
|
167
|
-
|
168
|
-
if (databaseTracker.error?)
|
169
|
-
ret["error"] = true
|
170
|
-
updateExceptionMetric(databaseTracker.error, ret)
|
171
|
-
end
|
172
|
-
|
173
|
-
dbData.push(ret)
|
174
180
|
dbData
|
175
181
|
end
|
176
182
|
|
@@ -185,48 +191,10 @@ module ManageEngine
|
|
185
191
|
excData[@obj.constants.mf_logmetric_warning] = excData[@obj.constants.mf_logmetric_warning].to_i + 1
|
186
192
|
end
|
187
193
|
|
188
|
-
def
|
189
|
-
trData = Array.new
|
190
|
-
trData[0] = dbTracker.starttime
|
191
|
-
queryInfo = dbTracker.getQueryInfo
|
192
|
-
trData[1] = queryInfo[0] + " - " + queryInfo[1]
|
193
|
-
trData[2] = ""
|
194
|
-
trData[3] = dbTracker.duration.to_i
|
195
|
-
trData[4] = trData[3]
|
196
|
-
trData[5] = dbTracker.getAdditionalInfo
|
197
|
-
trData[6] = Array.new
|
198
|
-
trData
|
199
|
-
end
|
200
|
-
|
201
|
-
def updateOtherTrace(tracker)
|
202
|
-
trData = Array.new
|
203
|
-
trData[0] = tracker.starttime
|
204
|
-
trData[1] = tracker.name
|
205
|
-
trData[2] = ""
|
206
|
-
trData[3] = tracker.duration
|
207
|
-
trData[4] = tracker.duration
|
208
|
-
trData[5] = tracker.getAdditionalInfo
|
209
|
-
trData[6] = Array.new
|
210
|
-
trData
|
211
|
-
end
|
212
|
-
|
213
|
-
def updateStartTrace(rootTracker)
|
214
|
-
trData = Array.new
|
215
|
-
trData[0] = rootTracker.starttime
|
216
|
-
trData[1] = rootTracker.name # tracker name
|
217
|
-
trData[2] = "" # component
|
218
|
-
trData[3] = rootTracker.duration # total time
|
219
|
-
trData[4] = trData[3] # exclusive time
|
220
|
-
trData[5] = rootTracker.getAdditionalInfo # additional info
|
221
|
-
trData[6] = Array.new # children
|
222
|
-
|
223
|
-
trData
|
224
|
-
end
|
225
|
-
|
226
|
-
def updateTrace(trans, exceptionInfo)
|
194
|
+
def updateTrace(url, trans, exceptionInfo)
|
227
195
|
# {"thread_name":"http-8080-6","s_time":1326276180289,"t_name":"transaction\/http\/Test-App\/login","r_time":18,"thread_id":141}
|
228
196
|
top = Array.new
|
229
|
-
path = @obj.constants.mf_transaction + @obj.constants.mf_separator +
|
197
|
+
path = @obj.constants.mf_transaction + @obj.constants.mf_separator + url
|
230
198
|
det = {"thread_name"=>"rorthread","s_time"=>trans[0],"t_name"=>path,"r_time"=>trans[3],"thread_id"=>141}
|
231
199
|
|
232
200
|
exception = trans[5] != nil ? trans[5][@obj.constants.mf_exception_st] : nil
|
@@ -244,31 +212,43 @@ module ManageEngine
|
|
244
212
|
end
|
245
213
|
|
246
214
|
def getTrace(rootTracker)
|
247
|
-
|
248
|
-
|
249
|
-
|
215
|
+
trace = Array.new
|
216
|
+
traceDetails(rootTracker, trace)
|
217
|
+
|
218
|
+
return trace[0]
|
250
219
|
end
|
251
220
|
|
252
|
-
def traceDetails
|
221
|
+
def traceDetails tracker, traceArr
|
253
222
|
|
254
|
-
|
223
|
+
siblingDuration = 0
|
255
224
|
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
end
|
269
|
-
|
225
|
+
while tracker != nil
|
226
|
+
|
227
|
+
childTrace = Array.new
|
228
|
+
childDuration = traceDetails tracker.child, childTrace
|
229
|
+
|
230
|
+
traceItem = Array.new
|
231
|
+
traceItem[0] = tracker.starttime
|
232
|
+
if tracker.kind_of?(ManageEngine::Tracker::DatabaseTracker)
|
233
|
+
queryInfo = tracker.getQueryInfo
|
234
|
+
traceItem[1] = queryInfo[0] + " - " + queryInfo[1]
|
235
|
+
else
|
236
|
+
traceItem[1] = tracker.name
|
237
|
+
end
|
238
|
+
traceItem[2] = ""
|
239
|
+
traceItem[3] = tracker.duration
|
240
|
+
traceItem[4] = tracker.duration - childDuration
|
241
|
+
traceItem[5] = tracker.getAdditionalInfo
|
242
|
+
traceItem[6] = childTrace.empty? ? nil : childTrace
|
243
|
+
|
244
|
+
traceArr.push(traceItem)
|
245
|
+
|
246
|
+
siblingDuration += tracker.duration
|
247
|
+
|
248
|
+
tracker = tracker.sibling
|
249
|
+
end
|
270
250
|
|
271
|
-
|
251
|
+
return siblingDuration
|
272
252
|
end
|
273
253
|
|
274
254
|
|
@@ -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
|
@@ -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 ActiveRecord"
|
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
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'agent/am_objectholder'
|
2
2
|
require 'agent/trackers/database_tracker'
|
3
|
+
require 'agent/handler/tracker_handler'
|
3
4
|
|
4
5
|
module ManageEngine
|
5
6
|
module Instrumentation
|
@@ -19,15 +20,16 @@ module ManageEngine
|
|
19
20
|
|
20
21
|
ActiveSupport::Notifications.subscribe('sql.active_record') do |name, start, finish, id, payload|
|
21
22
|
begin
|
22
|
-
if @obj.config.
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
28
30
|
dbTracker.finish(finish.to_f * 1000)
|
29
31
|
|
30
|
-
if dbTracker.duration >= @obj.config.sql_trace_t.to_f
|
32
|
+
if dbTracker.duration >= (@obj.config.sql_trace_t.to_f * 1000)
|
31
33
|
dbTracker.sqlBacktrace(caller(10))
|
32
34
|
end
|
33
35
|
|
@@ -36,7 +38,7 @@ module ManageEngine
|
|
36
38
|
dbTracker.setError(exception)
|
37
39
|
end
|
38
40
|
|
39
|
-
|
41
|
+
ManageEngine::Agent::TrackerHandler.exitTracker(dbTracker)
|
40
42
|
end
|
41
43
|
end
|
42
44
|
rescue Exception => e
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'agent/server/instrument/rails'
|
2
2
|
require 'agent/server/instrument/sinatra'
|
3
3
|
require 'agent/server/instrument/active_record'
|
4
|
+
require 'agent/server/instrument/action_view'
|
4
5
|
|
5
6
|
module ManageEngine
|
6
7
|
class Environment
|
@@ -14,6 +15,10 @@ module ManageEngine
|
|
14
15
|
ManageEngine::Instrumentation::ActiveRecordSQL.new
|
15
16
|
]
|
16
17
|
|
18
|
+
OTHER_INTERCEPTORS = [
|
19
|
+
ManageEngine::Instrumentation::ActionView.new
|
20
|
+
]
|
21
|
+
|
17
22
|
def detect_and_instrument
|
18
23
|
@framework ||= SUPPORTED_FRAMEWORKS.detect{ |framework| framework.present? }
|
19
24
|
@framework.instrument
|
@@ -23,6 +28,12 @@ module ManageEngine
|
|
23
28
|
interceptor.instrument
|
24
29
|
end
|
25
30
|
end
|
31
|
+
|
32
|
+
OTHER_INTERCEPTORS.each do |interceptor|
|
33
|
+
if (interceptor.present?)
|
34
|
+
interceptor.instrument
|
35
|
+
end
|
36
|
+
end
|
26
37
|
end
|
27
38
|
|
28
39
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'agent/handler/tracker_handler'
|
2
|
+
|
1
3
|
module ManageEngine
|
2
4
|
module Instrumentation
|
3
5
|
class RailsFramework
|
@@ -25,28 +27,25 @@ module ManageEngine
|
|
25
27
|
def instrument
|
26
28
|
@obj = ManageEngine::APMObjectHolder.instance
|
27
29
|
@obj.log.info "Instrumenting ActionController.. Rails Version: #{version}"
|
30
|
+
@railsTracker = nil
|
28
31
|
|
29
32
|
ActiveSupport::Notifications.subscribe('start_processing.action_controller') do |name, start, finish, id, payload|
|
30
33
|
path = payload[:path].partition("?")[0]
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
Thread.current[:apminsight] = railsTracker
|
35
|
-
end
|
34
|
+
@railsTracker = ManageEngine::Tracker::RootTracker.new("#{payload[:controller]}.#{payload[:action]}", start.to_f * 1000)
|
35
|
+
@railsTracker.url=(path)
|
36
|
+
@railsTracker = ManageEngine::Agent::TrackerHandler.invokeTracker(@railsTracker)
|
36
37
|
end # subscribe
|
37
38
|
|
38
39
|
|
39
40
|
ActiveSupport::Notifications.subscribe('process_action.action_controller') do |name, start, finish, id, payload|
|
40
|
-
|
41
|
-
|
42
|
-
tracker.finish(finish.to_f * 1000)
|
41
|
+
if @railsTracker != nil
|
42
|
+
@railsTracker.finish(finish.to_f * 1000)
|
43
43
|
exception = payload[:exception_object]
|
44
44
|
if exception != nil
|
45
|
-
|
46
|
-
|
45
|
+
@railsTracker.setError(exception)
|
46
|
+
@railsTracker.setStatus(500) # By default, set 500 as status for error txns
|
47
47
|
end
|
48
|
-
ManageEngine::
|
49
|
-
Thread.current[:apminsight] = nil # Removing threadlocal
|
48
|
+
ManageEngine::Agent::TrackerHandler.exitTracker(@railsTracker)
|
50
49
|
end
|
51
50
|
end
|
52
51
|
|
@@ -45,26 +45,27 @@ module ManageEngine
|
|
45
45
|
url = (env.has_key?('sinatra.route') ? env['sinatra.route'] : @request.path).dup
|
46
46
|
@obj = ManageEngine::APMObjectHolder.instance
|
47
47
|
|
48
|
-
if !@obj.config.agent_enabled || !@obj.txn_util.listen?(url)
|
49
|
-
original_route_eval(*args, &block)
|
50
|
-
end
|
51
|
-
|
52
48
|
sinatraTracker = ManageEngine::Tracker::RootTracker.new(url)
|
53
|
-
|
49
|
+
sinatraTracker.url=(url)
|
50
|
+
sinatraTracker = ManageEngine::Agent::TrackerHandler.invokeTracker(sinatraTracker)
|
51
|
+
|
54
52
|
# TODO: capture all additional details @request.query_string @request.params
|
55
53
|
|
56
54
|
begin
|
57
55
|
original_route_eval(*args, &block)
|
58
56
|
|
59
57
|
rescue Exception => e # On application error, above method throws exception
|
60
|
-
sinatraTracker
|
61
|
-
|
58
|
+
if (sinatraTracker != nil)
|
59
|
+
sinatraTracker.setError(e)
|
60
|
+
sinatraTracker.setStatus(500) # By default, set 500 as status for error txns
|
61
|
+
end
|
62
62
|
raise e
|
63
63
|
|
64
64
|
ensure
|
65
|
-
sinatraTracker
|
66
|
-
|
67
|
-
|
65
|
+
if sinatraTracker != nil
|
66
|
+
sinatraTracker.finish
|
67
|
+
end
|
68
|
+
ManageEngine::Agent::TrackerHandler.exitTracker(sinatraTracker)
|
68
69
|
end
|
69
70
|
|
70
71
|
end
|
@@ -7,39 +7,39 @@ class APMWorker
|
|
7
7
|
@status = 'not_init'
|
8
8
|
@id = 0
|
9
9
|
attr_accessor :id
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
def start
|
16
|
-
@obj = ManageEngine::APMObjectHolder.instance
|
17
|
-
|
18
|
-
if @status=="working"
|
19
|
-
@obj.log.debug "woker thread already started"
|
20
|
-
elsif @status == "initialized"
|
21
|
-
@obj.log.info "start worker thread for - #{Process.pid} :: #{@status} "
|
22
|
-
#@obj.log.info "Starting APMWorker Thread #{Process.pid} "
|
23
|
-
@apm = Thread.new do
|
24
|
-
@status = 'working'
|
25
|
-
while !@obj.shutdown do
|
26
|
-
checkforagentstatus
|
27
|
-
updateConfig
|
28
|
-
dc
|
29
|
-
sleep (@obj.config.connect_interval).to_i
|
30
|
-
end#w
|
31
|
-
@status= "end"
|
32
|
-
@obj.log.debug "Worker thread ends"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
10
|
+
def initialize
|
11
|
+
@status = "initialized"
|
12
|
+
@id = Process.pid
|
13
|
+
end
|
36
14
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
15
|
+
def start
|
16
|
+
@obj = ManageEngine::APMObjectHolder.instance
|
17
|
+
|
18
|
+
if @status=="working"
|
19
|
+
@obj.log.debug "woker thread already started"
|
20
|
+
elsif @status == "initialized"
|
21
|
+
@obj.log.info "start worker thread for - #{Process.pid} :: #{@status} "
|
22
|
+
#@obj.log.info "Starting APMWorker Thread #{Process.pid} "
|
23
|
+
@apm = Thread.new do
|
24
|
+
@status = 'working'
|
25
|
+
while !@obj.shutdown do
|
26
|
+
checkforagentstatus
|
27
|
+
updateConfig
|
28
|
+
dc
|
29
|
+
sleep (@obj.config.connect_interval).to_i
|
30
|
+
end#w
|
31
|
+
@status= "end"
|
32
|
+
@obj.log.debug "Worker thread ends"
|
42
33
|
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.getInstance
|
38
|
+
if(@work==nil || @work.id!=Process.pid)
|
39
|
+
@work = ManageEngine::APMWorker.new
|
40
|
+
end
|
41
|
+
return @work
|
42
|
+
end
|
43
43
|
|
44
44
|
def updateConfig
|
45
45
|
if(@obj.config.lastupdatedtime!=File.mtime(@obj.constants.apm_conf).to_i)
|
@@ -3,11 +3,11 @@ module ManageEngine
|
|
3
3
|
|
4
4
|
class DefaultTracker
|
5
5
|
|
6
|
-
attr_accessor :name, :error, :endtime, :starttime
|
6
|
+
attr_accessor :name, :error, :endtime, :starttime, :child, :sibling
|
7
7
|
|
8
8
|
def initialize(name = "unknonwn", time = ManageEngine::APMObjectHolder.instance.util.currenttimemillis)
|
9
9
|
@starttime = time.to_i
|
10
|
-
@name =
|
10
|
+
@name = name
|
11
11
|
@logger = ManageEngine::APMObjectHolder.instance.log
|
12
12
|
end
|
13
13
|
|
@@ -31,6 +31,14 @@ module ManageEngine
|
|
31
31
|
(@endtime - @starttime).to_i
|
32
32
|
end
|
33
33
|
|
34
|
+
def ==(obj)
|
35
|
+
return obj != nil && @name == obj.name
|
36
|
+
end
|
37
|
+
|
38
|
+
def hash
|
39
|
+
return @name.hash
|
40
|
+
end
|
41
|
+
|
34
42
|
def to_s
|
35
43
|
@name
|
36
44
|
end
|
@@ -4,7 +4,11 @@ module ManageEngine
|
|
4
4
|
module Tracker
|
5
5
|
class RootTracker < DefaultTracker
|
6
6
|
|
7
|
-
attr_accessor :
|
7
|
+
attr_accessor :status, :url
|
8
|
+
|
9
|
+
def url=(url = "unknown")
|
10
|
+
@url = ManageEngine::APMObjectHolder.instance.txn_util.normalizeName(url)
|
11
|
+
end
|
8
12
|
|
9
13
|
def http_method(method)
|
10
14
|
@http_method = method
|
@@ -22,13 +26,6 @@ module ManageEngine
|
|
22
26
|
@status = httpcode
|
23
27
|
end
|
24
28
|
|
25
|
-
def addChild(tracker)
|
26
|
-
if @children == nil
|
27
|
-
@children = Array.new
|
28
|
-
end
|
29
|
-
@children.push(tracker)
|
30
|
-
end
|
31
|
-
|
32
29
|
def getAdditionalInfo
|
33
30
|
info = super
|
34
31
|
if (@http_method != nil && @queryString != nil && @status != nil)
|