scout_apm 0.1.11 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b2f2ddadaf118058d788a7d39c15de73fb24c19d
4
- data.tar.gz: 7c495ff3fda4aab68c3d31b543bc3d934df4ae83
3
+ metadata.gz: 5c3c774cf96a6a211650f1fffabed007073ccb93
4
+ data.tar.gz: bd321d8d0567c66caeb6a96ca3a65a72a48db39a
5
5
  SHA512:
6
- metadata.gz: f3378b43c95b66a8f33fd3f0af330ff73d00e6aa2fde247246b205697d809cd30f65ed73306e4db135bc25011e08aedac434233469945a3b73d0c2f8dfda0795
7
- data.tar.gz: 56eea7c846a87ae932a758ca52dffd5b22287fb2852f36f9d267d374587cfa7c982c87d8bdd2c54f8b5bc5802754e2af1aa74e1a4e9f5b0a6742c182d8bf6b59
6
+ metadata.gz: e3071d8c222b7e3954aaa04a3eb25fe5ea89b780894be1763173ff5b061cf4cc565659267b3f353754dfeb16f9927db7108c22a6d60055f880d8561a74194e7e
7
+ data.tar.gz: 84ab4cc77107f927537587f080b6b23950330da0075c9819f03c4038929006087256fce9449f54f39ae51a98ee91678307fe836abc66ccbf2e75c0e20c229118
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,13 @@
1
+ # 0.1.12
2
+
3
+ * Fix Puma integration. Now detects both branches of preload_app! setting.
4
+ * Enhance Cpu instrumentation
5
+
6
+ # 0.1.11
7
+
8
+ * Post on-load application details in a background thread to prevent potential
9
+ pauses during app boot
10
+
1
11
  # 0.1.10
2
12
 
3
13
  * Prevent instrumentation in non-web contexts. Prevents agent running in rails
@@ -153,9 +153,7 @@ module ScoutApm
153
153
  def start_background_worker?
154
154
  return true if environment.app_server == :thin
155
155
  return true if environment.app_server == :webrick
156
- return false if environment.forking?
157
-
158
- false
156
+ return !environment.forking?
159
157
  end
160
158
 
161
159
  # Creates the worker thread. The worker thread is a loop that runs continuously. It sleeps for +Agent#period+ and when it wakes,
@@ -27,6 +27,7 @@ module ScoutApm
27
27
  :framework => ScoutApm::Environment.instance.framework_integration.human_name,
28
28
  :framework_version => ScoutApm::Environment.instance.framework_integration.version,
29
29
  :environment => ScoutApm::Environment.instance.framework_integration.env,
30
+ :app_server => ScoutApm::Environment.instance.app_server,
30
31
  :ruby_version => RUBY_VERSION,
31
32
  :hostname => ScoutApm::Environment.instance.hostname,
32
33
  :database_engine => ScoutApm::Environment.instance.database_engine,
@@ -25,6 +25,7 @@ module ScoutApm
25
25
  "Process CPU"
26
26
  end
27
27
 
28
+ # TODO: Figure out a good default instead of nil
28
29
  def run
29
30
  res = nil
30
31
 
@@ -34,11 +35,24 @@ module ScoutApm
34
35
  stime = t.stime
35
36
 
36
37
  wall_clock_elapsed = now - last_run
38
+ if wall_clock_elapsed < 0
39
+ save_times(now, utime, stime)
40
+ logger.warn "#{human_name}: Negative time elapsed. now: #{now}, last_run: #{last_run}, total time: #{wall_clock_elapsed}"
41
+ return nil
42
+ end
37
43
 
38
44
  utime_elapsed = utime - last_utime
39
45
  stime_elapsed = stime - last_stime
40
46
  process_elapsed = utime_elapsed + stime_elapsed
41
47
 
48
+ # This can happen right after a fork. This class starts up in
49
+ # pre-fork, records {u,s}time, then forks. This resets {u,s}time to 0
50
+ if process_elapsed < 0
51
+ save_times(now, utime, stime)
52
+ logger.warn "#{human_name}: Negative process time elapsed. utime: #{utime_elapsed}, stime: #{stime_elapsed}, total time: #{process_elapsed}"
53
+ return nil
54
+ end
55
+
42
56
  # Normalized to # of processors
43
57
  normalized_wall_clock_elapsed = wall_clock_elapsed * num_processors
44
58
 
@@ -49,14 +63,24 @@ module ScoutApm
49
63
  ( process_elapsed / normalized_wall_clock_elapsed )*100
50
64
  end
51
65
 
52
- self.last_run = now
53
- self.last_utime = t.utime
54
- self.last_stime = t.stime
66
+ if res < 0
67
+ save_times(now, utime, stime)
68
+ logger.warn "#{human_name}: Negative CPU. #{process_elapsed} / #{normalized_wall_clock_elapsed} * 100 ==> #{res}"
69
+ return nil
70
+ end
71
+
72
+ save_times(now, utime, stime)
55
73
 
56
- logger.debug "#{human_name}: #{res.inspect} [#{Environment.instance.processors} CPU(s)]"
74
+ logger.debug "#{human_name}: #{res.inspect} [#{num_processors} CPU(s)]"
57
75
 
58
76
  return res
59
77
  end
78
+
79
+ def save_times(now, utime, stime)
80
+ self.last_run = now
81
+ self.last_utime = utime
82
+ self.last_stime = stime
83
+ end
60
84
  end
61
85
  end
62
86
  end
@@ -11,14 +11,21 @@ module ScoutApm
11
11
  :puma
12
12
  end
13
13
 
14
- def forking?; true; end
14
+ def forking?
15
+ return false unless defined?(::Puma)
16
+ options = ::Puma.cli_config.instance_variable_get(:@options)
17
+ logger.debug options.inspect
18
+ options[:preload_app]
19
+ rescue
20
+ false
21
+ end
15
22
 
16
23
  def present?
17
- defined?(::Puma) && File.basename($0) == 'puma'
24
+ defined?(::Puma) && (File.basename($0) =~ /\Apuma/)
18
25
  end
19
26
 
20
27
  def install
21
- Puma.cli_config.options[:before_worker_boot] << Proc.new do
28
+ ::Puma.cli_config.options[:before_worker_boot] << Proc.new do
22
29
  logger.debug "Installing Puma worker loop."
23
30
  ScoutApm::Agent.instance.start_background_worker
24
31
  end
@@ -1,4 +1,4 @@
1
1
  module ScoutApm
2
- VERSION = "0.1.11"
2
+ VERSION = "0.1.12"
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: 0.1.11
4
+ version: 0.1.12
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: 2015-08-31 00:00:00.000000000 Z
12
+ date: 2015-09-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest