scout_apm 2.3.1 → 2.3.2

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: 8f7a080ba227f9128b5043ef6cef44057aca54aa
4
- data.tar.gz: 7efd65ac1bfc634bba4833cce60e5853f972f0fe
3
+ metadata.gz: 499e2fb1ca29ef0ca1a596acf1ef561efc9b8f05
4
+ data.tar.gz: 4ac01fb2789e05be922d6121eabae98b72af4198
5
5
  SHA512:
6
- metadata.gz: 2348d0ebc6ce4cc01b2f04f7dcba41376d55869f88d2aa5c1337079dcbc37bdd2dff527f6c1c73b26738eeaa735e26268273ebde4ba9f328e048d4926fd0c3c0
7
- data.tar.gz: b925e5905c463df7673fbba9d867d3f8f27f21f5eaf6420360454130e12485fe5e621b8634843b30e08420443f548e9037f7dd9405befd68133325f290811a9c
6
+ metadata.gz: 553499a35ca3b92571b649277feda1d2e195ccf091eefb85f2e0ca5279a36c3e8ea90a0a0073104ee9db398a2c1984d87ace59e706e76b8dda8b02e39ed67f1c
7
+ data.tar.gz: db4cc309f2c46c2f4a77f84c7f1c1ab66b7488f08d87310f1c18daa3ba62b0554a170c501cd407050cb89a52417b255c0269b70274c26e64d6ddc9def35c7a70
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,8 @@
1
+ # 2.3.2
2
+
3
+ * More robust startup sequence when using `rails server` vs. directly launching an app server
4
+ * Avoid incompatibility with 3rd party gems that aggressively obtain database connections
5
+
1
6
  # 2.3.1
2
7
 
3
8
  * Fix DevTrace bug
@@ -39,6 +39,7 @@ module ScoutApm
39
39
  # be started (when forking).
40
40
  def initialize(options = {})
41
41
  @started = false
42
+ @shutting_down = false
42
43
  @process_start_time = Time.now
43
44
  @options ||= options
44
45
 
@@ -172,7 +173,7 @@ module ScoutApm
172
173
  # Sends a ping to APM right away, smoothes out onboarding
173
174
  # Collects up any relevant info (framework, app server, system time, ruby version, etc)
174
175
  def app_server_load_hook
175
- AppServerLoad.new.run
176
+ @app_server_load ||= AppServerLoad.new.run
176
177
  end
177
178
 
178
179
  def exit_handler_supported?
@@ -236,6 +237,10 @@ module ScoutApm
236
237
  @started
237
238
  end
238
239
 
240
+ def shutting_down?
241
+ @shutdown == true
242
+ end
243
+
239
244
  # The worker thread will automatically start UNLESS:
240
245
  # * A supported application server isn't detected (example: running via Rails console)
241
246
  # * A supported application server is detected, but it forks. In this case,
@@ -256,18 +261,28 @@ module ScoutApm
256
261
 
257
262
  # Creates the worker thread. The worker thread is a loop that runs continuously. It sleeps for +Agent#period+ and when it wakes,
258
263
  # processes data, either saving it to disk or reporting to Scout.
259
- def start_background_worker
264
+ # => true if thread & worker got started
265
+ # => false if it wasn't started (either due to already running, or other preconditions)
266
+ def start_background_worker(quiet=false)
260
267
  if !apm_enabled?
261
- logger.debug "Not starting background worker as monitoring isn't enabled."
268
+ logger.debug "Not starting background worker as monitoring isn't enabled." unless quiet
269
+ return false
270
+ end
271
+ if background_worker_running?
272
+ logger.info "Not starting background worker, already started" unless quiet
262
273
  return false
263
274
  end
264
- logger.info "Not starting background worker, already started" and return if background_worker_running?
275
+ if shutting_down?
276
+ logger.info "Not starting background worker, already in process of shutting down" unless quiet
277
+ return false
278
+ end
279
+
265
280
  logger.info "Initializing worker thread."
266
281
 
267
282
  install_exit_handler
268
283
 
269
284
  @recorder = create_recorder
270
- logger.info("recorder is now: #{@recorder.class}")
285
+ logger.info("Recorder is now: #{@recorder.class}")
271
286
 
272
287
  @background_worker = ScoutApm::BackgroundWorker.new
273
288
  @background_worker_thread = Thread.new do
@@ -277,6 +292,8 @@ module ScoutApm
277
292
  clean_old_percentiles
278
293
  }
279
294
  end
295
+
296
+ return true
280
297
  end
281
298
 
282
299
  def clean_old_percentiles
@@ -41,6 +41,10 @@ module ScoutApm
41
41
  :paas => to_s_safe(ScoutApm::Environment.instance.platform_integration.name),
42
42
  :git_sha => to_s_safe(ScoutApm::Environment.instance.git_revision.sha)
43
43
  }
44
+ ensure
45
+ # Sometimes :database_engine and :database_adapter can cause a reference to an AR connection.
46
+ # Make sure we release all AR connections held by this thread.
47
+ ActiveRecord::Base.clear_active_connections! if Utils::KlassHelper.defined?("ActiveRecord::Base")
44
48
  end
45
49
 
46
50
  # Calls `.to_s` on the object passed in.
@@ -292,8 +292,26 @@ module ScoutApm
292
292
  trace = converter.call
293
293
  ScoutApm::InstantReporting.new(trace, instant_key).call
294
294
  end
295
+
296
+ if web? || job?
297
+ ensure_background_worker
298
+ end
295
299
  end
296
300
 
301
+ # Ensure the background worker thread is up & running - a fallback if other
302
+ # detection doesn't achieve this at boot.
303
+ def ensure_background_worker
304
+ agent = ScoutApm::Agent.instance
305
+ agent.start(:skip_app_server_check => true) unless agent.started?
306
+
307
+ if agent.start_background_worker(:quiet)
308
+ agent.logger.info("Force Started BG Worker")
309
+ end
310
+ rescue => e
311
+ true
312
+ end
313
+
314
+
297
315
  # Only call this after the request is complete
298
316
  def unique_name
299
317
  return nil if ignoring_request?
@@ -1,4 +1,4 @@
1
1
  module ScoutApm
2
- VERSION = "2.3.1"
2
+ VERSION = "2.3.2"
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: 2.3.1
4
+ version: 2.3.2
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-10-20 00:00:00.000000000 Z
12
+ date: 2017-12-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest