scout_apm 3.0.0.pre19 → 3.0.0.pre20

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: 0393ebae36fc959586f76135f0772c9353b2fb82
4
- data.tar.gz: d64a6fc7477a274b1a4712895ad62066b2653e4d
3
+ metadata.gz: f047a3fde038ff766a4257bd06039aaa57bc5eda
4
+ data.tar.gz: 2e3aecc744bff0176bb449f0bade29a43ff2810d
5
5
  SHA512:
6
- metadata.gz: c9281d472ab3df97780f5518a28c7e059c2e031693a47f91ad96d61b955a07678eb5960ee108a18a1b95d09355bd01f70f9aef3d9a9cbea09468c51ea77812ca
7
- data.tar.gz: ff8d0ea6114d2de8052780d029dc2c7451ff2e8ee40248e4912959f9fca0308fa0719066ec2e93e391d2c98dfb2ec3353b1883dd0854f084c89f6d6531554b25
6
+ metadata.gz: 57f0e123ba394164ea2263195a204f77787e254e8396bb5a0ca346523470f4e447e53b456005a082949e6f7f6a9154ac55b71cf701b19a7e8517f709591761fd
7
+ data.tar.gz: 555e23d6f39fd9c1ea919ab15f7fa28b868fef854c7f0dec610db7bc9ea20438de8d30a1c6c932e7d389cd5bd40f2a3b58af53b29e9fe44e965c8ff8b7ca2d8a
data/CHANGELOG.markdown CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  * ScoutProf BETA
4
4
 
5
+ # 2.4.7
6
+
7
+ * Fix issue recording backtraces
8
+
9
+ # 2.4.6
10
+
11
+ * Fix an edge case for Resque instrumentation
12
+
5
13
  # 2.4.5
6
14
 
7
15
  * More robust installation of instruments at startup
@@ -41,7 +41,7 @@ module ScoutApm
41
41
  @remote_server = ScoutApm::Remote::Server.new(
42
42
  bind,
43
43
  port,
44
- ScoutApm::Remote::Router.new(ScoutApm::SynchronousRecorder.new(logger), logger),
44
+ ScoutApm::Remote::Router.new(ScoutApm::SynchronousRecorder.new(self), logger),
45
45
  logger
46
46
  )
47
47
 
@@ -4,7 +4,6 @@ module ScoutApm
4
4
  include Enumerable
5
5
 
6
6
  attr_reader :metrics # the raw metrics. You probably want #metrics_to_report
7
- attr_reader :context
8
7
 
9
8
  def marshal_dump
10
9
  [ @metrics ]
@@ -22,6 +21,12 @@ module ScoutApm
22
21
  @metrics = Hash.new
23
22
  end
24
23
 
24
+ # Need to look this up again if we end up as nil. Which I guess can happen
25
+ # after a Marshal load?
26
+ def context
27
+ @context ||= ScoutApm::Agent.instance.context
28
+ end
29
+
25
30
  def each
26
31
  metrics.each do |_key, db_query_metric_stat|
27
32
  yield db_query_metric_stat
@@ -8,11 +8,12 @@
8
8
  # :stdout => true - explicitly force the log to write to stdout (if set, ignore log_file_path)
9
9
  # :stderr => true - explicitly force the log to write to stderr (if set, ignore log_file_path)
10
10
  # :logger_class => Class or String - a class to use as the underlying logger. Defaults to Ruby's Logger. See notes
11
- # :log_level => symbol, string, or integer - defualts to INFO level
11
+ # :log_level => symbol, string, or integer - defaults to INFO level
12
12
  #
13
13
  # The :logger_class option
14
14
  # - allows any class to be used as the underlying logger. Currently requires to respond to:
15
15
  # - debug, info, warn, error, fatal in both string and block form.
16
+ # - debug?, info?, warn?, error?, fatal?
16
17
  # - #level= with a number (0 = debug, 1 = info, 2= warn, 3=error, 4=fatal)
17
18
  # - #formatter= that takes a Ruby Logger::Formatter class. This method must be here, but the value may be ignored
18
19
  #
@@ -39,6 +40,12 @@ module ScoutApm
39
40
  def error(*args, &block); @logger.error(*args, &block); end
40
41
  def fatal(*args, &block); @logger.fatal(*args, &block); end
41
42
 
43
+ def debug?; @logger.debug?; end
44
+ def info?; @logger.info?; end
45
+ def warn?; @logger.warn?; end
46
+ def error?; @logger.error?; end
47
+ def fatal?; @logger.fatal?; end
48
+
42
49
  def log_level=(level)
43
50
  @logger.level = log_level_from_opts(level)
44
51
  end
@@ -38,6 +38,13 @@ module ScoutApm
38
38
  # An object that responds to `record!(TrackedRequest)` to store this tracked request
39
39
  attr_reader :recorder
40
40
 
41
+ # When we see these layers, it means a real request is going through the
42
+ # system. We toggle a flag to turn on some slightly more expensive
43
+ # instrumentation (backtrace collection and the like) that would be too
44
+ # expensive in situations where the framework is constantly churning. We
45
+ # see that on Sidekiq.
46
+ REQUEST_TYPES = ["Controller", "Job"]
47
+
41
48
  def initialize(agent_context, store)
42
49
  @agent_context = agent_context
43
50
  @store = store #this is passed in so we can use a real store (normal operation) or fake store (instant mode only)
@@ -52,6 +59,7 @@ module ScoutApm
52
59
  @instant_key = nil
53
60
  @mem_start = mem_usage
54
61
  @recorder = agent_context.recorder
62
+ @real_request = false
55
63
 
56
64
  ignore_request! if @recorder.nil?
57
65
  end
@@ -67,6 +75,10 @@ module ScoutApm
67
75
  layer.start_sampling
68
76
 
69
77
  start_request(layer) unless @root_layer
78
+
79
+ if REQUEST_TYPES.include?(layer.type)
80
+ real_request!
81
+ end
70
82
  @layers.push(layer)
71
83
  end
72
84
 
@@ -110,6 +122,15 @@ module ScoutApm
110
122
  end
111
123
  end
112
124
 
125
+ def real_request!
126
+ @real_request = true
127
+ end
128
+
129
+ # Have we seen a "controller" or "job" layer so far?
130
+ def real_request?
131
+ @real_request
132
+ end
133
+
113
134
  # Grab the currently running layer. Useful for adding additional data as we
114
135
  # learn it. This is useful in ActiveRecord instruments, where we start the
115
136
  # instrumentation early, and gradually learn more about the request that
@@ -133,7 +154,7 @@ module ScoutApm
133
154
  # Only capture backtraces if we're in a real "request". Otherwise we
134
155
  # can spend lot of time capturing backtraces from the internals of
135
156
  # Sidekiq, only to throw them away immediately.
136
- return false unless (web? || job?)
157
+ return false unless real_request?
137
158
 
138
159
  # Capture any individually slow layer.
139
160
  return true if layer.total_exclusive_time > backtrace_threshold
@@ -245,16 +266,6 @@ module ScoutApm
245
266
  @headers = headers
246
267
  end
247
268
 
248
- # This request is a job transaction iff it has a 'Job' layer
249
- def job?
250
- layer_finder.job != nil
251
- end
252
-
253
- # This request is a web transaction iff it has a 'Controller' layer
254
- def web?
255
- layer_finder.controller != nil
256
- end
257
-
258
269
  def instant?
259
270
  return false if ignoring_request?
260
271
 
@@ -278,7 +289,7 @@ module ScoutApm
278
289
 
279
290
  # If we didn't have store, but we're trying to record anyway, go
280
291
  # figure that out. (this happens in Remote Agent scenarios)
281
- restore_store if @store.nil?
292
+ restore_from_dump! if @agent_context.nil?
282
293
 
283
294
  # Bail out early if the user asked us to ignore this uri
284
295
  return if @agent_context.ignored_uris.ignore?(annotations[:uri])
@@ -317,6 +328,19 @@ module ScoutApm
317
328
  end
318
329
  end
319
330
 
331
+ # This request is a job transaction iff it has a 'Job' layer
332
+ # Use this only during recording
333
+ def job?
334
+ layer_finder.job != nil
335
+ end
336
+
337
+ # This request is a web transaction iff it has a 'Controller' layer
338
+ # Use this only during recording
339
+ def web?
340
+ layer_finder.controller != nil
341
+ end
342
+
343
+
320
344
  def layer_finder
321
345
  @layer_finder ||= LayerConverters::FindLayerByType.new(self)
322
346
  end
@@ -457,11 +481,14 @@ module ScoutApm
457
481
  @call_set = nil
458
482
  @store = nil
459
483
  @recorder = nil
484
+ @agent_context = nil
460
485
  end
461
486
 
462
487
  # Go re-fetch the store based on what the Agent's official one is. Used
463
488
  # after hydrating a dumped TrackedRequest
464
- def restore_store
489
+ def restore_from_dump!
490
+ @agent_context = ScoutApm::Agent.instance.context
491
+ @recorder = @agent_context.recorder
465
492
  @store = @agent_context.store
466
493
  end
467
494
  end
@@ -1,3 +1,3 @@
1
1
  module ScoutApm
2
- VERSION = "3.0.0.pre19"
2
+ VERSION = "3.0.0.pre20"
3
3
  end
@@ -1,10 +1,12 @@
1
1
  require 'test_helper'
2
+ require 'fileutils'
2
3
 
3
4
  require 'scout_apm/logger'
4
5
 
5
6
  class LoggerTest < Minitest::Test
6
7
  def setup
7
8
  @env_root = Pathname.new(File.dirname(__FILE__)) + "../../"
9
+ FileUtils.mkdir_p(@env_root + "log")
8
10
  end
9
11
 
10
12
  def test_detect_stdout
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: 3.0.0.pre19
4
+ version: 3.0.0.pre20
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-01-25 00:00:00.000000000 Z
12
+ date: 2018-02-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest