scout_apm 2.4.11.pre → 2.4.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1686beb2285cb415ac0f73e4dfa65524b85a369d
4
- data.tar.gz: f56d09891f9b899721c711f43dc48e06160073b1
3
+ metadata.gz: b51f36211c52637ac2eba181cf772f6e80e4476f
4
+ data.tar.gz: fef360f94b747d5fe67acb6fcc1ced25ddf80dce
5
5
  SHA512:
6
- metadata.gz: 3af376cdc73869c73775ca02aaad1817fa735a7b2c73521fe2015f0584c5085e50f7ec94c40bc402363c691e70d98c6cfbc4d0887ff1b0cb7082efeae1bc2578
7
- data.tar.gz: 6ace83f9f30fd8bfeb48875e6a58c508f2cc65f1fafd36e8fc1e6421c6556ddc096a27396dc2546ae623af9765586da976da64b6cec9654c29c71feea0927bd6
6
+ metadata.gz: a18c8bcc6c39c1d7448b2c715e006e7498db48973e1789b60f585e4357393c545033e5fe677aa11ea2d6f4a16b2b396c579575fad3758c464680317f48f5dfa2
7
+ data.tar.gz: d5aea617adf94ef945769198b42e995423fc9dec15dff9a57a292326bb535da20596bb9908c205315051be617b7ad3d08f640e95fa39470476b69577121e07fa
data/CHANGELOG.markdown CHANGED
@@ -1,6 +1,7 @@
1
1
  # 2.4.11
2
2
 
3
3
  * Adds transaction + periodic reporting callback extension support
4
+ * Use Module#prepend if available for ActiveRecord `exec_query` instrument
4
5
 
5
6
  # 2.4.10
6
7
 
@@ -165,15 +165,23 @@ module ScoutApm
165
165
  end
166
166
 
167
167
  def ruby_19?
168
- @ruby_19 ||= defined?(RUBY_ENGINE) && RUBY_ENGINE == "ruby" && RUBY_VERSION.match(/^1\.9/)
168
+ return @ruby_19 if defined?(@ruby_19)
169
+ @ruby_19 = defined?(RUBY_ENGINE) && RUBY_ENGINE == "ruby" && RUBY_VERSION.match(/^1\.9/)
169
170
  end
170
171
 
171
172
  def ruby_187?
172
- @ruby_187 ||= defined?(RUBY_VERSION) && RUBY_VERSION.match(/^1\.8\.7/)
173
+ return @ruby_187 if defined?(@ruby_187)
174
+ @ruby_187 = defined?(RUBY_VERSION) && RUBY_VERSION.match(/^1\.8\.7/)
173
175
  end
174
176
 
175
177
  def ruby_2?
176
- @ruby_2 ||= defined?(RUBY_VERSION) && RUBY_VERSION.match(/^2/)
178
+ return @ruby_2 if defined?(@ruby_2)
179
+ @ruby_2 = defined?(RUBY_VERSION) && RUBY_VERSION.match(/^2/)
180
+ end
181
+
182
+ # Returns true if this Ruby version supports Module#prepend.
183
+ def supports_module_prepend?
184
+ ruby_2?
177
185
  end
178
186
 
179
187
  # Returns a string representation of the OS (ex: darwin, linux)
@@ -118,8 +118,14 @@ module ScoutApm
118
118
  (::ActiveRecord::VERSION::MAJOR.to_i == 3 && ::ActiveRecord::VERSION::MINOR.to_i >= 2))
119
119
  if rails_3_2_or_above
120
120
  if Utils::KlassHelper.defined?("ActiveRecord::Relation")
121
- ::ActiveRecord::Relation.module_eval do
122
- include ::ScoutApm::Instruments::ActiveRecordRelationQueryInstruments
121
+ if @context.environment.supports_module_prepend?
122
+ ::ActiveRecord::Relation.module_eval do
123
+ prepend ::ScoutApm::Instruments::ActiveRecordRelationQueryInstruments
124
+ end
125
+ else
126
+ ::ActiveRecord::Relation.module_eval do
127
+ include ::ScoutApm::Instruments::ActiveRecordRelationQueryInstruments
128
+ end
123
129
  end
124
130
  end
125
131
  else
@@ -298,6 +304,10 @@ module ScoutApm
298
304
  end
299
305
 
300
306
  module ActiveRecordRelationQueryInstruments
307
+ def self.prepended(instrumented_class)
308
+ ScoutApm::Agent.instance.context.logger.info "Instrumenting ActiveRecord::Relation#exec_queries - #{instrumented_class.inspect} (prepending)"
309
+ end
310
+
301
311
  def self.included(instrumented_class)
302
312
  ScoutApm::Agent.instance.context.logger.info "Instrumenting ActiveRecord::Relation#exec_queries - #{instrumented_class.inspect}"
303
313
  instrumented_class.class_eval do
@@ -308,7 +318,7 @@ module ScoutApm
308
318
  end
309
319
  end
310
320
 
311
- def exec_queries_with_scout_instruments(*args, &block)
321
+ def exec_queries(*args, &block)
312
322
  req = ScoutApm::RequestManager.lookup
313
323
  layer = ScoutApm::Layer.new("ActiveRecord", Utils::ActiveRecordMetricName::DEFAULT_METRIC)
314
324
  layer.annotate_layer(:ignorable => true)
@@ -316,12 +326,23 @@ module ScoutApm
316
326
  req.start_layer(layer)
317
327
  req.ignore_children!
318
328
  begin
319
- exec_queries_without_scout_instruments(*args, &block)
329
+ if ScoutApm::Environment.instance.supports_module_prepend?
330
+ super(*args, &block)
331
+ else
332
+ exec_queries_without_scout_instruments(*args, &block)
333
+ end
320
334
  ensure
321
335
  req.acknowledge_children!
322
336
  req.stop_layer
323
337
  end
324
338
  end
339
+
340
+ # If prepend is not supported, rename the method and use
341
+ # alias_method_style chaining instead
342
+ if !ScoutApm::Environment.instance.supports_module_prepend?
343
+ alias_method :exec_queries_with_scout_instruments, :exec_queries
344
+ remove_method :exec_queries
345
+ end
325
346
  end
326
347
 
327
348
  module ActiveRecordUpdateInstruments
@@ -1,4 +1,4 @@
1
1
  module ScoutApm
2
- VERSION = "2.4.11.pre"
2
+ VERSION = "2.4.11"
3
3
  end
4
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scout_apm
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.11.pre
4
+ version: 2.4.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derek Haynes
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-04-11 00:00:00.000000000 Z
12
+ date: 2018-04-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -383,12 +383,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
383
383
  version: '0'
384
384
  required_rubygems_version: !ruby/object:Gem::Requirement
385
385
  requirements:
386
- - - ">"
386
+ - - ">="
387
387
  - !ruby/object:Gem::Version
388
- version: 1.3.1
388
+ version: '0'
389
389
  requirements: []
390
390
  rubyforge_project: scout_apm
391
- rubygems_version: 2.4.6
391
+ rubygems_version: 2.4.5.2
392
392
  signing_key:
393
393
  specification_version: 4
394
394
  summary: Ruby application performance monitoring
@@ -435,4 +435,3 @@ test_files:
435
435
  - test/unit/utils/backtrace_parser_test.rb
436
436
  - test/unit/utils/numbers_test.rb
437
437
  - test/unit/utils/scm.rb
438
- has_rdoc: