scout_apm 2.1.13 → 2.1.14

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: 270c8e00f124e50fa52444a01e1d17339ea46a86
4
- data.tar.gz: e9699a8a5614f9e752a0b64fba22079a655e52d1
3
+ metadata.gz: faa58ca3a2800e8aade5ade08a31d2c5db1e5a7d
4
+ data.tar.gz: ceb42f746d3b72eb84610522eeee9247fd68cf81
5
5
  SHA512:
6
- metadata.gz: 5e1935a1bdb172835103fc0b6a61ecf3e3306df472db5a87730c4d056cc20ad8fa36abde59b59bdf577e463645e57c358e6a12e3e719ca870811ed90d6bbe0ea
7
- data.tar.gz: e53d0af91f2de2f6123ade8b76744cdbf8b33bc10d13913aa930782a75b576b0db4b5a91b92bfe93b50dd15be4d90d8dce64fd6d9a56828eb29543544504a467
6
+ metadata.gz: b692efc8a697ffb71657d9c2493c1c4fd2bc003f5970155339654679832d6b7fd9da95d26bc0d2b46c153980da697532376556556ff8b2ba10140cc5fb398180
7
+ data.tar.gz: 3ae789a0000e598a39bce414c4955d13fa354e38f716d53ddb6041160a89fc9a500c3f1d1144095e0487722eedc2951cb6681e8db4f8917bf162adbc52112b51
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,9 @@
1
+ # 2.1.14
2
+
3
+ * Add TrackedRequest#ignore_request! to entirely ignore and stop capturing a
4
+ certain request. Use in your code by calling:
5
+ ScoutApm::RequestManager.lookup.ignore_request!
6
+
1
7
  # 2.1.13
2
8
 
3
9
  * Rework Delayed Job instrumentation to not interfere with other instruments.
@@ -50,6 +50,9 @@ module ScoutApm
50
50
  if ScoutApm::Agent.instance.config.value('dev_trace')
51
51
  if response.respond_to?(:body)
52
52
  req = ScoutApm::RequestManager.lookup
53
+
54
+ return [status, headers, response] if req.ignoring_request?
55
+
53
56
  slow_converter = LayerConverters::SlowRequestConverter.new(req)
54
57
  trace = slow_converter.call
55
58
  if trace
@@ -62,8 +62,10 @@ module ScoutApm
62
62
  layer = req.current_layer
63
63
  if layer && layer.type == "ActiveRecord"
64
64
  layer.annotate_layer(payload)
65
- else
65
+ elsif layer
66
66
  ScoutApm::Agent.instance.logger.debug("Expected layer type: ActiveRecord, got #{layer && layer.type}")
67
+ else
68
+ # noop, no layer at all. We're probably ignoring this req.
67
69
  end
68
70
  end
69
71
  end
@@ -22,12 +22,17 @@ module ScoutApm
22
22
  include ScoutApm::Tracer
23
23
 
24
24
  def request_with_scout_instruments(*args,&block)
25
- url = (@address + args.first.path.split('?').first)[0..99]
26
- self.class.instrument("HTTP", "request", :desc => url) do
25
+ self.class.instrument("HTTP", "request", :desc => request_scout_description(args.first)) do
27
26
  request_without_scout_instruments(*args, &block)
28
27
  end
29
28
  end
30
29
 
30
+ def request_scout_description(req)
31
+ path = req.path
32
+ path = path.path if path.respond_to?(:path)
33
+ (@address + path.split('?').first)[0..99]
34
+ end
35
+
31
36
  alias request_without_scout_instruments request
32
37
  alias request request_with_scout_instruments
33
38
  end
@@ -57,9 +57,9 @@ module ScoutApm
57
57
  end
58
58
 
59
59
  def start_layer(layer)
60
- if ignoring_children?
61
- return
62
- end
60
+ return if ignoring_children?
61
+
62
+ return ignoring_start_layer if ignoring_request?
63
63
 
64
64
  start_request(layer) unless @root_layer
65
65
  @layers[-1].add_child(layer) if @layers.any?
@@ -69,6 +69,8 @@ module ScoutApm
69
69
  def stop_layer
70
70
  return if ignoring_children?
71
71
 
72
+ return ignoring_stop_layer if ignoring_request?
73
+
72
74
  layer = @layers.pop
73
75
 
74
76
  # Safeguard against a mismatch in the layer tracking in an instrument.
@@ -110,6 +112,8 @@ module ScoutApm
110
112
 
111
113
  BACKTRACE_BLACKLIST = ["Controller", "Job"]
112
114
  def capture_backtrace?(layer)
115
+ return if ignoring_request?
116
+
113
117
  # Never capture backtraces for this kind of layer. The backtrace will
114
118
  # always be 100% framework code.
115
119
  return false if BACKTRACE_BLACKLIST.include?(layer.type)
@@ -210,6 +214,8 @@ module ScoutApm
210
214
  end
211
215
 
212
216
  def instant?
217
+ return false if ignoring_request?
218
+
213
219
  instant_key
214
220
  end
215
221
 
@@ -222,6 +228,8 @@ module ScoutApm
222
228
  def record!
223
229
  @recorded = true
224
230
 
231
+ return if ignoring_request?
232
+
225
233
  # Bail out early if the user asked us to ignore this uri
226
234
  return if ScoutApm::Agent.instance.ignored_uris.ignore?(annotations[:uri])
227
235
 
@@ -271,6 +279,8 @@ module ScoutApm
271
279
 
272
280
  # Only call this after the request is complete
273
281
  def unique_name
282
+ return nil if ignoring_request?
283
+
274
284
  @unique_name ||= begin
275
285
  scope_layer = LayerConverters::ConverterBase.new(self).scope_layer
276
286
  if scope_layer
@@ -285,6 +295,8 @@ module ScoutApm
285
295
  # Used to know when we should just create a new one (don't attempt to add
286
296
  # data to an already-recorded request). See RequestManager
287
297
  def recorded?
298
+ return ignoring_recorded? if ignoring_request?
299
+
288
300
  @recorded
289
301
  end
290
302
 
@@ -333,5 +345,48 @@ module ScoutApm
333
345
  def backtrace_threshold
334
346
  dev_trace ? 0.05 : 0.5 # the minimum threshold in seconds to record the backtrace for a metric.
335
347
  end
348
+
349
+ ################################################################################
350
+ # Ignoring the rest of a request
351
+ ################################################################################
352
+
353
+ # At any point in the request, calling code or instrumentation can call
354
+ # `ignore_request!` to immediately stop recording any information about new
355
+ # layers, and delete any existing layer info. This class will still exist,
356
+ # and respond to methods as normal, but `record!` won't be called, and no
357
+ # data will be recorded.
358
+
359
+ def ignore_request!
360
+ return if @ignoring_request
361
+
362
+ # Set instance variable
363
+ @ignoring_request = true
364
+
365
+ # Store data we'll need
366
+ @ignoring_depth = @layers.length
367
+
368
+ # Clear data
369
+ @layers = []
370
+ @root_layer = nil
371
+ @call_set = nil
372
+ @annotations = {}
373
+ @instant_key = nil
374
+ end
375
+
376
+ def ignoring_request?
377
+ @ignoring_request
378
+ end
379
+
380
+ def ignoring_start_layer
381
+ @ignoring_depth += 1
382
+ end
383
+
384
+ def ignoring_stop_layer
385
+ @ignoring_depth -= 1
386
+ end
387
+
388
+ def ignoring_recorded?
389
+ @ignoring_depth <= 0
390
+ end
336
391
  end
337
392
  end
@@ -1,4 +1,4 @@
1
1
  module ScoutApm
2
- VERSION = "2.1.13"
2
+ VERSION = "2.1.14"
3
3
  end
4
4
 
data/scout_apm.gemspec CHANGED
@@ -27,4 +27,5 @@ Gem::Specification.new do |s|
27
27
  s.add_development_dependency "m"
28
28
  s.add_development_dependency "simplecov"
29
29
  s.add_development_dependency "rake-compiler"
30
+ s.add_development_dependency "addressable"
30
31
  end
@@ -0,0 +1,21 @@
1
+ require 'test_helper'
2
+
3
+ require 'scout_apm/instruments/net_http'
4
+
5
+ require 'addressable'
6
+
7
+ class NetHttpTest < Minitest::Test
8
+ def setup
9
+ ScoutApm::Instruments::NetHttp.new.install
10
+ end
11
+
12
+ def test_request_scout_description_for_uri
13
+ req = Net::HTTP::Get.new(URI('http://example.org/here'))
14
+ assert_equal '/here', Net::HTTP.new('').request_scout_description(req)
15
+ end
16
+
17
+ def test_request_scout_description_for_addressable
18
+ req = Net::HTTP::Get.new(Addressable::URI.parse('http://example.org/here'))
19
+ assert_equal '/here', Net::HTTP.new('').request_scout_description(req)
20
+ end
21
+ end
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.1.13
4
+ version: 2.1.14
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: 2016-10-10 00:00:00.000000000 Z
12
+ date: 2016-11-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -95,6 +95,20 @@ dependencies:
95
95
  - - ">="
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: addressable
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
98
112
  description: Monitors Ruby apps and reports detailed metrics on performance to Scout.
99
113
  email:
100
114
  - support@scoutapp.com
@@ -234,6 +248,7 @@ files:
234
248
  - test/unit/histogram_test.rb
235
249
  - test/unit/ignored_uris_test.rb
236
250
  - test/unit/instruments/active_record_instruments_test.rb
251
+ - test/unit/instruments/net_http_test.rb
237
252
  - test/unit/instruments/percentile_sampler_test.rb
238
253
  - test/unit/layaway_test.rb
239
254
  - test/unit/metric_set_test.rb
@@ -267,7 +282,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
267
282
  version: '0'
268
283
  requirements: []
269
284
  rubyforge_project: scout_apm
270
- rubygems_version: 2.6.2
285
+ rubygems_version: 2.4.8
271
286
  signing_key:
272
287
  specification_version: 4
273
288
  summary: Ruby application performance monitoring
@@ -283,6 +298,7 @@ test_files:
283
298
  - test/unit/histogram_test.rb
284
299
  - test/unit/ignored_uris_test.rb
285
300
  - test/unit/instruments/active_record_instruments_test.rb
301
+ - test/unit/instruments/net_http_test.rb
286
302
  - test/unit/instruments/percentile_sampler_test.rb
287
303
  - test/unit/layaway_test.rb
288
304
  - test/unit/metric_set_test.rb
@@ -295,4 +311,3 @@ test_files:
295
311
  - test/unit/utils/active_record_metric_name_test.rb
296
312
  - test/unit/utils/backtrace_parser_test.rb
297
313
  - test/unit/utils/numbers_test.rb
298
- has_rdoc: