scout_apm 2.4.0.pre → 2.4.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +9 -0
- data/lib/scout_apm/agent/exit_handler.rb +1 -0
- data/lib/scout_apm/agent.rb +24 -7
- data/lib/scout_apm/agent_context.rb +8 -0
- data/lib/scout_apm/app_server_load.rb +4 -0
- data/lib/scout_apm/tracked_request.rb +18 -0
- data/lib/scout_apm/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 08385e64d3b8d96ae39c02f892b637dfd0a9b154
|
4
|
+
data.tar.gz: 3ab13e2996230a611bca4907bd439d5503b05af5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50d959241a2921399d5d05e67add7b75000782e24ae9276c3a99460b9dcfcb076f72b230c6e35f29cb47f3dd3a75e2fb6487490e084f97403dfe030e4cf7210a
|
7
|
+
data.tar.gz: 6d36b242cc269e99981dae5fda755aa8bee1ef73616e1afc9dbabcd9a81aca3190f42d27fc6dddcc5b7309078b0ad6086e17008720ad90b35af0765f7ec237b2
|
data/CHANGELOG.markdown
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
# 2.4.0
|
2
|
+
|
3
|
+
* Rework agent startup sequence
|
4
|
+
|
5
|
+
# 2.3.2
|
6
|
+
|
7
|
+
* More robust startup sequence when using `rails server` vs. directly launching an app server
|
8
|
+
* Avoid incompatibility with 3rd party gems that aggressively obtain database connections
|
9
|
+
|
1
10
|
# 2.3.1
|
2
11
|
|
3
12
|
* Fix DevTrace bug
|
data/lib/scout_apm/agent.rb
CHANGED
@@ -46,7 +46,9 @@ module ScoutApm
|
|
46
46
|
# XXX: Should this happen at application start?
|
47
47
|
# Should this ever happen after fork?
|
48
48
|
# We start a thread in this, which can screw stuff up when we then fork.
|
49
|
-
|
49
|
+
#
|
50
|
+
# Save it into a variable to prevent it from ever running twice
|
51
|
+
@app_server_load ||= AppServerLoad.new(context).run
|
50
52
|
|
51
53
|
logger.info "Scout Agent [#{ScoutApm::VERSION}] installed"
|
52
54
|
|
@@ -61,8 +63,12 @@ module ScoutApm
|
|
61
63
|
# installed, and starting the background worker.
|
62
64
|
#
|
63
65
|
# Does not attempt to start twice.
|
64
|
-
def start
|
65
|
-
|
66
|
+
def start(_opts={})
|
67
|
+
if context.started?
|
68
|
+
start_background_worker unless background_worker_running?
|
69
|
+
return
|
70
|
+
end
|
71
|
+
|
66
72
|
install unless context.installed?
|
67
73
|
|
68
74
|
context.started!
|
@@ -127,15 +133,24 @@ module ScoutApm
|
|
127
133
|
# Background Worker Lifecycle #
|
128
134
|
#################################
|
129
135
|
|
130
|
-
|
136
|
+
# Creates the worker thread. The worker thread is a loop that runs continuously. It sleeps for +Agent#period+ and when it wakes,
|
137
|
+
# processes data, either saving it to disk or reporting to Scout.
|
138
|
+
# => true if thread & worker got started
|
139
|
+
# => false if it wasn't started (either due to already running, or other preconditions)
|
140
|
+
def start_background_worker(quiet=false)
|
131
141
|
if !context.config.value('monitor')
|
132
|
-
logger.debug "Not starting background worker as monitoring isn't enabled."
|
142
|
+
logger.debug "Not starting background worker as monitoring isn't enabled." unless quiet
|
133
143
|
return false
|
134
144
|
end
|
135
145
|
|
136
146
|
if background_worker_running?
|
137
|
-
logger.info "Not starting background worker, already started"
|
138
|
-
return
|
147
|
+
logger.info "Not starting background worker, already started" unless quiet
|
148
|
+
return false
|
149
|
+
end
|
150
|
+
|
151
|
+
if context.shutting_down?
|
152
|
+
logger.info "Not starting background worker, already in process of shutting down" unless quiet
|
153
|
+
return false
|
139
154
|
end
|
140
155
|
|
141
156
|
logger.info "Initializing worker thread."
|
@@ -150,6 +165,8 @@ module ScoutApm
|
|
150
165
|
periodic_work.run
|
151
166
|
}
|
152
167
|
end
|
168
|
+
|
169
|
+
return true
|
153
170
|
end
|
154
171
|
|
155
172
|
def stop_background_worker
|
@@ -75,6 +75,10 @@ module ScoutApm
|
|
75
75
|
@started
|
76
76
|
end
|
77
77
|
|
78
|
+
def shutting_down?
|
79
|
+
@shutting_down
|
80
|
+
end
|
81
|
+
|
78
82
|
def installed?
|
79
83
|
@installed
|
80
84
|
end
|
@@ -157,6 +161,10 @@ module ScoutApm
|
|
157
161
|
@started = true
|
158
162
|
end
|
159
163
|
|
164
|
+
def shutting_down!
|
165
|
+
@shutting_down = true
|
166
|
+
end
|
167
|
+
|
160
168
|
def store=(store)
|
161
169
|
@store = store
|
162
170
|
|
@@ -43,6 +43,10 @@ module ScoutApm
|
|
43
43
|
:paas => to_s_safe(environment.platform_integration.name),
|
44
44
|
:git_sha => to_s_safe(environment.git_revision.sha)
|
45
45
|
}
|
46
|
+
ensure
|
47
|
+
# Sometimes :database_engine and :database_adapter can cause a reference to an AR connection.
|
48
|
+
# Make sure we release all AR connections held by this thread.
|
49
|
+
ActiveRecord::Base.clear_active_connections! if Utils::KlassHelper.defined?("ActiveRecord::Base")
|
46
50
|
end
|
47
51
|
|
48
52
|
# Calls `.to_s` on the object passed in.
|
@@ -295,8 +295,26 @@ module ScoutApm
|
|
295
295
|
trace = converter.call
|
296
296
|
ScoutApm::InstantReporting.new(trace, instant_key).call
|
297
297
|
end
|
298
|
+
|
299
|
+
if web? || job?
|
300
|
+
ensure_background_worker
|
301
|
+
end
|
298
302
|
end
|
299
303
|
|
304
|
+
# Ensure the background worker thread is up & running - a fallback if other
|
305
|
+
# detection doesn't achieve this at boot.
|
306
|
+
def ensure_background_worker
|
307
|
+
agent = ScoutApm::Agent.instance
|
308
|
+
agent.start
|
309
|
+
|
310
|
+
if agent.start_background_worker(:quiet)
|
311
|
+
agent.logger.info("Force Started BG Worker")
|
312
|
+
end
|
313
|
+
rescue => e
|
314
|
+
true
|
315
|
+
end
|
316
|
+
|
317
|
+
|
300
318
|
# Only call this after the request is complete
|
301
319
|
def unique_name
|
302
320
|
return nil if ignoring_request?
|
data/lib/scout_apm/version.rb
CHANGED
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.0.
|
4
|
+
version: 2.4.0.pre2
|
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: 2017-12-
|
12
|
+
date: 2017-12-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|