scout_apm 2.5.1 → 2.5.2

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
- SHA1:
3
- metadata.gz: 89a778c6a185b81e358249aef0f9420bec2d9cbc
4
- data.tar.gz: d4f063fd0c52537c5780fab065052e3b1c989848
2
+ SHA256:
3
+ metadata.gz: c8715d4d303e068a7730e2ec2f788ee44c2bbd6762a3a3bd30cdcc9f167435b9
4
+ data.tar.gz: 58e17c6491c144b596a61501b01406b15da245b6ce517a7fdbcaddfa896b0929
5
5
  SHA512:
6
- metadata.gz: 2d46fa2cb57eb83c07c6a4b0552f9565834423b3af09402753524af2af81ff963d60a6b2fee6b19b8c786976baa61d67efc448477421f04f4fa0a84c5d97b3f2
7
- data.tar.gz: 6db9909c632798dd5be1976577d74fc099a7587359a4af2736ae0c020240b4640cf8c6bbf2a165c299b7fe22c41d3fc5d2b73866d8c30a71809ced3a33019b78
6
+ metadata.gz: da8ddf5b4bb2a6d2223b49c1071dad0dd966234f2ed7b2e05747c67a0e3a9368b3831ef0496f5e6b57bd785ef486d12aade25db6815c2bf9a78ce1fce5f2acdf
7
+ data.tar.gz: 9fc04fcf1fa8350b1c95b00c936612a6dfc575905f22821d86e4fa01474c3cd9eab1343857ece2d7cd7e631b625c4e7e4f2e24dc895068f59f08c7fbe0e777c2
data/.gitignore CHANGED
@@ -18,3 +18,4 @@ coverage/*
18
18
  lib/*.bundle
19
19
  lib/*.so
20
20
  log/scout_apm.log
21
+ gems/*.lock
data/.travis.yml CHANGED
@@ -1,25 +1,25 @@
1
1
  language: ruby
2
-
3
- rvm:
4
- - "1.8.7"
5
- - "1.9.3"
6
- - "2.0"
7
- - "2.2"
8
- - "2.4"
9
- - "2.5"
10
-
11
2
  cache: bundler
12
3
 
13
- before_install:
14
- # Don't gem update, since it tries to install RubyGems requiring 2.3+.
15
- # - gem update --system
16
-
17
- # Lock down the version. Newer versions only support Ruby 2.3+, but we need
18
- # to test back further.
19
- - gem install bundler -v '1.17.3'
20
-
21
- jobs:
4
+ matrix:
22
5
  include:
23
- - script: bundle exec rake test
24
- - script: bundle exec rubocop
25
- rvm: "2.5"
6
+ - rvm: "1.8.7"
7
+ gemfile: gems/rails3.gemfile
8
+ - rvm: "1.9.3"
9
+ gemfile: gems/rails3.gemfile
10
+ - rvm: 2.0
11
+ gemfile: gems/rails3.gemfile
12
+ - rvm: 2.1
13
+ gemfile: gems/rails3.gemfile
14
+ - rvm: 2.2
15
+ - rvm: 2.3
16
+ - rvm: 2.4
17
+ - rvm: 2.5
18
+ - rvm: 2.6
19
+ - rvm: 2.6
20
+ gemfile: gems/octoshark.gemfile
21
+ - rvm: 2.6
22
+ name: rubocop yo
23
+ script: bundle exec rubocop
24
+ - rvm: 2.6
25
+ gemfile: gems/rails3.gemfile
data/CHANGELOG.markdown CHANGED
@@ -1,6 +1,12 @@
1
+ # 2.5.2
2
+
3
+ * Don't process limited layers in detailed traces (#268)
4
+ * Fix OctoShark (and other gems which patch ActiveRecord) interaction (#217)
5
+ * Legacy [Rails 2.3 fix for as_json](https://github.com/scoutapp/scout_apm_ruby/pull/276)
6
+
1
7
  # 2.5.1
2
8
 
3
- * Decrease timeline trace span limit to 1,500 as an attempted workaround for [this bug](https://github.com/scoutapp/scout_apm_ruby/issues/267).
9
+ * Decrease timeline trace span limit to 1,500 to address [this bug](https://github.com/scoutapp/scout_apm_ruby/issues/267).
4
10
 
5
11
  # 2.5.0
6
12
 
data/gems/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # Gems
2
+
3
+ These gemfiles list specific configurations of gems that we use in travis testing.
4
+
5
+ ## Travis Matrix
6
+
7
+ ```yaml
8
+ matrix:
9
+ include:
10
+ - rvm: "1.8.7"
11
+ gemfile: gems/rails3.gemfile
12
+ ```
13
+
14
+ Using a gemfile controls the specific versions of the gems that are installed, and can be used to reproduce customer configurations for testing.
15
+
16
+ ## Local Testing
17
+
18
+ To install the gems specified by a specific gemfile:
19
+
20
+ ```
21
+ BUNDLE_GEMFILE=gems/rails5.gemfile bundle install
22
+ ```
23
+
24
+ Then, to run tests using these gems:
25
+
26
+ ```
27
+ BUNDLE_GEMFILE=gems/rails5.gemfile bundle exec rake
28
+ ```
@@ -0,0 +1,4 @@
1
+ eval_gemfile("../Gemfile")
2
+
3
+ # https://github.com/scoutapp/scout_apm_ruby/issues/217
4
+ gem 'octoshark'
@@ -0,0 +1,4 @@
1
+ eval_gemfile("../Gemfile")
2
+
3
+ gem "rails", "~> 3.2"
4
+ gem "sqlite3", "~> 1.3.5"
@@ -0,0 +1,4 @@
1
+ eval_gemfile("../Gemfile")
2
+
3
+ gem "rails", "~> 4.2"
4
+ gem "sqlite3", "~> 1.3.6"
@@ -0,0 +1,4 @@
1
+ eval_gemfile("../Gemfile")
2
+
3
+ gem "rails", "~> 5.0"
4
+ gem "sqlite3", "~> 1.3", ">= 1.3.6"
@@ -0,0 +1,4 @@
1
+ eval_gemfile("../Gemfile")
2
+
3
+ gem "rails", "~> 6.0.0rc1"
4
+ gem "sqlite3", "~> 1.4"
@@ -98,7 +98,7 @@ class DetailedTrace
98
98
  }
99
99
  },
100
100
  :tags => tags.as_json,
101
- :spans => spans.as_json,
101
+ :spans => spans.map{|span| span.as_json},
102
102
  }
103
103
  end
104
104
 
@@ -82,9 +82,14 @@ module ScoutApm
82
82
 
83
83
  # Install #log tracing
84
84
  if Utils::KlassHelper.defined?("ActiveRecord::ConnectionAdapters::AbstractAdapter")
85
- ::ActiveRecord::ConnectionAdapters::AbstractAdapter.module_eval do
86
- include ::ScoutApm::Instruments::ActiveRecordInstruments
87
- include ::ScoutApm::Tracer
85
+ if Module.respond_to?(:prepend)
86
+ ::ActiveRecord::ConnectionAdapters::AbstractAdapter.prepend(ActiveRecordInstruments)
87
+ ::ActiveRecord::ConnectionAdapters::AbstractAdapter.include(Tracer)
88
+ else
89
+ ::ActiveRecord::ConnectionAdapters::AbstractAdapter.module_eval do
90
+ include ::ScoutApm::Instruments::ActiveRecordAliasMethodInstruments
91
+ include ::ScoutApm::Tracer
92
+ end
88
93
  end
89
94
  end
90
95
 
@@ -167,7 +172,9 @@ module ScoutApm
167
172
  # to the real SQL, and an AR generated "name" for the Query
168
173
  #
169
174
  ################################################################################
170
- module ActiveRecordInstruments
175
+ #
176
+ # Note, if you change this instrumentation, you also need to change ActiveRecordInstruments.
177
+ module ActiveRecordAliasMethodInstruments
171
178
  def self.included(instrumented_class)
172
179
  ScoutApm::Agent.instance.context.logger.info "Instrumenting #{instrumented_class.inspect}"
173
180
  instrumented_class.class_eval do
@@ -225,6 +232,58 @@ module ScoutApm
225
232
  end
226
233
  end
227
234
 
235
+ module ActiveRecordInstruments
236
+ def self.prepended(instrumented_class)
237
+ ScoutApm::Agent.instance.context.logger.info "Instrumenting #{instrumented_class.inspect}"
238
+ end
239
+
240
+ def log(*args, &block)
241
+ # Extract data from the arguments
242
+ sql, name = args
243
+ metric_name = Utils::ActiveRecordMetricName.new(sql, name)
244
+ desc = SqlList.new(sql)
245
+
246
+ # Get current ScoutApm context
247
+ req = ScoutApm::RequestManager.lookup
248
+ current_layer = req.current_layer
249
+
250
+ # If we call #log, we have a real query to run, and we've already
251
+ # gotten through the cache gatekeeper. Since we want to only trace real
252
+ # queries, and not repeated identical queries that just hit cache, we
253
+ # mark layer as ignorable initially in #find_by_sql, then only when we
254
+ # know it's a real database call do we mark it back as usable.
255
+ #
256
+ # This flag is later used in SlowRequestConverter to skip adding ignorable layers
257
+ current_layer.annotate_layer(:ignorable => false) if current_layer
258
+
259
+ # Either: update the current layer and yield, don't start a new one.
260
+ if current_layer && current_layer.type == "ActiveRecord"
261
+ # TODO: Get rid of call .to_s, need to find this without forcing a previous run of the name logic
262
+ if current_layer.name.to_s == Utils::ActiveRecordMetricName::DEFAULT_METRIC
263
+ current_layer.name = metric_name
264
+ end
265
+
266
+ if current_layer.desc.nil?
267
+ current_layer.desc = SqlList.new
268
+ end
269
+ current_layer.desc.merge(desc)
270
+
271
+ super(*args, &block)
272
+
273
+ # OR: Start a new layer, we didn't pick up instrumentation earlier in the stack.
274
+ else
275
+ layer = ScoutApm::Layer.new("ActiveRecord", metric_name)
276
+ layer.desc = desc
277
+ req.start_layer(layer)
278
+ begin
279
+ super(*args, &block)
280
+ ensure
281
+ req.stop_layer
282
+ end
283
+ end
284
+ end
285
+ end
286
+
228
287
  ################################################################################
229
288
  # Entry-point of instruments.
230
289
  #
@@ -117,7 +117,9 @@ module ScoutApm
117
117
  tags)
118
118
 
119
119
  layer.children.each do |child|
120
- unless over_span_limit?(result)
120
+ # Don't create spans from limited layers. These don't have start/stop times and our processing can't
121
+ # handle these yet.
122
+ unless over_span_limit?(result) || child.is_a?(LimitedLayer)
121
123
  result += create_spans(child, span_id)
122
124
  end
123
125
  end
@@ -152,10 +154,8 @@ module ScoutApm
152
154
  # Limit Handling
153
155
  ################################################################################
154
156
 
155
- # To prevent huge traces from being generated, we should stop collecting
157
+ # To prevent huge traces from being generated, we stop collecting
156
158
  # spans as we go beyond some reasonably large count.
157
- # Until the root cause of https://github.com/scoutapp/scout_apm_ruby/issues/267 is addressed,
158
- # keep `MAX_SPANS` less than `DEFAULT_UNIQUE_CUTOFF`.
159
159
  MAX_SPANS = 1500
160
160
 
161
161
  def over_span_limit?(spans)
@@ -212,8 +212,8 @@ module ScoutApm
212
212
  def stop_request
213
213
  @stopping = true
214
214
 
215
- if recorder
216
- recorder.record!(self)
215
+ if @recorder
216
+ @recorder.record!(self)
217
217
  end
218
218
  end
219
219
 
@@ -1,3 +1,3 @@
1
1
  module ScoutApm
2
- VERSION = "2.5.1"
2
+ VERSION = "2.5.2"
3
3
  end
data/scout_apm.gemspec CHANGED
@@ -29,6 +29,12 @@ Gem::Specification.new do |s|
29
29
  s.add_development_dependency "addressable"
30
30
  s.add_development_dependency "activesupport"
31
31
 
32
+ # These are general development dependencies which are used in instrumentation
33
+ # tests. Specific versions are pulled in using specific gemfiles, e.g.
34
+ # `gems/rails3.gemfile`.
35
+ s.add_development_dependency "activerecord"
36
+ s.add_development_dependency "sqlite3"
37
+
32
38
  if RUBY_VERSION >= "1.9.3"
33
39
  s.add_development_dependency "rubocop"
34
40
  s.add_development_dependency "guard"
data/test/test_helper.rb CHANGED
@@ -100,7 +100,7 @@ class Minitest::Test
100
100
  end
101
101
 
102
102
  def agent_context
103
- ScoutApm::AgentContext.new
103
+ ScoutApm::Agent.instance.context
104
104
  end
105
105
 
106
106
  DATA_FILE_DIR = File.dirname(__FILE__) + '/tmp'
@@ -0,0 +1,40 @@
1
+ require 'test_helper'
2
+ require 'sqlite3'
3
+ require 'active_record'
4
+
5
+ begin
6
+ require 'octoshark'
7
+ rescue LoadError
8
+ # Ignore
9
+ end
10
+
11
+ class ActiveRecordTest < Minitest::Test
12
+ def database_path
13
+ File.expand_path('test.sqlite3', DATA_FILE_DIR)
14
+ end
15
+
16
+ def setup
17
+ database = SQLite3::Database.new(database_path)
18
+ database.execute("DROP TABLE IF EXISTS users;")
19
+ database.execute("CREATE TABLE users (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(100));")
20
+
21
+ ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => database_path)
22
+ end
23
+
24
+ class User < ActiveRecord::Base
25
+ end
26
+
27
+ def test_instrumentation
28
+ recorder = FakeRecorder.new
29
+ agent_context.recorder = recorder
30
+
31
+ instrument = ScoutApm::Instruments::ActiveRecord.new(agent_context)
32
+ instrument.install
33
+
34
+ ScoutApm::Tracer.instrument("Controller", "foo/bar") do
35
+ user = User.create
36
+ end
37
+
38
+ assert 1, recorder.requests.size
39
+ end
40
+ 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.5.1
4
+ version: 2.5.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: 2019-06-24 00:00:00.000000000 Z
12
+ date: 2019-08-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -109,6 +109,34 @@ dependencies:
109
109
  - - ">="
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: activerecord
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: sqlite3
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
112
140
  - !ruby/object:Gem::Dependency
113
141
  name: rubocop
114
142
  requirement: !ruby/object:Gem::Requirement
@@ -189,6 +217,12 @@ files:
189
217
  - ext/rusage/README.md
190
218
  - ext/rusage/extconf.rb
191
219
  - ext/rusage/rusage.c
220
+ - gems/README.md
221
+ - gems/octoshark.gemfile
222
+ - gems/rails3.gemfile
223
+ - gems/rails4.gemfile
224
+ - gems/rails5.gemfile
225
+ - gems/rails6.gemfile
192
226
  - lib/scout_apm.rb
193
227
  - lib/scout_apm/agent.rb
194
228
  - lib/scout_apm/agent/exit_handler.rb
@@ -332,6 +366,7 @@ files:
332
366
  - scout_apm.gemspec
333
367
  - test/data/config_test_1.yml
334
368
  - test/test_helper.rb
369
+ - test/tmp/README.md
335
370
  - test/unit/agent_test.rb
336
371
  - test/unit/background_job_integrations/sidekiq_test.rb
337
372
  - test/unit/config_test.rb
@@ -345,7 +380,7 @@ files:
345
380
  - test/unit/git_revision_test.rb
346
381
  - test/unit/histogram_test.rb
347
382
  - test/unit/ignored_uris_test.rb
348
- - test/unit/instruments/active_record_instruments_test.rb
383
+ - test/unit/instruments/active_record_test.rb
349
384
  - test/unit/instruments/net_http_test.rb
350
385
  - test/unit/instruments/percentile_sampler_test.rb
351
386
  - test/unit/layaway_test.rb
@@ -394,51 +429,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
394
429
  version: '0'
395
430
  requirements: []
396
431
  rubyforge_project: scout_apm
397
- rubygems_version: 2.4.6
432
+ rubygems_version: 2.7.6
398
433
  signing_key:
399
434
  specification_version: 4
400
435
  summary: Ruby application performance monitoring
401
- test_files:
402
- - test/data/config_test_1.yml
403
- - test/test_helper.rb
404
- - test/unit/agent_test.rb
405
- - test/unit/background_job_integrations/sidekiq_test.rb
406
- - test/unit/config_test.rb
407
- - test/unit/context_test.rb
408
- - test/unit/db_query_metric_set_test.rb
409
- - test/unit/db_query_metric_stats_test.rb
410
- - test/unit/environment_test.rb
411
- - test/unit/extensions/periodic_callbacks_test.rb
412
- - test/unit/extensions/transaction_callbacks_test.rb
413
- - test/unit/fake_store_test.rb
414
- - test/unit/git_revision_test.rb
415
- - test/unit/histogram_test.rb
416
- - test/unit/ignored_uris_test.rb
417
- - test/unit/instruments/active_record_instruments_test.rb
418
- - test/unit/instruments/net_http_test.rb
419
- - test/unit/instruments/percentile_sampler_test.rb
420
- - test/unit/layaway_test.rb
421
- - test/unit/layer_children_set_test.rb
422
- - test/unit/layer_converters/depth_first_walker_test.rb
423
- - test/unit/layer_converters/metric_converter_test.rb
424
- - test/unit/layer_converters/stubs.rb
425
- - test/unit/limited_layer_test.rb
426
- - test/unit/logger_test.rb
427
- - test/unit/metric_set_test.rb
428
- - test/unit/remote/test_message.rb
429
- - test/unit/remote/test_router.rb
430
- - test/unit/remote/test_server.rb
431
- - test/unit/scored_item_set_test.rb
432
- - test/unit/serializers/payload_serializer_test.rb
433
- - test/unit/slow_job_policy_test.rb
434
- - test/unit/slow_request_policy_test.rb
435
- - test/unit/sql_sanitizer_test.rb
436
- - test/unit/store_test.rb
437
- - test/unit/tracer_test.rb
438
- - test/unit/tracked_request_test.rb
439
- - test/unit/transaction_test.rb
440
- - test/unit/transaction_time_consumed_test.rb
441
- - test/unit/utils/active_record_metric_name_test.rb
442
- - test/unit/utils/backtrace_parser_test.rb
443
- - test/unit/utils/numbers_test.rb
444
- - test/unit/utils/scm.rb
436
+ test_files: []
@@ -1,5 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ActiveRecordInstrumentsTest < Minitest::Test
4
- end
5
-