site24x7_apminsight 1.8.8 → 1.9.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6adf1511641c4e23c0e5f0a0ac71336dd62c4fe0ee23b0df46b07e804c74841a
4
+ data.tar.gz: 1d5dcaa91fd5e185f3592c86f686af35f33d20918297ef0f1d2deeaffa5a5c7b
5
+ SHA512:
6
+ metadata.gz: 7a01e038e40a5656c0c62dd353dcb5c118bc071312612aef245fdf1d2edcf2ae4a6dded206406febda1f029b42a961b5b75758565758938dc5ee77a7e837b92c
7
+ data.tar.gz: 80d84c7ba2f6095adb9050040283a788242d94f7ad9e00b9141b76addbb88123fa16027de9af33723bd3a60daa9e5a01c4a75b5ea0205a0d3c009aed7f23ca3c
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- This License Agreement details the policy for license of Site24x7 APM Insight Ruby Agent ("Licensed Software")
1
+ This License Agreement details the policy for license of ManageEngine APM Insight Ruby Agent ("Licensed Software")
2
2
  Please read the following license carefully, before either (i) downloading the Licensed Software from an authorized website, or (ii) installing the Licensed Software. You acknowledge that you have read this License Agreement, have understood it, and agree to be bound by its terms. If you do not agree to the terms and conditions of this Agreement, do not download or install the Licensed Software.
3
3
 
4
4
  1. LICENSE GRANT
data/README.rdoc CHANGED
@@ -1,5 +1,5 @@
1
1
  APM Insight Ruby Agent
2
- Site24x7 APM Insight Ruby agent gives you end-to-end web-transaction awareness enabling you to isolate performance issues and resolve them quickly. Site24x7 APM Insight requires a monitoring agent (ruby gem) to be deployed in your application server to monitor Ruby application performance. Download the latest Ruby Agent(site24x7_apminsight.gem) and deploy it in your application server. The agent collects application performance metrics and sends it to the central Site24x7 server at fixed intervals i.e. every 60 seconds. You can view them at https://site24x7.com in your accounts page.
2
+ Applications Manager's Ruby agent gives you end-to-end web-transaction awareness enabling you to isolate performance issues and resolve them quickly.Applications Manager requires a monitoring agent (ruby gem) to be deployed in your application server to monitor Ruby application performance. Download the latest Ruby Agent(apminsight.gem) and deploy it in your application server. The agent collects application performance metrics and sends it to the central Applications Manager server at fixed intervals i.e. every 60 seconds.
3
3
 
4
4
  Installing APM Insight Agent
5
5
 
@@ -7,13 +7,13 @@ Installing APM Insight Agent
7
7
 
8
8
  * Install from RubyGems by using the following command in the system where Ruby is installed :
9
9
 
10
- gem install site24x7_apminsight
10
+ gem install apminsight
11
11
 
12
12
  OR
13
13
 
14
- * Download the site24x7_apminsight.gem file from your accounts page in https://site24x7.com (after sign in) or the RubyGems website and run the command
14
+ * Download the apminsight.gem file directly from our website or the RubyGems website and run the command
15
15
 
16
- gem install site24x7_apminsight.gem
16
+ gem install apminsight.gem
17
17
 
18
18
  Configuration
19
19
 
@@ -21,28 +21,30 @@ Configuration
21
21
 
22
22
  For each of your applications, add the following line to the application gemfile:
23
23
 
24
- gem 'site24x7_apminsight'
24
+ gem 'apminsight'
25
25
 
26
26
  OR
27
27
 
28
28
  For each of your applications, add the following line to the application initializer block:
29
29
 
30
- require 'site24x7_apminsight'
30
+ require 'apminsight'
31
31
 
32
- A copy of the configuration file apminsight.conf will be available in the <Gem Installed folder> /site24x7_apminsight/conf/. Configure the class name in the configuration file(include.packages), so that all the methods in that class can be instrumented and details will be reported in tracedata.
32
+ A copy of the configuration file apminsight.conf will be available in the <Gem Installed folder> /apminsight/conf/. Configure the class name in the configuration file(include.packages), so that all the methods in that class can be instrumented and details will be reported in tracedata.
33
33
 
34
34
 
35
35
  The following configuration options are mandatory and should be provided for the agent to be initialized:
36
36
 
37
- application.name - The application's name to be displayed in Site24x7 server.
37
+ application.name - The application's name to be displayed in Applications Manager.
38
38
 
39
- license.key - The license api key from your account page after sign in (https://site24x7.com)
39
+ apm.host - The host where Applications Manager is running.
40
+
41
+ apm.port - The HTTP port of Applications Manager.
40
42
 
41
43
  behind.proxy - The proxy network under which the agent is installed
42
44
 
43
45
  agent.server.port - The HTTP listening port of the Application Server.
44
46
 
45
- More configuration options of APM Insight Ruby Agent can be found here. https://www.site24x7.com/help/apm/apm-insight-configuration.html
47
+ More configuration options of APM Insight Ruby Agent can be found here.
46
48
 
47
49
  Supported Environments :
48
50
 
@@ -52,16 +54,16 @@ Supported Environments :
52
54
 
53
55
  References
54
56
 
55
- * Create an apminsight account in Site24x7 server (https://www.site24x7.com)
57
+ * Download link for Applications Manager
56
58
 
57
- * Download link for site24x7_apminsight gem
59
+ http://www.manageengine.com/products/applications_manager/
58
60
 
59
- From your account page after valid sign in
60
- or
61
- http://rubygems.org/gems/site24x7_apminsight
61
+ * Download link for apminsight
62
62
 
63
- * Help Documentation for apminsight
63
+ http://www.manageengine.com/products/applications_manager/
64
+ http://rubygems.org/gems/apminsight
64
65
 
65
- https://www.site24x7.com/help/apm/ruby-agent.html
66
- https://support.site24x7.com/portal/helpcenter/site24x7/apm-insight/ruby-monitoring
66
+ * Help Documentation for apminsight
67
67
 
68
+ http://www.manageengine.com/products/applications_manager/help/APMInsight/installing-transaction-agent.html
69
+
data/Rakefile CHANGED
@@ -14,13 +14,13 @@ require 'rake'
14
14
  require 'jeweler'
15
15
  Jeweler::Tasks.new do |gem|
16
16
  # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
- gem.name = "site24x7_apminsight"
18
- gem.homepage = "https://www.site24x7.com/help/apm/ruby-agent.html"
17
+ gem.name = "apminsight"
18
+ gem.homepage = "http://www.manageengine.com/products/applications_manager/ruby-webtransaction-monitoring.html"
19
19
  gem.license = "MIT"
20
20
  gem.summary = %Q{Application Performace Monitor}
21
21
  gem.description = %Q{Application Performace Monitor : Monitor the web tranasactions}
22
22
  gem.email = "apm-insight@zohocorp.com"
23
- gem.authors = ["Rajalakshmi Ezhilan"]
23
+ gem.authors = ["Sabarinathan P"]
24
24
  gem.files=Dir.glob('lib/**/*.*')
25
25
  # dependencies defined in Gemfile
26
26
  end
@@ -48,7 +48,7 @@ Rake::RDocTask.new do |rdoc|
48
48
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
49
49
 
50
50
  rdoc.rdoc_dir = 'rdoc'
51
- rdoc.title = "site24x7_apminsight #{version}"
51
+ rdoc.title = "apminsight #{version}"
52
52
  rdoc.rdoc_files.include('README*')
53
53
  rdoc.rdoc_files.include('lib/**/*.*')
54
54
  rdoc.rdoc_files.include('lib/agent/**/*.*')
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.8.2
1
+ 1.8.2
@@ -180,7 +180,7 @@ module ManageEngine
180
180
  @metric_overflow_t=250
181
181
  @dbmetric_overflow_t=500
182
182
  @trace_overflow_t=30
183
- @site24x7url = @obj.constants.site24x7USurl #default agent communication URL
183
+ #@site24x7url = @obj.constants.site24x7USurl #default agent communication URL
184
184
  @delayedStart = false
185
185
  end
186
186
 
@@ -385,6 +385,9 @@ module ManageEngine
385
385
  if defined?(Rainbows) then
386
386
  dispatcher = "rainbows"
387
387
  end
388
+ if defined?(Puma) then
389
+ dispatcher = "puma"
390
+ end
388
391
  dispatcher
389
392
  end
390
393
 
@@ -62,7 +62,7 @@ module APMInsight
62
62
 
63
63
  # Marks end of transaction
64
64
  if @rootTracker == tracker
65
- if @listenFlag < 1 || (@listenFlag >= 1 && @trackerCount > 1)
65
+ if @listenFlag < 1 || (@listenFlag >= 1 && @trackerCount > 0)
66
66
  # if some trackers are not closed, while processing the metrics, it may go into infinite loop
67
67
  if (@closedTrackerCount - @trackerCount) == 0
68
68
  sequenceBag = Hash.new
@@ -17,8 +17,10 @@ module ManageEngine
17
17
  @apdex_threshold = @obj.config.apdex_t * 1000
18
18
  #@obj.log.info "[FORMAT]"
19
19
  @transaction = Hash.new
20
+ @bgTransaction = Hash.new
20
21
  @db = Hash.new
21
22
  @instance = Hash.new
23
+ @bginstance = Hash.new
22
24
  @dbinstance = Hash.new
23
25
  @dboperations = Hash.new
24
26
  @keystoremove = Array.new
@@ -27,6 +29,7 @@ module ManageEngine
27
29
  updatetransaction value
28
30
  end
29
31
  updateinstance
32
+ updatebginstance
30
33
  updatedbinstance
31
34
 
32
35
  @transaction.each do |key,value|
@@ -39,6 +42,16 @@ module ManageEngine
39
42
  result.push(valArr)
40
43
  end
41
44
 
45
+ @bgTransaction.each do |key,value|
46
+ res = Hash.new
47
+ res[@obj.constants.mf_namespace] = key
48
+ res[@obj.constants.mf_name] = @obj.constants.mf_bckgrnd
49
+ valArr= Array.new
50
+ valArr[0] =res
51
+ valArr[1] =value
52
+ result.push(valArr)
53
+ end
54
+
42
55
  @db.each do |key,value|
43
56
  #puts "#{key} == #{value}"
44
57
  res = Hash.new
@@ -58,6 +71,15 @@ module ManageEngine
58
71
  valArr[1] =value
59
72
  result.push(valArr)
60
73
  end
74
+ @bginstance.each do |key,value|
75
+ res = Hash.new
76
+ res[@obj.constants.mf_namespace] = ""
77
+ res[@obj.constants.mf_name] = @obj.constants.mf_bckgrnd
78
+ valArr= Array.new
79
+ valArr[0] =res
80
+ valArr[1] =value
81
+ result.push(valArr)
82
+ end
61
83
  @dbinstance.each do |key,value|
62
84
  res = Hash.new
63
85
  res[@obj.constants.mf_namespace] = ""
@@ -95,8 +117,13 @@ module ManageEngine
95
117
  end
96
118
 
97
119
  def updateinstance
120
+ if (@transaction.size == 0)
121
+ return
122
+ end
123
+
98
124
  ins_apdx = [0,-1,-1,0,0,0,0,0,0]
99
125
  logmetric = Hash.new
126
+ error_rt = 0
100
127
  @transaction.each do |key,value|
101
128
  apdexValue = value[0]
102
129
  ins_apdx[0] += apdexValue[0]
@@ -117,7 +144,10 @@ module ManageEngine
117
144
  ins_apdx[6] += apdexValue[6]
118
145
  ins_apdx[7] += apdexValue[7]
119
146
  ins_apdx[8] += apdexValue[8]
120
-
147
+ ert = value[1][@obj.constants.error_rt]
148
+ if (ert != nil)
149
+ error_rt += ert
150
+ end
121
151
  exceptions = value[1][@obj.constants.mf_logmetric]
122
152
  if (exceptions != nil)
123
153
  exceptions.each do |name, count|
@@ -129,9 +159,48 @@ module ManageEngine
129
159
  ins_apdx[4] = (ins_apdx[5].to_f + (ins_apdx[6]/2).to_f).to_f/ins_apdx[3].to_f
130
160
  ins_apdx[0] = ins_apdx[0].round(2)
131
161
  end
132
- @instance[":apdex"]=[ins_apdx, {@obj.constants.mf_logmetric=>logmetric}]
162
+ @instance[":apdex"]=[ins_apdx, {@obj.constants.mf_logmetric=>logmetric, @obj.constants.error_rt=>error_rt}]
133
163
  end
134
164
 
165
+ def updatebginstance
166
+ if (@bgTransaction.size == 0)
167
+ return
168
+ end
169
+
170
+ stats = [0,-1,-1,0,0]
171
+ logmetric = Hash.new
172
+ error_rt = 0
173
+ @bgTransaction.each do |key,value|
174
+ txnValue = value[0]
175
+ stats[0] += txnValue[0]
176
+ if stats[1] == -1
177
+ stats[1] = txnValue[1]
178
+ stats[2] = txnValue[2]
179
+ else
180
+ if(txnValue[1]<stats[1])
181
+ stats[1] = txnValue[1]
182
+ end
183
+ if (txnValue[2]>stats[2])
184
+ stats[2] = txnValue[2]
185
+ end
186
+ end
187
+ stats[3] += txnValue[3]
188
+ stats[4] += txnValue[4]
189
+
190
+ ert = value[1][@obj.constants.error_rt]
191
+ if (ert != nil)
192
+ error_rt += ert
193
+ end
194
+ exceptions = value[1][@obj.constants.mf_logmetric]
195
+ if (exceptions != nil)
196
+ exceptions.each do |name, count|
197
+ logmetric[name] = logmetric[name].to_i + count
198
+ end
199
+ end
200
+ end
201
+ @bginstance[":bckgrnd"]=[stats, {@obj.constants.mf_logmetric=>logmetric, @obj.constants.error_rt=>error_rt}]
202
+ end
203
+
135
204
  def updatedbinstance
136
205
  cnt = 0;
137
206
  rt = 0;
@@ -166,42 +235,91 @@ module ManageEngine
166
235
  exc = d["exception"]
167
236
 
168
237
  rt = pl["rt"].round(2)
169
- path = @obj.constants.mf_transaction + @obj.constants.mf_separator + pl["path"]
170
-
171
-
172
- apx_stat = nil
173
- additionalInfo = nil
174
- if(@transaction.has_key?(path))
175
- apx_stat = @transaction[path][0]
176
- additionalInfo = @transaction[path][1]
177
- else
178
- if @transaction.length == @obj.config.metric_overflow_t
179
- @obj.log.debug "Metricstore overflow. Current Size: #{@obj.config.metric_overflow_t} #{path}"
180
- return
181
- end
182
- apx_stat = Array.new
183
- apx_stat = [0,0,0,0,0,0,0,0,0]
184
- additionalInfo = Hash.new
185
- end
238
+ # path = @obj.constants.mf_transaction + @obj.constants.mf_separator + pl["path"]
239
+ path = pl["path"]
186
240
 
187
- if (pl.has_key?("error"))
188
- apx_stat[8] += 1
189
- else
190
- apx_stat = apxarray apx_stat,rt
191
- end
241
+ if (pl["type"] == @obj.constants.mf_http)
242
+ apx_stat = nil
243
+ additionalInfo = nil
244
+ if(@transaction.has_key?(path))
245
+ apx_stat = @transaction[path][0]
246
+ additionalInfo = @transaction[path][1]
247
+ else
248
+ if @transaction.length == @obj.config.metric_overflow_t
249
+ @obj.log.debug "Metricstore overflow. Current Size: #{@obj.config.metric_overflow_t} #{path}"
250
+ return
251
+ end
252
+
253
+ apx_stat = Array.new
254
+ apx_stat = [0,0,0,0,0,0,0,0,0]
255
+ additionalInfo = Hash.new
256
+ end
257
+
258
+ if (pl.has_key?("error"))
259
+ apx_stat[8] += 1
260
+ if (additionalInfo[@obj.constants.error_rt] == nil)
261
+ additionalInfo[@obj.constants.error_rt] = rt
262
+ else
263
+ additionalInfo[@obj.constants.error_rt] += rt
264
+ end
265
+ else
266
+ apx_stat = apxarray apx_stat,rt
267
+ end
192
268
 
193
- if (exc != nil)
194
- logmetric = additionalInfo[@obj.constants.mf_logmetric]
195
- if (logmetric == nil)
196
- additionalInfo[@obj.constants.mf_logmetric] = exc
197
- else
198
- exc.each do |name, count|
199
- logmetric[name] = logmetric[name].to_i + count
269
+ if (exc != nil)
270
+ logmetric = additionalInfo[@obj.constants.mf_logmetric]
271
+ if (logmetric == nil)
272
+ additionalInfo[@obj.constants.mf_logmetric] = exc
273
+ else
274
+ exc.each do |name, count|
275
+ logmetric[name] = logmetric[name].to_i + count
276
+ end
277
+ end
278
+ end
279
+
280
+ @transaction[path] = [apx_stat, additionalInfo]
281
+ else
282
+ stat = nil
283
+ additionalInfo = nil
284
+ if(@bgTransaction.has_key?(path))
285
+ stat = @bgTransaction[path][0]
286
+ additionalInfo = @bgTransaction[path][1]
287
+ else
288
+ if @bgTransaction.length == @obj.config.metric_overflow_t
289
+ @obj.log.debug "Metricstore overflow. Current Size: #{@obj.config.metric_overflow_t} #{path}"
290
+ return
200
291
  end
292
+
293
+ stat = Array.new
294
+ stat = [0,0,0,0,0]
295
+ additionalInfo = Hash.new
201
296
  end
202
- end
203
-
204
- @transaction[path] = [apx_stat, additionalInfo]
297
+
298
+ if (pl.has_key?("error"))
299
+ stat[4] += 1
300
+ if (additionalInfo[@obj.constants.error_rt] == nil)
301
+ additionalInfo[@obj.constants.error_rt] = rt
302
+ else
303
+ additionalInfo[@obj.constants.error_rt] += rt
304
+ end
305
+ else
306
+ stat = updatert stat,rt
307
+ end
308
+
309
+ if (exc != nil)
310
+ logmetric = additionalInfo[@obj.constants.mf_logmetric]
311
+ if (logmetric == nil)
312
+ additionalInfo[@obj.constants.mf_logmetric] = exc
313
+ else
314
+ exc.each do |name, count|
315
+ logmetric[name] = logmetric[name].to_i + count
316
+ end
317
+ end
318
+ end
319
+
320
+ @bgTransaction[path] = [stat, additionalInfo]
321
+ end
322
+
205
323
  if(dbl!=nil)
206
324
  if @db.length < @obj.config.dbmetric_overflow_t
207
325
  updatedb dbl,path
@@ -95,7 +95,7 @@ module ManageEngine
95
95
  end
96
96
  begin
97
97
  trdata = getTrace(rootTracker)
98
- trac = updateTrace(rootTracker.url, trdata, exceptionInfo)
98
+ trac = updateTrace(rootTracker, trdata, exceptionInfo)
99
99
  if(parseddata.has_key?("trace-data"))
100
100
  traceData = parseddata["trace-data"];
101
101
  traceData.push(trac);
@@ -136,7 +136,7 @@ module ManageEngine
136
136
  ret = tdata["td"]
137
137
  ret["rt"] = ret["rt"] + rootTracker.duration
138
138
  else
139
- ret = {"rt"=> rootTracker.duration, "path"=>rootTracker.url}
139
+ ret = {"rt"=> rootTracker.duration, "path"=>rootTracker.getTxnName, "type"=>rootTracker.getTxnType}
140
140
  if (rootTracker.error?)
141
141
  ret["error"] = true
142
142
  end
@@ -193,10 +193,10 @@ module ManageEngine
193
193
  excData[@obj.constants.mf_logmetric_warning] = excData[@obj.constants.mf_logmetric_warning].to_i + 1
194
194
  end
195
195
 
196
- def updateTrace(url, trans, exceptionInfo)
196
+ def updateTrace(roottracker, trans, exceptionInfo)
197
197
  # {"thread_name":"http-8080-6","s_time":1326276180289,"t_name":"transaction\/http\/Test-App\/login","r_time":18,"thread_id":141}
198
198
  top = Array.new
199
- path = @obj.constants.mf_transaction + @obj.constants.mf_separator + url
199
+ path = roottracker.getTxnName
200
200
  det = {"thread_name"=>"rorthread","s_time"=>trans[0],"t_name"=>path,"r_time"=>trans[3],"thread_id"=>141}
201
201
 
202
202
  exception = trans[5] != nil ? trans[5][@obj.constants.mf_exception_st] : nil
@@ -2,6 +2,8 @@ require 'agent/server/instrument/rails'
2
2
  require 'agent/server/instrument/sinatra'
3
3
  require 'agent/server/instrument/active_record'
4
4
  require 'agent/server/instrument/action_view'
5
+ require 'agent/server/instrument/sidekiq_server'
6
+ require 'agent/server/instrument/puma'
5
7
 
6
8
  module ManageEngine
7
9
  class Environment
@@ -16,7 +18,9 @@ module ManageEngine
16
18
  ]
17
19
 
18
20
  OTHER_INTERCEPTORS = [
19
- ManageEngine::Instrumentation::ActionView.new
21
+ ManageEngine::Instrumentation::ActionView.new,
22
+ ManageEngine::Instrumentation::SidekiqServer.new,
23
+ ManageEngine::Instrumentation::PumaWorker.new
20
24
  ]
21
25
 
22
26
  def detect_and_instrument
@@ -0,0 +1,39 @@
1
+ module ManageEngine
2
+ module Instrumentation
3
+ class PumaWorker
4
+
5
+ def present?
6
+ defined?(Puma::Server)
7
+ end
8
+
9
+ def version
10
+ Puma::Const::PUMA_VERSION
11
+ end
12
+
13
+ def env
14
+ ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development'
15
+ end
16
+
17
+ def name
18
+ 'Puma Worker'
19
+ end
20
+
21
+ def instrument
22
+ ManageEngine::APMObjectHolder.instance.log.info "Instrumenting Puma server workers. Version: #{version}"
23
+ Puma::Server.class_eval do
24
+ include ManageEngine::Instrumentation::PumaRun
25
+ alias original_run run
26
+ alias run agent_run
27
+ end
28
+ end
29
+ end
30
+
31
+ module PumaRun
32
+ def agent_run(*args, &block)
33
+ ::ManageEngine::APMObjectHolder.instance.agent.doCollect
34
+ original_run(*args, &block)
35
+ end
36
+ end
37
+
38
+ end
39
+ end
@@ -24,6 +24,8 @@ module ManageEngine
24
24
  'Rails'
25
25
  end
26
26
 
27
+ # https://edgeguides.rubyonrails.org/active_support_instrumentation.html#rails-framework-hooks
28
+
27
29
  def instrument
28
30
  @obj = ManageEngine::APMObjectHolder.instance
29
31
  @obj.log.info "Instrumenting ActionController.. Rails Version: #{version}"
@@ -31,6 +33,9 @@ module ManageEngine
31
33
 
32
34
  ActiveSupport::Notifications.subscribe('start_processing.action_controller') do |name, start, finish, id, payload|
33
35
  path = payload[:path].partition("?")[0]
36
+ # request = payload[:request]
37
+ # request.original_url => returns http://www.example.com/articles?page=2
38
+ # request.request_method
34
39
  @railsTracker = ManageEngine::Tracker::RootTracker.new("#{payload[:controller]}.#{payload[:action]}", start.to_f * 1000)
35
40
  @railsTracker.url=(path)
36
41
  @railsTracker = ManageEngine::Agent::TrackerHandler.invokeTracker(@railsTracker)
@@ -43,6 +48,7 @@ module ManageEngine
43
48
  exception = payload[:exception_object]
44
49
  if exception != nil
45
50
  @railsTracker.setError(exception)
51
+ # TODO: payload[:status]
46
52
  @railsTracker.setStatus(500) # By default, set 500 as status for error txns
47
53
  end
48
54
  ManageEngine::Agent::TrackerHandler.exitTracker(@railsTracker)
@@ -0,0 +1,38 @@
1
+ require 'agent/am_objectholder'
2
+ require 'agent/trackers/default_tracker'
3
+
4
+ module ManageEngine
5
+ module Instrumentation
6
+ class SidekiqClient
7
+ include Sidekiq::ClientMiddleware if defined?(Sidekiq::ClientMiddleware)
8
+
9
+ def call(worker, msg, queue, *_)
10
+ tracker = nil
11
+ result = nil
12
+ begin
13
+ # https://github.com/sidekiq/sidekiq/blob/main/lib/sidekiq/middleware/chain.rb
14
+ # Check comment section
15
+ jobName = msg["class"]
16
+ tracker = ManageEngine::Tracker::DefaultTracker.new("Sidekiq - " + msg["class"] + " - Job Id: " + msg["jid"])
17
+ tracker = ManageEngine::Agent::TrackerHandler.invokeTracker(tracker)
18
+ rescue Exception=>e
19
+ ManageEngine::APMObjectHolder.instance.log.info "Exception while creating tracker for sidekiq_client #{e}"
20
+ end
21
+ begin
22
+ result = yield
23
+ rescue Exception=>e
24
+ if (tracker != nil)
25
+ tracker.setError(e)
26
+ end
27
+ raise e
28
+ ensure
29
+ if tracker != nil
30
+ tracker.finish
31
+ ManageEngine::Agent::TrackerHandler.exitTracker(tracker)
32
+ end
33
+ end
34
+ result
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,66 @@
1
+ require 'agent/am_objectholder'
2
+ require 'agent/trackers/root_tracker'
3
+ require 'agent/server/instrument/sidekiq_client'
4
+
5
+ module ManageEngine
6
+ module Instrumentation
7
+ class SidekiqServer
8
+ include Sidekiq::ServerMiddleware if defined?(Sidekiq::ServerMiddleware)
9
+
10
+ def present?
11
+ defined?(::Sidekiq::ServerMiddleware)
12
+ end
13
+
14
+ def version
15
+ Sidekiq::VERSION
16
+ end
17
+
18
+ def name
19
+ 'Sidekiq'
20
+ end
21
+
22
+ def instrument
23
+ ::Sidekiq.configure_server do |config|
24
+ config.server_middleware do |chain|
25
+ chain.add(ManageEngine::Instrumentation::SidekiqServer)
26
+ end
27
+ end
28
+ ::Sidekiq.configure_client do |config|
29
+ config.client_middleware do |chain|
30
+ chain.add(ManageEngine::Instrumentation::SidekiqClient)
31
+ end
32
+ end
33
+ ManageEngine::APMObjectHolder.instance.log.info "Instrumenting #{name} Version: #{version}"
34
+ end
35
+
36
+ def call(worker, msg, queue, *_)
37
+ tracker = nil
38
+ begin
39
+ # https://github.com/sidekiq/sidekiq/blob/main/lib/sidekiq/middleware/chain.rb
40
+ # Check comment section
41
+ jobName = msg["class"]+".perform"
42
+ tracker = ManageEngine::Tracker::RootTracker.new(jobName + " jid: " + msg["jid"])
43
+ tracker.url = jobName
44
+ tracker.setTxnType(ManageEngine::APMObjectHolder.instance.constants.mf_bckgrnd)
45
+ #tracker.addAdditionalInfo(msg)
46
+ tracker = ManageEngine::Agent::TrackerHandler.invokeTracker(tracker)
47
+ rescue Exception=>e
48
+ ManageEngine::APMObjectHolder.instance.log.info "Exception while creating tracker for sidekiq_server #{e}"
49
+ end
50
+ begin
51
+ yield
52
+ rescue Exception=>e
53
+ if (tracker != nil)
54
+ tracker.setError(e)
55
+ end
56
+ raise e
57
+ ensure
58
+ if tracker != nil
59
+ tracker.finish
60
+ ManageEngine::Agent::TrackerHandler.exitTracker(tracker)
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -231,6 +231,8 @@ class APMWorker
231
231
  if tdata.has_key?(name)
232
232
  if (sd[0]["name"]=="apdex")
233
233
  tdata[name][1] = mapdx(tdata[name][1],sd[1])
234
+ elsif (sd[0]["name"]=="bckgrnd")
235
+ tdata[name][1] = mapbg(tdata[name][1],sd[1])
234
236
  else
235
237
  tdata[name][1] = mapdb(tdata[name][1],sd[1])
236
238
  end
@@ -263,7 +265,7 @@ class APMWorker
263
265
  rtData[7] = rtData[7]+dat[0][7]
264
266
  rtData[4] = rtData[3] != 0 ? (rtData[5].to_f + (rtData[6].to_f/2).to_f).to_f/rtData[3].to_f : 0
265
267
  res[0] = rtData
266
-
268
+ res[1][@obj.constants.error_rt] += dat[1][@obj.constants.error_rt]
267
269
  resExcepData = res[1][@obj.constants.mf_logmetric]
268
270
  excepData = dat[1][@obj.constants.mf_logmetric]
269
271
  if (resExcepData == nil)
@@ -281,6 +283,36 @@ class APMWorker
281
283
  res
282
284
  end
283
285
 
286
+ def mapbg res,dat
287
+ begin
288
+ rtData = res[0];
289
+ rtData[0] = rtData[0]+dat[0][0];
290
+ if dat[0][1]<rtData[1]
291
+ rtData[1]=dat[0][1]
292
+ end
293
+ if dat[0][2]>rtData[2]
294
+ rtData[2]=dat[0][2]
295
+ end
296
+ rtData[3] = rtData[3]+dat[0][3]
297
+ rtData[4] = rtData[4]+dat[0][4]
298
+ res[0] = rtData
299
+ res[1][@obj.constants.error_rt] += dat[1][@obj.constants.error_rt]
300
+ resExcepData = res[1][@obj.constants.mf_logmetric]
301
+ excepData = dat[1][@obj.constants.mf_logmetric]
302
+ if (resExcepData == nil)
303
+ resExcepData = excepData
304
+ else
305
+ if (excepData != nil)
306
+ resExcepData = resExcepData.merge(excepData){|key, oldval, newval| newval + oldval}
307
+ end
308
+ end
309
+
310
+ res[1][@obj.constants.mf_logmetric] = resExcepData != nil ? resExcepData : Hash.new
311
+ rescue Exception=>e
312
+ @obj.log.logException "Exception while merging bg data",e
313
+ end
314
+ res
315
+ end
284
316
  def mapdb res,dat
285
317
  res[0] = res[0]+dat[0];
286
318
  if dat[1]<res[1]
@@ -63,7 +63,7 @@ module ManageEngine
63
63
  return [sqlArr[0], tableName]
64
64
 
65
65
  rescue Exception=>e
66
- @logger.logException "#{e.message}",e
66
+ @logger.logException "Error processing query #{sql} Exception: #{e.message}",e
67
67
  return [sqlArr[0], '-']
68
68
  end
69
69
  end
@@ -4,12 +4,27 @@ module ManageEngine
4
4
  module Tracker
5
5
  class RootTracker < DefaultTracker
6
6
 
7
- attr_accessor :status, :url
7
+ attr_accessor :status, :url, :txnType
8
8
 
9
9
  def url=(url = "unknown")
10
10
  @url = ManageEngine::APMObjectHolder.instance.txn_util.normalizeName(url)
11
11
  end
12
12
 
13
+ def getTxnName
14
+ ManageEngine::APMObjectHolder.instance.constants.mf_transaction + getTxnType() + ManageEngine::APMObjectHolder.instance.constants.mf_separator + @url
15
+ end
16
+
17
+ def setTxnType(type)
18
+ @txnType=type
19
+ end
20
+
21
+ def getTxnType
22
+ if (@txnType == nil)
23
+ @txnType = ManageEngine::APMObjectHolder.instance.constants.mf_http
24
+ end
25
+ @txnType
26
+ end
27
+
13
28
  def http_method(method)
14
29
  @http_method = method
15
30
  end
@@ -26,6 +41,17 @@ module ManageEngine
26
41
  @status = httpcode
27
42
  end
28
43
 
44
+ def addCustomParam key, value
45
+ if (@params == nil)
46
+ @params = Hash.new
47
+ end
48
+ @params[key] = value
49
+ end
50
+
51
+ def addAdditionalInfo param
52
+ @params = param
53
+ end
54
+
29
55
  def getAdditionalInfo
30
56
  info = super
31
57
  if (@http_method != nil && @queryString != nil && @status != nil)
@@ -36,6 +62,12 @@ module ManageEngine
36
62
  info["http_query_str"] = @queryString
37
63
  info["httpcode"] = @status
38
64
  end
65
+ if (@params != nil)
66
+ if (info == nil)
67
+ info = Hash.new
68
+ end
69
+ info["custom_params"] = @params
70
+ end
39
71
  info
40
72
  end
41
73
  end
@@ -5,8 +5,8 @@ module ManageEngine
5
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
6
  attr_reader :site24x7USurl, :site24x7EUurl, :site24x7CNurl, :site24x7INurl, :site24x7AUurl, :site24x7GDurl, :site24x7JPurl, :site24x7CAurl, :site24x7SAurl, :site24x7UKurl, :site24x7HDFCurl
7
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
8
+ attr_reader :mf_transaction,:mf_separator,:mf_db,:mf_apdex,:mf_http,:mf_bckgrnd,:mf_namespace,:mf_name,:mf_all,:agent_store,:agent_lock,:mf_overflow
9
+ attr_reader :error_rt, :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
10
  attr_reader :en_alphabets, :en_numerals
11
11
 
12
12
  def initialize
@@ -82,10 +82,13 @@ module ManageEngine
82
82
  @mf_all = "all"
83
83
 
84
84
  @mf_separator = "/"
85
- @mf_transaction = "transaction" + @mf_separator + "http"
85
+ @mf_transaction = "transaction" + @mf_separator
86
86
  @mf_db = "db"
87
87
  @mf_overflow = "0verf10w"
88
+ @mf_http = "http"
89
+ @mf_bckgrnd = "bckgrnd"
88
90
 
91
+ @error_rt = "error_rt"
89
92
  @mf_logmetric = "logmetric"
90
93
  @mf_logmetric_warning = "warning"
91
94
  @mf_err_st = "err_st"
data/lib/agent/version.rb CHANGED
@@ -6,8 +6,8 @@
6
6
 
7
7
  module ManageEngine
8
8
  class APMInsight
9
- VERSION = '1.8.8'
10
- MAJOR_VERSION = '1.8'
11
- MINOR_VERSION = '8'
9
+ VERSION = '1.9.1'
10
+ MAJOR_VERSION = '1.9'
11
+ MINOR_VERSION = '1'
12
12
  end
13
13
  end
metadata CHANGED
@@ -1,110 +1,103 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: site24x7_apminsight
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 8
8
- - 8
9
- version: 1.8.8
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.9.1
10
5
  platform: ruby
11
- authors:
6
+ authors:
12
7
  - Adithyan P
13
8
  autorequire:
14
9
  bindir: bin
15
10
  cert_chain: []
16
-
17
- date: 2024-01-31 00:00:00 +05:30
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
11
+ date: 2024-06-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
21
14
  name: shoulda
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
26
17
  - - ">="
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- version: "0"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
31
20
  type: :development
32
- version_requirements: *id001
33
- - !ruby/object:Gem::Dependency
34
- name: bundler
35
21
  prerelease: false
36
- requirement: &id002 !ruby/object:Gem::Requirement
37
- none: false
38
- requirements:
39
- - - ~>
40
- - !ruby/object:Gem::Version
41
- segments:
42
- - 1
43
- - 0
44
- - 0
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
45
33
  version: 1.0.0
46
34
  type: :development
47
- version_requirements: *id002
48
- - !ruby/object:Gem::Dependency
49
- name: jeweler
50
35
  prerelease: false
51
- requirement: &id003 !ruby/object:Gem::Requirement
52
- none: false
53
- requirements:
54
- - - ~>
55
- - !ruby/object:Gem::Version
56
- segments:
57
- - 1
58
- - 6
59
- - 4
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: jeweler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
60
47
  version: 1.6.4
61
48
  type: :development
62
- version_requirements: *id003
63
- - !ruby/object:Gem::Dependency
64
- name: rcov
65
49
  prerelease: false
66
- requirement: &id004 !ruby/object:Gem::Requirement
67
- none: false
68
- requirements:
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.6.4
55
+ - !ruby/object:Gem::Dependency
56
+ name: rcov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
69
59
  - - ">="
70
- - !ruby/object:Gem::Version
71
- segments:
72
- - 0
73
- version: "0"
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
74
62
  type: :development
75
- version_requirements: *id004
76
- - !ruby/object:Gem::Dependency
77
- name: rails
78
63
  prerelease: false
79
- requirement: &id005 !ruby/object:Gem::Requirement
80
- none: false
81
- requirements:
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
82
73
  - - ">="
83
- - !ruby/object:Gem::Version
84
- segments:
85
- - 3
86
- - 0
87
- - 0
74
+ - !ruby/object:Gem::Version
88
75
  version: 3.0.0
89
76
  type: :development
90
- version_requirements: *id005
91
- description: Site24x7 APMInsight 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 Ruby agent(site24x7_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 your user account in Site24x7
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 3.0.0
83
+ description: Site24x7 APMInsight gives you end-to-end web-transaction awareness of
84
+ Rails applications enabling you to isolate performance issues and resolve them quickly.
85
+ To monitor Rails application performance, download and deploy Ruby agent(site24x7_apminsight)
86
+ in your Application Server. This agent allows you to send information about Ruby
87
+ applications. You can install APM Insight Agent via Rubygems or download it from
88
+ your user account in Site24x7
92
89
  email: apm-insight@zohocorp.com
93
90
  executables: []
94
-
95
91
  extensions: []
96
-
97
- extra_rdoc_files:
92
+ extra_rdoc_files:
98
93
  - LICENSE.txt
99
94
  - README.rdoc
100
- files:
95
+ files:
101
96
  - LICENSE.txt
102
97
  - README.rdoc
103
98
  - Rakefile
104
99
  - VERSION
105
- - site24x7-agent.gemspec
106
100
  - conf/apminsight.conf
107
- - lib/site24x7_apminsight.rb
108
101
  - lib/agent/am_objectholder.rb
109
102
  - lib/agent/api/custom_tracker.rb
110
103
  - lib/agent/configuration/am_configuration.rb
@@ -124,7 +117,10 @@ files:
124
117
  - lib/agent/server/instrument/am_apm.rb
125
118
  - lib/agent/server/instrument/am_instrumenter.rb
126
119
  - lib/agent/server/instrument/environment.rb
120
+ - lib/agent/server/instrument/puma.rb
127
121
  - lib/agent/server/instrument/rails.rb
122
+ - lib/agent/server/instrument/sidekiq_client.rb
123
+ - lib/agent/server/instrument/sidekiq_server.rb
128
124
  - lib/agent/server/instrument/sinatra.rb
129
125
  - lib/agent/server/worker/am_worker.rb
130
126
  - lib/agent/trackers/database_tracker.rb
@@ -134,37 +130,33 @@ files:
134
130
  - lib/agent/util/am_util.rb
135
131
  - lib/agent/util/transaction_util.rb
136
132
  - lib/agent/version.rb
137
- has_rdoc: true
133
+ - lib/site24x7_apminsight.rb
134
+ - site24x7-agent.gemspec
138
135
  homepage: https://www.site24x7.com/help/apm/ruby-agent.html
139
136
  licenses: []
140
-
137
+ metadata: {}
141
138
  post_install_message:
142
139
  rdoc_options: []
143
-
144
- require_paths:
140
+ require_paths:
145
141
  - lib
146
- required_ruby_version: !ruby/object:Gem::Requirement
147
- none: false
148
- requirements:
142
+ required_ruby_version: !ruby/object:Gem::Requirement
143
+ requirements:
149
144
  - - ">="
150
- - !ruby/object:Gem::Version
151
- segments:
152
- - 0
153
- version: "0"
154
- required_rubygems_version: !ruby/object:Gem::Requirement
155
- none: false
156
- requirements:
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ required_rubygems_version: !ruby/object:Gem::Requirement
148
+ requirements:
157
149
  - - ">="
158
- - !ruby/object:Gem::Version
159
- segments:
160
- - 0
161
- version: "0"
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
162
152
  requirements: []
163
-
164
- rubyforge_project:
165
- rubygems_version: 1.3.7
153
+ rubygems_version: 3.0.0
166
154
  signing_key:
167
155
  specification_version: 3
168
- summary: Site24x7 APMInsight 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 Ruby agent(site24x7_apminsight.gem) 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 your user account in Site24x7
156
+ summary: Site24x7 APMInsight gives you end-to-end web-transaction awareness of Rails
157
+ applications enabling you to isolate performance issues and resolve them quickly.
158
+ To monitor Rails application performance, download and deploy Ruby agent(site24x7_apminsight.gem)
159
+ in your Application Server. This agent allows you to send information about Ruby
160
+ applications. You can install APM Insight Agent via Rubygems or download it from
161
+ your user account in Site24x7
169
162
  test_files: []
170
-