scout_apm 2.2.0.pre1 → 2.2.0.pre2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 04b5ba56e4b5d547ab50ca2c7bf9de7ad51175b4
4
- data.tar.gz: d8a85c252b959e001d5b92498de94ab844a76f6b
3
+ metadata.gz: 9b1ea1128aa9aa0aa0b5086860810f324ffe732c
4
+ data.tar.gz: 00e3f0e517bfb8b580205bd7709a040fd13d611a
5
5
  SHA512:
6
- metadata.gz: 49365dc262bd4065eb827c3affc362d02e82b25e1638d67912f2d32ed2ac75bd08c490cb6a5071d9d352ce0f0b9a0531d8adea657c39f42913f28291f961eed3
7
- data.tar.gz: e931e86d96b7baf0a7fc329e17ce0683f953085b95cc6a01ca2ef67d13d1ba556d346a675fc96e9738ab65f5f2771fb90e49a2539952246f417873a3eebf16c1
6
+ metadata.gz: bea83409eb9f21cccbfc9aeeeeae3f4a22113cfdd13fa1f51ede6df3422ed5a0d2b7a15d922c7d132632c486430372c68616482b9d2356fd80689ba0cf9d74e8
7
+ data.tar.gz: 43c32ce10c3e01134904e19a1d2068c1b4a06ac928d44dbb3f1fd46e781ab98414737f9c004858f3ced00fe29534f91af0804f9b2559364ac3e15ad856020918
data/ext/stacks/stacks.c CHANGED
@@ -69,6 +69,12 @@ const long INTERVAL = 1000; // 1ms
69
69
 
70
70
  #endif
71
71
 
72
+ #ifdef T_IMEMO
73
+ #define VALID_RUBY_FRAME T_IMEMO
74
+ #else
75
+ #define VALID_RUBY_FRAME T_DATA
76
+ #endif
77
+
72
78
 
73
79
 
74
80
  #ifdef RUBY_INTERNAL_EVENT_NEWOBJ
@@ -403,7 +409,7 @@ static VALUE rb_scout_profile_frames(VALUE self)
403
409
  if (_traces[i].num_tracelines > 0) {
404
410
  trace = rb_ary_new2(_traces[i].num_tracelines);
405
411
  for(n = 0; n < _traces[i].num_tracelines; n++) {
406
- if (TYPE(_traces[i].frames_buf[n]) == RUBY_T_DATA) { // We should always get valid frames from rb_profile_frames, but that doesn't always seem to be the case
412
+ if (TYPE(_traces[i].frames_buf[n]) == VALID_RUBY_FRAME) { // We should always get valid frames from rb_profile_frames, but that doesn't always seem to be the case
407
413
  trace_line = rb_ary_new2(2);
408
414
  rb_ary_store(trace_line, 0, _traces[i].frames_buf[n]);
409
415
  rb_ary_store(trace_line, 1, INT2FIX(_traces[i].lines_buf[n]));
data/lib/scout_apm.rb CHANGED
@@ -165,6 +165,8 @@ if defined?(Rails) && defined?(Rails::VERSION) && defined?(Rails::VERSION::MAJOR
165
165
  end
166
166
  class Railtie < Rails::Railtie
167
167
  initializer 'scout_apm.start' do |app|
168
+ # Install the middleware every time in development mode.
169
+ # The middleware is a noop if dev_trace is not enabled in config
168
170
  if Rails.env.development?
169
171
  app.middleware.use ScoutApm::Instant::Middleware
170
172
  end
@@ -112,7 +112,10 @@ module ScoutApm
112
112
  # It initializes the agent and starts the worker thread (if appropiate).
113
113
  def start(options = {})
114
114
  @options.merge!(options)
115
+
115
116
  @config = ScoutApm::Config.with_file(@config.value("config_file"))
117
+ layaway.config = config
118
+
116
119
  init_logger
117
120
  logger.info "Attempting to start Scout Agent [#{ScoutApm::VERSION}] on [#{environment.hostname}]"
118
121
 
@@ -41,8 +41,7 @@ module ScoutApm
41
41
  # Note that this middleware never even gets inserted unless Rails environment is development (See Railtie)
42
42
  class Middleware
43
43
  def initialize(app)
44
- ScoutApm::Agent.instance.logger.info("Activating Scout DevTrace because environment=development and dev_trace=true in scout_apm config")
45
- @app = app
44
+ @app = app
46
45
  end
47
46
 
48
47
  def call(env)
@@ -18,7 +18,7 @@ module ScoutApm
18
18
  # Must be sortable as an integer
19
19
  TIME_FORMAT = "%Y%m%d%H%M"
20
20
 
21
- attr_reader :config
21
+ attr_accessor :config
22
22
  attr_reader :environment
23
23
 
24
24
  def initialize(config, environment)
@@ -69,14 +69,19 @@ module ScoutApm
69
69
 
70
70
  @mutex.synchronize {
71
71
  reporting_periods.select { |time, rp| force || time.timestamp < current_timestamp.timestamp}.
72
- each { |time, rp|
73
- collect_samplers(rp)
74
- layaway.write_reporting_period(rp)
75
- reporting_periods.delete(time)
76
- }
72
+ each { |time, rp| write_reporting_period(layaway, time, rp) }
77
73
  }
78
74
  end
79
75
 
76
+ def write_reporting_period(layaway, time, rp)
77
+ collect_samplers(rp)
78
+ layaway.write_reporting_period(rp)
79
+ rescue => e
80
+ ScoutApm::Agent.instance.logger.warn("Failed writing data to layaway file: #{e.message} / #{e.backtrace}")
81
+ ensure
82
+ reporting_periods.delete(time)
83
+ end
84
+
80
85
  ######################################
81
86
  # Sampler support
82
87
  def add_sampler(sampler)
@@ -1,4 +1,4 @@
1
1
  module ScoutApm
2
- VERSION = "2.2.0.pre1"
2
+ VERSION = "2.2.0.pre2"
3
3
  end
4
4
 
@@ -0,0 +1,23 @@
1
+ require 'test_helper'
2
+
3
+ require 'scout_apm/store'
4
+
5
+ class FakeFailingLayaway
6
+ def write_reporting_period(rp)
7
+ raise "Always fails. Sucks."
8
+ end
9
+ end
10
+
11
+ class StoreTest < Minitest::Test
12
+ # TODO: Introduce a clock object to avoid having to use 'force'
13
+ def test_writing_layaway_removes_timestamps
14
+ s = ScoutApm::Store.new
15
+ s.track_one!("Controller", "user/show", 10)
16
+
17
+ assert_equal(1, s.reporting_periods.size)
18
+
19
+ s.write_to_layaway(FakeFailingLayaway.new, true)
20
+
21
+ assert_equal({}, s.reporting_periods)
22
+ end
23
+ end
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.2.0.pre1
4
+ version: 2.2.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: 2016-08-18 00:00:00.000000000 Z
12
+ date: 2016-08-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rusage
@@ -241,6 +241,7 @@ files:
241
241
  - test/unit/slow_job_policy_test.rb
242
242
  - test/unit/slow_request_policy_test.rb
243
243
  - test/unit/sql_sanitizer_test.rb
244
+ - test/unit/store_test.rb
244
245
  - test/unit/utils/active_record_metric_name_test.rb
245
246
  - test/unit/utils/backtrace_parser_test.rb
246
247
  - tester.rb