scout_apm 2.0.0.pre8 → 2.0.0

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: bdef63b6e4340550876655a7d9d8544e6667730d
4
- data.tar.gz: af94bc60dd3364790210017f5615fa39b14e63ef
3
+ metadata.gz: a0a32ed17d0fae5e86bf5e64cfe7f25dfe9d1a77
4
+ data.tar.gz: 0e910af3eebdef26c093df1f522795aea983d890
5
5
  SHA512:
6
- metadata.gz: b49b704dd2d10cc5ecc896e640f527cc0c4f740c3905ad786c4a651bf4b561f3d51585f73f9338afaaa61f05ecc979e0c8e6f375ad41c2989144bdb804ca5c5b
7
- data.tar.gz: 9665d168ed2418c293c7f3fc73a0ab36919f34f5984dd38a756db30b1aa9f5383d01242c254a46603d15fabda5058b9e342ed097cc004312273d0f22f171c375
6
+ metadata.gz: f125f45638df4302321104e62d147725636ce4a31ea69d4ee9ca6b5730fb9673ac4ea3cca1e2cf58ff5874ac4c90ccce2eb737b940ca3780a4741fa531763784
7
+ data.tar.gz: 78eeec2d2700d0d02c937be30abc4322820935e89bd178a6d31114b86ea2e5d040b57578eccd7043e9c1386b4f2b6ffa1e26c94d52ae8d1c7afbbdf624cdbc1a
data/CHANGELOG.markdown CHANGED
@@ -1,14 +1,20 @@
1
1
  # 2.0.0
2
2
 
3
- * Reporting object allocation metrics and mem delta with slow requests and jobs.
4
- * Collecting memory metrics on slow transactions
5
- * Collecting additional fields for slow transactions:
3
+ * Reporting object allocation & mem delta metrics and mem delta for requests and jobs.
4
+ * Collecting additional fields for transactions:
6
5
  * hostname
7
6
  * seconds_since_startup (larger memory increases and other other odd behavior more common when close to startup)
8
- * Initial support for instant traces
9
- * Collect 95th percentiles
10
7
  * Remove unused & old references to Stackprof
11
8
  * Fixing exception on load if no config file is provided
9
+ * DevTrace BETA
10
+
11
+ # 1.6.8
12
+
13
+ * Don't wait on a sleeping thread during shutdown
14
+
15
+ # 1.6.7
16
+
17
+ * Mongoid bugfixes
12
18
 
13
19
  # 1.6.6
14
20
 
data/LICENSE.md CHANGED
@@ -1,9 +1,33 @@
1
- All components of this product, except where noted, are Copyright (c) 2013-2016 Zimuth, Inc DBA Scout. All rights reserved.
1
+ # Scout Software Agent License
2
2
 
3
- Certain inventions disclosed in this file may be claimed within patents owned or patent applications filed by Zimuth, Inc. or third parties.
3
+ Subject to and conditioned upon your continued compliance with the terms and conditions of this license, Zimuth, Inc. grants you a non-exclusive, non-sublicensable and non-transferable, limited license to install, use and run one copy of this software on each of your and your affiliate’s computers. This license also grants you the limited right to distribute verbatim copies of this software and documentation to third parties provided the software and documentation will (a) remain the exclusive property of Zimuth; (b) be subject to the terms and conditions of this license; and (c) include a complete and unaltered copy of this license and all other copyright or other intellectual property rights notices contained in the original.
4
4
 
5
- Subject to the terms of this notice, Zimuth grants you a nonexclusive, nontransferable license, without the right to sublicense, to (a) install and execute one copy of these files on any number of workstations owned or controlled by you and (b) distribute verbatim copies of these files to third parties. As a condition to the foregoing grant, you must provide this notice along with each copy you distribute and you must not remove, alter, or obscure this notice. All other use, reproduction, modification, distribution, or other exploitation of these files is strictly prohibited, except as may be set forth in a separate written license agreement between you and Zimuth. The terms of any such license agreement will control over this notice. The license stated above will be automatically terminated and revoked if you exceed its scope or violate any of the terms of this notice.
5
+ The software includes the open-source components listed below. Any use of the open-source components by you shall be governed by, and subject to, the terms and conditions of the applicable open-source licenses.
6
6
 
7
- This License does not grant permission to use the trade names, trademarks, service marks, or product names of Zimuth, except as required for reasonable and customary use in describing the origin of this file and reproducing the content of this notice. You may not mark or brand this file with any trade name, trademarks, service marks, or product names other than the original brand (if any) provided by Zimuth.
7
+ Except as this license expressly permits, you may not:
8
8
 
9
- Unless otherwise expressly agreed by Zimuth in a separate written license agreement, these files are provided AS IS, WITHOUT WARRANTY OF ANY KIND, including without any implied warranties of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, or NON-INFRINGEMENT. As a condition to your use of these files, you are solely responsible for such use. Zimuth will have no liability to you for direct, indirect, consequential, incidental, special, or punitive damages or for lost profits or data.
9
+ * copy the software, in whole or in part;
10
+ * modify, correct, adapt, translate, enhance or otherwise prepare derivative works or improvements of the software;
11
+ * sell, sublicense, assign, distribute, publish, transfer or otherwise make available the software to any person or entity;
12
+ * remove, delete, efface, alter, obscure, translate, combine, supplement or otherwise change any trademarks, terms of the documentation, warranties, disclaimers, or intellectual property rights, or other symbols, notices, marks or serial numbers on or relating to any copy of the software or documentation; or
13
+ use the software in any manner or for any purpose that infringes, misappropriates or otherwise violates any intellectual property right or other right of any person or entity, or that violates any applicable law;
14
+
15
+ By using the software, you acknowledge and agree that:
16
+
17
+ * the software and documentation are licensed, not sold, to you by Zimuth and you do not and will not have or acquire under or in connection with this license any ownership interest in the software or documentation, or in any related intellectual property rights; and
18
+ * Zimuth will remain the sole and exclusive owner of all right, title and interest in and to the software and documentation, including all related intellectual property rights, subject only to the rights of third parties in open-source components and the limited license granted to you under this license; and
19
+
20
+ Except for the limited rights and licenses expressly granted to you under this agreement, nothing in this license grants, by implication, waiver, estoppel or otherwise, to you or any third party any intellectual property rights or other right, title, or interest in or to any of the software or documentation.
21
+
22
+ This license shall be automatically terminated and revoked if you exceed the scope or violate any terms and conditions of this license.
23
+
24
+ ALL LICENSED SOFTWARE, DOCUMENTATION AND OTHER PRODUCTS, INFORMATION, MATERIALS AND SERVICES PROVIDED BY ZIMUTH ARE PROVIDED HERE “AS IS.” ZIMUTH DISCLAIMS ALL WARRANTIES, WHETHER EXPRESS, IMPLIED, STATUTORY OR OTHER (INCLUDING ALL WARRANTIES ARISING FROM COURSE OF DEALING, USAGE OR TRADE PRACTICE), AND SPECIFICALLY DISCLAIMS ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. WITHOUT LIMITING THE FOREGOING, ZIMUTH MAKES NO WARRANTY OF ANY KIND THAT THE LICENSED SOFTWARE OR DOCUMENTATION, OR ANY OTHER LICENSOR OR THIRD-PARTY GOODS, SERVICES, TECHNOLOGIES OR MATERIALS, WILL MEET YOUR REQUIREMENTS, OPERATE WITHOUT INTERRUPTION, ACHIEVE ANY INTENDED RESULT, BE COMPATIBLE OR WORK WITH ANY OTHER GOODS, SERVICES, TECHNOLOGIES OR MATERIALS (INCLUDING ANY SOFTWARE, HARDWARE, SYSTEM OR NETWORK) EXCEPT IF AND TO THE EXTENT EXPRESSLY SET FORTH IN THE DOCUMENTATION, OR BE SECURE, ACCURATE, COMPLETE, FREE OF HARMFUL CODE OR ERROR FREE. ALL OPEN-SOURCE COMPONENTS AND OTHER THIRD-PARTY MATERIALS ARE PROVIDED “AS IS” AND ANY REPRESENTATION OR WARRANTY OF OR CONCERNING ANY OF THEM IS STRICTLY BETWEEN LICENSEE AND THE THIRD-PARTY OWNER OR DISTRIBUTOR OF SUCH OPEN-SOURCE COMPONENTS AND THIRD-PARTY MATERIALS.
25
+
26
+ IN NO EVENT WILL ZIMUTH BE LIABLE UNDER OR IN CONNECTION WITH THIS LICENSE OR ITS SUBJECT MATTER UNDER ANY LEGAL OR EQUITABLE THEORY, INCLUDING BREACH OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY AND OTHERWISE, FOR ANY CONSEQUENTIAL, INCIDENTAL, INDIRECT, EXEMPLARY, SPECIAL, ENHANCED OR PUNITIVE DAMAGES, IN EACH CASE REGARDLESS OF WHETHER SUCH PERSONS WERE ADVISED OF THE POSSIBILITY OF SUCH LOSSES OR DAMAGES OR SUCH LOSSES OR DAMAGES WERE OTHERWISE FORESEEABLE, AND NOTWITHSTANDING THE FAILURE OF ANY AGREED OR OTHER REMEDY OF ITS ESSENTIAL PURPOSE.
27
+
28
+ ## OPEN SOURCE COMPONENTS
29
+
30
+ This product includes `rusage`, which inherits the Artistic License 2.0 from proc/wait3.
31
+ See http://www.rubydoc.info/gems/rusage/0.2.0.
32
+
33
+ Copyright Daniel J. Berger and Ben Sandofsky.
@@ -198,15 +198,17 @@ module ScoutApm
198
198
  def shutdown
199
199
  logger.info "Shutting down ScoutApm"
200
200
  return if !started?
201
+
201
202
  if @background_worker
203
+ logger.info("Stopping background worker")
202
204
  @background_worker.stop
203
205
  store.write_to_layaway(layaway, :force)
204
206
  end
205
207
 
206
- # make sure we don't exit the process while the background worker is running its task. Bypass this step in development.
207
- if environment.env != 'development'
208
- logger.debug "Joining background worker thread"
209
- @background_worker_thread.join if @background_worker_thread
208
+ logger.debug "Joining background worker thread"
209
+ if @background_worker_thread
210
+ @background_worker_thread.wakeup
211
+ @background_worker_thread.join
210
212
  end
211
213
  end
212
214
 
@@ -260,7 +262,7 @@ module ScoutApm
260
262
  # If we want to skip the app_server_check, then we must load it.
261
263
  def should_load_instruments?(options={})
262
264
  return true if options[:skip_app_server_check]
263
- return true if config.value('instant')
265
+ return true if config.value('dev_trace')
264
266
  return false if !apm_enabled?
265
267
  environment.app_server_integration.found? || !background_job_missing?
266
268
  end
@@ -12,6 +12,7 @@ module ScoutApm
12
12
  end
13
13
 
14
14
  def stop
15
+ ScoutApm::Agent.instance.logger.debug "Background Worker: stop requested"
15
16
  @keep_running = false
16
17
  end
17
18
 
@@ -25,31 +26,33 @@ module ScoutApm
25
26
  @task = block
26
27
 
27
28
  begin
28
- ScoutApm::Agent.instance.logger.debug "Starting Background Worker, running every #{period} seconds"
29
+ ScoutApm::Agent.instance.logger.debug "Background Worker: Starting Background Worker, running every #{period} seconds"
29
30
 
30
31
  # The first run should be 1 period of time from now
31
32
  next_time = Time.now + period
32
33
 
33
34
  loop do
35
+ # Bail out if @keep_running is false
36
+ unless @keep_running
37
+ ScoutApm::Agent.instance.logger.debug "Background Worker: breaking from loop"
38
+ break
39
+ end
40
+
34
41
  now = Time.now
35
42
 
36
43
  # Sleep the correct amount of time to reach next_time
37
- while now < next_time
44
+ while now < next_time && @keep_running
38
45
  sleep_time = next_time - now
39
46
  sleep(sleep_time) if sleep_time > 0
40
47
  now = Time.now
41
48
  end
42
49
 
43
- # Bail out if @keep_running is false
44
- break unless @keep_running
45
-
46
50
  @task.call
47
51
 
48
52
  # Adjust the next time to run forward by @periods until it is in the future
49
53
  while next_time <= now
50
54
  next_time += period
51
55
  end
52
-
53
56
  end
54
57
  rescue
55
58
  ScoutApm::Agent.instance.logger.debug "Background Worker Exception!"
@@ -16,6 +16,8 @@ require 'scout_apm/environment'
16
16
  # name - override the name reported to APM. This is the name that shows in the Web UI
17
17
  # uri_reporting - 'path' or 'full_path' default is 'full_path', which reports URL params as well as the path.
18
18
  # report_format - 'json' or 'marshal'. Marshal is legacy and will be removed.
19
+ # dev_trace - true or false. Enables always-on tracing in development environmen only
20
+ # enable_background_jobs - true or false
19
21
  #
20
22
  # Any of these config settings can be set with an environment variable prefixed
21
23
  # by SCOUT_ and uppercasing the key: SCOUT_LOG_LEVEL for instance.
@@ -27,12 +29,77 @@ require 'scout_apm/environment'
27
29
 
28
30
  module ScoutApm
29
31
  class Config
32
+
33
+ ################################################################################
34
+ # Coersions
35
+ #
36
+ # Since we get values from environment variables, which are always strings,
37
+ # we need to be able to coerce them into the correct data type. For
38
+ # instance, setting "SCOUT_ENABLE=false" should be interpreted as being the
39
+ # boolean false, not a string that is present & true.
40
+ #
41
+ # Similarly, this will help parsing YAML configurations if the user has a
42
+ # key like:
43
+ # monitor: "false"
44
+ ################################################################################
45
+
46
+ # Any boolean is passed through
47
+ # A string is false iff it is 0 length, is "f", or "false" - otherwise true
48
+ # An number is false if it is exactly 0
49
+ # Other types are false
50
+ class BooleanCoercion
51
+ def coerce(val)
52
+ case val
53
+ when NilClass
54
+ false
55
+ when TrueClass
56
+ val
57
+ when FalseClass
58
+ val
59
+ when String
60
+ coerce_string(val)
61
+ when Numeric
62
+ val != 0
63
+ else
64
+ false
65
+ end
66
+ end
67
+
68
+ def coerce_string(val)
69
+ val = val.downcase.strip
70
+ return false if val.length == 0
71
+ return false if val == "f"
72
+ return false if val == "false"
73
+
74
+ true
75
+ end
76
+ end
77
+
78
+ # Simply returns the passed in value, without change
79
+ class NullCoercion
80
+ def coerce(val)
81
+ val
82
+ end
83
+ end
84
+
85
+ SETTING_COERCIONS = {
86
+ "monitor" => BooleanCoercion.new,
87
+ "enable_background_jobs" => BooleanCoercion.new,
88
+ "dev_trace" => BooleanCoercion.new,
89
+ }
90
+
91
+
92
+ ################################################################################
93
+ # Configuration layers & reading
94
+ ################################################################################
95
+
30
96
  # Load up a config instance without attempting to load a file.
31
97
  # Useful for bootstrapping.
32
98
  def self.without_file
33
99
  overlays = [
34
100
  ConfigEnvironment.new,
35
101
  ConfigDefaults.new,
102
+ ConfigNull.new,
36
103
  ]
37
104
  new(overlays)
38
105
  end
@@ -45,6 +112,7 @@ module ScoutApm
45
112
  ConfigEnvironment.new,
46
113
  ConfigFile.new(file_path, config[:file]),
47
114
  ConfigDefaults.new,
115
+ ConfigNull.new,
48
116
  ]
49
117
  new(overlays)
50
118
  end
@@ -54,13 +122,10 @@ module ScoutApm
54
122
  end
55
123
 
56
124
  def value(key)
57
- @overlays.each do |overlay|
58
- if overlay.has_key?(key)
59
- return overlay.value(key)
60
- end
61
- end
125
+ raw_value = @overlays.detect{ |overlay| overlay.has_key?(key) }.value(key)
62
126
 
63
- nil
127
+ coercion = SETTING_COERCIONS[key] || NullCoercion.new
128
+ coercion.coerce(raw_value)
64
129
  end
65
130
 
66
131
  class ConfigDefaults
@@ -73,7 +138,7 @@ module ScoutApm
73
138
  'disabled_instruments' => [],
74
139
  'enable_background_jobs' => true,
75
140
  'ignore_traces' => [],
76
- 'instant' => false, # false for now so code can live in main branch
141
+ 'dev_trace' => false, # false for now so code can live in main branch
77
142
  }.freeze
78
143
 
79
144
  def value(key)
@@ -85,6 +150,20 @@ module ScoutApm
85
150
  end
86
151
  end
87
152
 
153
+
154
+ # Good News: It has every config value you could want
155
+ # Bad News: The content of that config value is always nil
156
+ # Used for the null-object pattern
157
+ class ConfigNull
158
+ def value(*)
159
+ nil
160
+ end
161
+
162
+ def has_key?(*)
163
+ true
164
+ end
165
+ end
166
+
88
167
  class ConfigEnvironment
89
168
  def value(key)
90
169
  val = ENV[key_to_env_key(key)]
@@ -165,6 +244,7 @@ module ScoutApm
165
244
  def app_environment
166
245
  @config[:environment] || ScoutApm::Environment.instance.env
167
246
  end
247
+
168
248
  def logger
169
249
  if ScoutApm::Agent.instance.logger
170
250
  return ScoutApm::Agent.instance.logger
@@ -1,35 +1,9 @@
1
+ <!-- Added by Scout DevTrace -->
1
2
  <script language="JavaScript">
2
- (function() {
3
- /* instrument XMLHttpRequest */
4
- var open = window.XMLHttpRequest.prototype.open;
5
- var send = window.XMLHttpRequest.prototype.send;
6
- function openReplacement(method, url, async, user, password) {
7
- this._url = url;
8
- return open.apply(this, arguments);
9
- }
10
- function sendReplacement(data) {
11
- if (this.onload) {
12
- this._onload = this.onload;
13
- }
14
- this.onload = onLoadReplacement;
15
- return send.apply(this, arguments);
16
- }
17
- function onLoadReplacement() {
18
- try {
19
- traceText = this.getResponseHeader("X-scoutapminstant");
20
- if(traceText){
21
- //console.info("Got an AJAX instrumentation with "+traceText.length.toString()+" characters.")
22
- setTimeout(function(){ window.scoutInstant("addTrace",traceText) },0);
23
- }
24
- } catch(e){
25
- console.debug("Problem getting X-scoutapminstant header");
26
- console.debug(e);
27
- }
28
- if (this._onload) {
29
- return this._onload.apply(this, arguments);
30
- }
31
- }
32
- window.XMLHttpRequest.prototype.open = openReplacement;
33
- window.XMLHttpRequest.prototype.send = sendReplacement;
34
- })();
3
+ (function(){var open=window.XMLHttpRequest.prototype.open;var send=window.XMLHttpRequest.prototype.send;function openReplacement(method,url,async,user,password){this._url=url;return open.apply(this,arguments);}
4
+ function sendReplacement(data){if(this.onload){this._onload=this.onload;}
5
+ this.onload=onLoadReplacement;return send.apply(this,arguments);}
6
+ function onLoadReplacement(){if(this._url.startsWith(window.location.protocol+"//"+window.location.host)||!this._url.startsWith("http")){try{traceText=this.getResponseHeader("X-scoutapminstant");if(traceText){setTimeout(function(){window.scoutInstant("addTrace",traceText)},0);}}catch(e){console.debug("Problem getting X-scoutapminstant header");}}
7
+ if(this._onload){return this._onload.apply(this,arguments);}}
8
+ window.XMLHttpRequest.prototype.open=openReplacement;window.XMLHttpRequest.prototype.send=sendReplacement;})();
35
9
  </script>
@@ -47,17 +47,22 @@ module ScoutApm
47
47
  def call(env)
48
48
  status, headers, response = @app.call(env)
49
49
 
50
- if ScoutApm::Agent.instance.config.value('instant')
50
+ if ScoutApm::Agent.instance.config.value('dev_trace')
51
51
  if response.respond_to?(:body)
52
52
  req = ScoutApm::RequestManager.lookup
53
53
  slow_converter = LayerConverters::SlowRequestConverter.new(req)
54
54
  trace = slow_converter.call
55
55
  if trace
56
+ metadata = {
57
+ :app_root => ScoutApm::Environment.instance.root.to_s,
58
+ :unique_id => env['action_dispatch.request_id'], # note, this is a different unique_id than what "normal" payloads use
59
+ :agent_version => ScoutApm::VERSION,
60
+ :platform => "ruby",
61
+ }
56
62
  hash = ScoutApm::Serializers::PayloadSerializerToJson.rearrange_slow_transaction(trace)
57
- hash.merge!(id:env['action_dispatch.request_id']) # TODO: this could be separated into a metadata section
63
+ hash.merge!(metadata:metadata)
58
64
  payload = ScoutApm::Serializers::PayloadSerializerToJson.jsonify_hash(hash)
59
65
 
60
-
61
66
  if env['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'
62
67
  # Add the payload as a header if it's an AJAX call
63
68
  headers['X-scoutapminstant'] = payload
@@ -31,10 +31,10 @@ module ScoutApm
31
31
  payload = ScoutApm::Serializers::PayloadSerializer.serialize(metadata, metrics, traces, jobs, slow_jobs)
32
32
 
33
33
  # Hand it off to the reporter for POST to our servers
34
- reporter = Reporter.new(:instant_trace, config = Agent.instance.config, logger = Agent.instance.logger, instant_key = @instant_key)
34
+ reporter = Reporter.new(:instant_trace, Agent.instance.config, Agent.instance.logger, @instant_key)
35
35
  reporter.report(payload, {'Content-Type' => 'application/json'} )
36
36
  end
37
37
  end
38
38
 
39
39
  end
40
- end
40
+ end
@@ -17,7 +17,7 @@ module ScoutApm
17
17
 
18
18
  # Mongoid versions that use Moped should instrument Moped.
19
19
  if defined?(::Mongoid) and !defined?(::Moped)
20
- ScoutApm::Agent.instance.logger.info "Instrumenting Mongoid"
20
+ ScoutApm::Agent.instance.logger.info "Instrumenting Mongoid 2.x"
21
21
 
22
22
  ### OLD (2.x) mongoids
23
23
  if defined?(::Mongoid::Collection)
@@ -33,6 +33,7 @@ module ScoutApm
33
33
 
34
34
  ### 5.x Mongoid
35
35
  if mongoid_v5? && defined?(::Mongoid::Contextual::Mongo)
36
+ ScoutApm::Agent.instance.logger.info "Instrumenting Mongoid 5.x"
36
37
  # All the public methods from Mongoid::Contextual::Mongo.
37
38
  # TODO: Geo and MapReduce support (?). They are in other Contextual::* classes
38
39
  methods = [
@@ -46,8 +47,8 @@ module ScoutApm
46
47
 
47
48
  methods.each do |method|
48
49
  if ::Mongoid::Contextual::Mongo.method_defined?(method)
49
- with_scout_instruments = %Q|
50
- def #{method}_with_scout_instruments(*args)
50
+ with_scout_instruments = %Q[
51
+ def #{method}_with_scout_instruments(*args, &block)
51
52
 
52
53
  req = ScoutApm::RequestManager.lookup
53
54
  *db, collection = view.collection.namespace.split(".")
@@ -60,7 +61,7 @@ module ScoutApm
60
61
 
61
62
  req.start_layer( layer )
62
63
  begin
63
- #{method}_without_scout_instruments
64
+ #{method}_without_scout_instruments(*args, &block)
64
65
  ensure
65
66
  req.stop_layer
66
67
  end
@@ -68,7 +69,7 @@ module ScoutApm
68
69
 
69
70
  alias_method :#{method}_without_scout_instruments, :#{method}
70
71
  alias_method :#{method}, :#{method}_with_scout_instruments
71
- |
72
+ ]
72
73
 
73
74
  ::Mongoid::Contextual::Mongo.class_eval(with_scout_instruments)
74
75
  end
@@ -39,7 +39,8 @@ module ScoutApm
39
39
  # this is set in the controller instumentation (ActionControllerRails3Rails4 according)
40
40
  attr_accessor :instant_key
41
41
 
42
- BACKTRACE_THRESHOLD = 0.5 # the minimum threshold in seconds to record the backtrace for a metric.
42
+ # Whereas the instant_key gets set per-request in reponse to a URL param, dev_trace is set in the config file
43
+ attr_accessor :dev_trace
43
44
 
44
45
  def initialize(store)
45
46
  @store = store #this is passed in so we can use a real store (normal operation) or fake store (instant mode only)
@@ -52,6 +53,7 @@ module ScoutApm
52
53
  @error = false
53
54
  @instant_key = nil
54
55
  @mem_start = mem_usage
56
+ @dev_trace = ScoutApm::Agent.instance.config.value('dev_trace') && Rails.env.development?
55
57
  end
56
58
 
57
59
  def start_layer(layer)
@@ -118,7 +120,7 @@ module ScoutApm
118
120
  return false unless (web? || job?)
119
121
 
120
122
  # Capture any individually slow layer.
121
- return true if layer.total_exclusive_time > BACKTRACE_THRESHOLD
123
+ return true if layer.total_exclusive_time > backtrace_threshold
122
124
 
123
125
  # Capture any layer that we've seen many times. Captures n+1 problems
124
126
  return true if @call_set[layer.name].capture_backtrace?
@@ -308,5 +310,11 @@ module ScoutApm
308
310
  def ignoring_children?
309
311
  @ignoring_children
310
312
  end
313
+
314
+ # Grab backtraces more aggressively when running in dev trace mode
315
+ def backtrace_threshold
316
+ dev_trace ? 0.05 : 0.5 # the minimum threshold in seconds to record the backtrace for a metric.
317
+ end
318
+
311
319
  end
312
320
  end
@@ -1,4 +1,4 @@
1
1
  module ScoutApm
2
- VERSION = "2.0.0.pre8"
2
+ VERSION = "2.0.0"
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.0.0.pre8
4
+ version: 2.0.0
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-07-15 00:00:00.000000000 Z
12
+ date: 2016-08-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rusage
@@ -252,12 +252,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
252
252
  version: '0'
253
253
  required_rubygems_version: !ruby/object:Gem::Requirement
254
254
  requirements:
255
- - - ">"
255
+ - - ">="
256
256
  - !ruby/object:Gem::Version
257
- version: 1.3.1
257
+ version: '0'
258
258
  requirements: []
259
259
  rubyforge_project: scout_apm
260
- rubygems_version: 2.6.2
260
+ rubygems_version: 2.4.6
261
261
  signing_key:
262
262
  specification_version: 4
263
263
  summary: Ruby application performance monitoring
@@ -278,4 +278,3 @@ test_files:
278
278
  - test/unit/slow_request_policy_test.rb
279
279
  - test/unit/sql_sanitizer_test.rb
280
280
  - test/unit/utils/active_record_metric_name_test.rb
281
- has_rdoc: