scout_apm 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/scout_apm/app_server_load.rb +11 -4
- data/lib/scout_apm/instruments/process/process_cpu.rb +28 -13
- data/lib/scout_apm/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2f2ddadaf118058d788a7d39c15de73fb24c19d
|
4
|
+
data.tar.gz: 7c495ff3fda4aab68c3d31b543bc3d934df4ae83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3378b43c95b66a8f33fd3f0af330ff73d00e6aa2fde247246b205697d809cd30f65ed73306e4db135bc25011e08aedac434233469945a3b73d0c2f8dfda0795
|
7
|
+
data.tar.gz: 56eea7c846a87ae932a758ca52dffd5b22287fb2852f36f9d267d374587cfa7c982c87d8bdd2c54f8b5bc5802754e2af1aa74e1a4e9f5b0a6742c182d8bf6b59
|
@@ -7,10 +7,17 @@ module ScoutApm
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def run
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
@thread = Thread.new do
|
11
|
+
begin
|
12
|
+
logger.info("Sending Startup Info: #{data.inspect}")
|
13
|
+
payload = ScoutApm::Serializers::AppServerLoadSerializer.serialize(data)
|
14
|
+
reporter = Reporter.new(:app_server_load)
|
15
|
+
reporter.report(payload)
|
16
|
+
logger.info("Finished sending Startup Info")
|
17
|
+
rescue => e
|
18
|
+
logger.debug("Failed Startup Info In Thread - #{e.message} \n\t#{e.backtrace.join("\t\n")}")
|
19
|
+
end
|
20
|
+
end
|
14
21
|
rescue => e
|
15
22
|
logger.debug("Failed Startup Info - #{e.message} \n\t#{e.backtrace.join("\t\n")}")
|
16
23
|
end
|
@@ -3,9 +3,12 @@ module ScoutApm
|
|
3
3
|
module Process
|
4
4
|
class ProcessCpu
|
5
5
|
attr_reader :logger
|
6
|
+
attr_reader :num_processors
|
7
|
+
attr_accessor :last_run, :last_utime, :last_stime
|
8
|
+
|
6
9
|
|
7
10
|
def initialize(num_processors, logger)
|
8
|
-
@num_processors = num_processors
|
11
|
+
@num_processors = [num_processors, 1].compact.max
|
9
12
|
@logger = logger
|
10
13
|
|
11
14
|
t = ::Process.times
|
@@ -24,19 +27,31 @@ module ScoutApm
|
|
24
27
|
|
25
28
|
def run
|
26
29
|
res = nil
|
27
|
-
|
30
|
+
|
28
31
|
t = ::Process.times
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
32
|
+
now = Time.now
|
33
|
+
utime = t.utime
|
34
|
+
stime = t.stime
|
35
|
+
|
36
|
+
wall_clock_elapsed = now - last_run
|
37
|
+
|
38
|
+
utime_elapsed = utime - last_utime
|
39
|
+
stime_elapsed = stime - last_stime
|
40
|
+
process_elapsed = utime_elapsed + stime_elapsed
|
41
|
+
|
42
|
+
# Normalized to # of processors
|
43
|
+
normalized_wall_clock_elapsed = wall_clock_elapsed * num_processors
|
44
|
+
|
45
|
+
# If somehow we run for 0 seconds between calls, don't try to divide by 0
|
46
|
+
res = if normalized_wall_clock_elapsed == 0
|
47
|
+
0
|
48
|
+
else
|
49
|
+
( process_elapsed / normalized_wall_clock_elapsed )*100
|
50
|
+
end
|
51
|
+
|
52
|
+
self.last_run = now
|
53
|
+
self.last_utime = t.utime
|
54
|
+
self.last_stime = t.stime
|
40
55
|
|
41
56
|
logger.debug "#{human_name}: #{res.inspect} [#{Environment.instance.processors} CPU(s)]"
|
42
57
|
|
data/lib/scout_apm/version.rb
CHANGED