scout_apm 2.1.4 → 2.1.5

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: 5e7455372ff88117a2caf4ecac5634b833131c30
4
- data.tar.gz: c726bd01b48f93f6bd55f5b06dd36f86ecabfa4b
3
+ metadata.gz: 3e07d333b6388ad233485d64c3c1f460a0267873
4
+ data.tar.gz: 2fae8e481a1c38dc02aa99f77fef443bc4e30ec4
5
5
  SHA512:
6
- metadata.gz: 8d996da034590250b3fcc9b87a412de39ddb01956ee144c4bd4917f4f7b18f6a23650fcbd9b9e2f6f48c2ac8952cc972bd65415b5e5cbbcc733fa26981111796
7
- data.tar.gz: ea8f5cfe8e3e9222d138a7c09f40d57b32d19a756f8472b6d764b125f57a34cf54bf3f884668147a661cf1af1d3afd10e18dca9a9d4b110fb9d372c37fbea82a
6
+ metadata.gz: 119d47bb1e32990a8841e34aca493b614b3ac060a43a77de6779e4bbf7d1b8d6be7f4630bcb5ee2672f9bb0ddb4b7a4f2e83962807d78ca0181e22d923f03a30
7
+ data.tar.gz: 339f928af02ecfcdbf82b546e2666f86bba4fd7aef9f34e95637992b4d61d3070873ab17dfebbcf6b5a41b06f6179cc1c3ab3b60f33dbe8cc88608d1fa77c271
data/.gitignore CHANGED
@@ -16,3 +16,4 @@ test/tmp/*
16
16
  test/tmp/*coverage/*
17
17
  coverage/*
18
18
  lib/*.bundle
19
+ lib/*.so
data/CHANGELOG.markdown CHANGED
@@ -1,5 +1,15 @@
1
1
  # master
2
2
 
3
+ # 2.1.5
4
+
5
+ * Be less strict loading Rails environments that don't have a matching
6
+ scout_apm.yml section. Previously we raised, now we log and continue
7
+ to load with the ENV settings
8
+ * Fix a memory leak in error recovery code
9
+ * Fix a minor race condition in data coordination between processes.
10
+ * There was a tiny sliver of a window where a lock wasn't held, and it caused
11
+ an exception to be raised.
12
+
3
13
  # 2.1.4
4
14
 
5
15
  * Enhance regular expression that determines if a backtrace line is "inside"
@@ -25,13 +25,13 @@ module ScoutApm
25
25
  def start(&block)
26
26
  @task = block
27
27
 
28
- begin
29
- ScoutApm::Agent.instance.logger.debug "Background Worker: Starting Background Worker, running every #{period} seconds"
28
+ ScoutApm::Agent.instance.logger.debug "Background Worker: Starting Background Worker, running every #{period} seconds"
30
29
 
31
- # The first run should be 1 period of time from now
32
- next_time = Time.now + period
30
+ # The first run should be 1 period of time from now
31
+ next_time = Time.now + period
33
32
 
34
- loop do
33
+ loop do
34
+ begin
35
35
  # Bail out if @keep_running is false
36
36
  unless @keep_running
37
37
  ScoutApm::Agent.instance.logger.debug "Background Worker: breaking from loop"
@@ -53,11 +53,11 @@ module ScoutApm
53
53
  while next_time <= now
54
54
  next_time += period
55
55
  end
56
+ rescue
57
+ ScoutApm::Agent.instance.logger.debug "Background Worker Exception!"
58
+ ScoutApm::Agent.instance.logger.debug $!.message
59
+ ScoutApm::Agent.instance.logger.debug $!.backtrace
56
60
  end
57
- rescue
58
- ScoutApm::Agent.instance.logger.debug "Background Worker Exception!"
59
- ScoutApm::Agent.instance.logger.debug $!.message
60
- ScoutApm::Agent.instance.logger.debug $!.backtrace
61
61
  end
62
62
  end
63
63
  end
@@ -22,11 +22,6 @@ require 'scout_apm/environment'
22
22
  # Any of these config settings can be set with an environment variable prefixed
23
23
  # by SCOUT_ and uppercasing the key: SCOUT_LOG_LEVEL for instance.
24
24
 
25
-
26
- # Config - Made up of config overlay
27
- # Default -> File -> Environment Var
28
- # QUESTION: How to embed arrays or hashes into ENV?
29
-
30
25
  module ScoutApm
31
26
  class Config
32
27
 
@@ -129,7 +124,7 @@ module ScoutApm
129
124
  def self.with_file(file_path=nil, config={})
130
125
  overlays = [
131
126
  ConfigEnvironment.new,
132
- ConfigFile.new(file_path, config[:file]),
127
+ ConfigFile.new(file_path, config),
133
128
  ConfigDefaults.new,
134
129
  ConfigNull.new,
135
130
  ]
@@ -149,7 +144,7 @@ module ScoutApm
149
144
  nil
150
145
  end
151
146
 
152
- coercion = SETTING_COERCIONS[key] || NullCoercion.new
147
+ coercion = SETTING_COERCIONS.fetch(key, NullCoercion.new)
153
148
  coercion.coerce(raw_value)
154
149
  end
155
150
 
@@ -163,7 +158,8 @@ module ScoutApm
163
158
  'disabled_instruments' => [],
164
159
  'enable_background_jobs' => true,
165
160
  'ignore' => [],
166
- 'dev_trace' => false, # false for now so code can live in main branch
161
+ 'dev_trace' => false,
162
+ 'profile' => true # for scoutprof
167
163
  }.freeze
168
164
 
169
165
  def value(key)
@@ -247,15 +243,16 @@ module ScoutApm
247
243
  raw_file = File.read(@resolved_file_path)
248
244
  erb_file = ERB.new(raw_file).result(binding)
249
245
  parsed_yaml = YAML.load(erb_file)
250
- @settings = parsed_yaml[app_environment]
246
+ file_settings = parsed_yaml[app_environment]
251
247
 
252
- if !@settings.is_a? Hash
253
- raise ("Missing environment key for: #{app_environment}. This can happen if the key is missing, or with a malformed configuration file," +
254
- " check that there is a top level #{app_environment} key.")
248
+ if file_settings.is_a? Hash
249
+ logger.debug("Loaded Configuration: #{@resolved_file_path}. Using environment: #{app_environment}")
250
+ @settings = file_settings
251
+ @file_loaded = true
252
+ else
253
+ logger.info("Couldn't find configuration in #{@resolved_file_path} for environment: #{app_environment}. Configuration in ENV will still be applied.")
254
+ @file_loaded = false
255
255
  end
256
-
257
- logger.debug("Loaded Configuration: #{@resolved_file_path}. Using environment: #{app_environment}")
258
- @file_loaded = true
259
256
  rescue Exception => e # Explicit `Exception` handling to catch SyntaxError and anything else that ERB or YAML may throw
260
257
  logger.debug("Failed loading configuration file: #{e.message}. ScoutAPM will continue starting with configuration from ENV and defaults")
261
258
  @file_loaded = false
@@ -61,11 +61,15 @@ module ScoutApm
61
61
  coordinator_file = glob_pattern(timestamp, :coordinator)
62
62
 
63
63
 
64
- # This file gets deleted only by a process that successfully obtained a lock
65
- f = File.open(coordinator_file, File::RDWR | File::CREAT)
66
64
  begin
67
- # Nonblocking, Exclusive lock.
68
- if f.flock(File::LOCK_EX | File::LOCK_NB)
65
+ # This file gets deleted only by a process that successfully created and obtained the exclusive lock
66
+ f = File.open(coordinator_file, File::RDWR | File::CREAT | File::EXCL | File::NONBLOCK)
67
+ rescue Errno::EEXIST
68
+ false
69
+ end
70
+
71
+ begin
72
+ if f
69
73
 
70
74
  ScoutApm::Agent.instance.logger.debug("Obtained Reporting Lock")
71
75
 
@@ -87,7 +91,6 @@ module ScoutApm
87
91
  true
88
92
  else
89
93
  # Didn't obtain lock, another process is reporting. Return false from this function, but otherwise no work
90
- f.close
91
94
  false
92
95
  end
93
96
  end
@@ -1,4 +1,4 @@
1
1
  module ScoutApm
2
- VERSION = "2.1.4"
2
+ VERSION = "2.1.5"
3
3
  end
4
4
 
@@ -26,5 +26,47 @@ class ConfigTest < Minitest::Test
26
26
  assert_equal "debug", conf.value('log_level')
27
27
  assert_equal "APM Test Conf (Production)", conf.value('name')
28
28
  end
29
+
30
+ def test_loading_file_without_env_in_file
31
+ conf_file = File.expand_path("../../data/config_test_1.yml", __FILE__)
32
+ conf = ScoutApm::Config.with_file(conf_file, environment: "staging")
33
+
34
+ assert_equal "info", conf.value('log_level') # the default value
35
+ assert_equal nil, conf.value('name') # the default value
36
+ end
37
+
38
+ def test_boolean_coercion
39
+ coercion = ScoutApm::Config::BooleanCoercion.new
40
+ assert_equal true, coercion.coerce("true")
41
+ assert_equal true, coercion.coerce("t")
42
+ assert_equal false, coercion.coerce("false")
43
+ assert_equal false, coercion.coerce("f")
44
+ assert_equal false, coercion.coerce("")
45
+
46
+ assert_equal true, coercion.coerce(true)
47
+ assert_equal false, coercion.coerce(false)
48
+ assert_equal false, coercion.coerce(nil)
49
+
50
+ assert_equal true, coercion.coerce(1)
51
+ assert_equal true, coercion.coerce(20)
52
+ assert_equal true, coercion.coerce(-1)
53
+ assert_equal false, coercion.coerce(0)
54
+
55
+ # for any other unknown class, there is no clear answer, so be safe and say false.
56
+ assert_equal false, coercion.coerce([])
57
+ end
58
+
59
+ def test_json_coersion
60
+ coercion = ScoutApm::Config::JsonCoercion.new
61
+ assert_equal [1,2,3], coercion.coerce('[1,2,3]')
62
+ assert_equal ['foo/bar','baz/quux'], coercion.coerce('["foo/bar", "baz/quux"]')
63
+
64
+ assert_equal({"foo" => "bar"}, coercion.coerce('{"foo": "bar"}'))
65
+
66
+ assert_equal true, coercion.coerce(true)
67
+ assert_equal 10, coercion.coerce(10)
68
+ assert_equal ["a"], coercion.coerce(["a"])
69
+ end
29
70
  end
30
71
 
72
+
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.1.4
4
+ version: 2.1.5
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: 2016-08-25 00:00:00.000000000 Z
12
+ date: 2016-08-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rusage