scout_apm 2.6.6 → 2.6.9

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
  SHA256:
3
- metadata.gz: 73af2b28e0b054233c1ccd48122741d7b8e27adf9c61ee93fea520f7e3a6b3c7
4
- data.tar.gz: 544c20bf5c56478269232f19a792dcbc00c125befb6e5e7b406be04dc954944e
3
+ metadata.gz: 54f1c7e07f92a0d5d67a22354b0273c4894e8408ec00bcdada275457ed2f00f2
4
+ data.tar.gz: 50cf2d441c948e769b2f2222895c84aadb0a5e3e3f75d16e647a2096a86551e4
5
5
  SHA512:
6
- metadata.gz: c8558cd998a6c54ca7cd3c3174ba96c28230b0041a49e2d494460116a6f9065ba28f998ce8a74b546f69a8f1d5ec5dd81b9be29e27f4a874f51e1352f02798f0
7
- data.tar.gz: 18f7152a257b7ff61cb0c4953542527a2af25220d726ac26ade9242421f817afc83ce18fa28ea018188215717cedb25336ba79a61572cb706f99f16278be3545
6
+ metadata.gz: 27a012457a6871cdbed206f2a55914163571e81af1b1f6253079c2fe9954354a9888b59627d832f3635a536ddf3f331c066b2bc4e053956f5135c706ffea1a17
7
+ data.tar.gz: cfc5d80fb3b0ccebc2e78246a394a23a8e16d52a89868cff024931d6ce5b3539aafc42ef6f491105db43f8c544750b270cbbc7cc1fed556ab543bb0d963f1c75
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,22 @@
1
+ # 2.6.9
2
+
3
+ * Add `ssl_cert_file` config option (#352)
4
+ * Improve sanitization of Postgres UPDATE SQL (#351)
5
+ * Allow custom URL sanitization (#341)
6
+
7
+ # 2.6.8
8
+
9
+ * Lock rake version for 1.8.7 to older version (#329)
10
+ * Delete unneeded .DS_Store file that snuck in (#334)
11
+ * Fix typo in "queue_time_ms"
12
+ * Fix Rails 6 deprecation warning at boot time (#337)
13
+ * Fix partial naming on Rails 6.0 (#339)
14
+ * Support Sidekiq 6.1 instrumentation (#340)
15
+
16
+ # 2.6.7
17
+
18
+ * Remove accidental call to `as_json`
19
+
1
20
  # 2.6.6
2
21
 
3
22
  * Add basic support for parsing Microsoft SQLServer queries (#317)
data/Gemfile CHANGED
@@ -10,4 +10,8 @@ if RUBY_VERSION <= "1.8.7"
10
10
  gem "pry", "~> 0.9.12"
11
11
  gem "rake", "~> 10.5"
12
12
  gem "minitest", "~> 5.11.3"
13
+ elsif RUBY_VERSION <= "1.9.3"
14
+ gem "rake", "~> 10.5"
15
+ else
16
+ gem "rake", ">= 12.3.3"
13
17
  end
@@ -40,10 +40,10 @@ module ScoutApm
40
40
  require 'sidekiq/processor' # sidekiq v4 has not loaded this file by this point
41
41
 
42
42
  ::Sidekiq::Processor.class_eval do
43
- def initialize_with_scout(boss)
43
+ def initialize_with_scout(*args)
44
44
  agent = ::ScoutApm::Agent.instance
45
45
  agent.start
46
- initialize_without_scout(boss)
46
+ initialize_without_scout(*args)
47
47
  end
48
48
 
49
49
  alias_method :initialize_without_scout, :initialize
@@ -75,6 +75,7 @@ module ScoutApm
75
75
  'revision_sha',
76
76
  'scm_subdirectory',
77
77
  'start_resque_server_instrument',
78
+ 'ssl_cert_file',
78
79
  'uri_reporting',
79
80
  'instrument_http_url_length',
80
81
  'timeline_traces',
@@ -284,7 +285,8 @@ module ScoutApm
284
285
  'collect_remote_ip' => true,
285
286
  'timeline_traces' => true,
286
287
  'auto_instruments' => false,
287
- 'auto_instruments_ignore' => []
288
+ 'auto_instruments_ignore' => [],
289
+ 'ssl_cert_file' => File.join( File.dirname(__FILE__), *%w[.. .. data cacert.pem] )
288
290
  }.freeze
289
291
 
290
292
  def value(key)
@@ -200,8 +200,9 @@ class DetailedTraceTags
200
200
  @tags = hash
201
201
  end
202
202
 
203
+ # @tags is already a hash, so no conversion needed
203
204
  def as_json(*)
204
- @tags.as_json
205
+ @tags
205
206
  end
206
207
  end
207
208
 
@@ -26,7 +26,7 @@ module ScoutApm
26
26
  # The time in queue of the transaction in ms. If not present, +nil+ is returned as this is unknown.
27
27
  def queue_time_ms
28
28
  # Controller logic
29
- if converter_results[:queue_time] && converter_results[:queue].any?
29
+ if converter_results[:queue_time] && converter_results[:queue_time].any?
30
30
  converter_results[:queue_time].values.first.total_call_time*1000 # ms
31
31
  # Job logic
32
32
  elsif converter_results[:job]
@@ -17,46 +17,73 @@ module ScoutApm
17
17
  @installed
18
18
  end
19
19
 
20
+ def installed!
21
+ @installed = true
22
+ end
23
+
20
24
  def install
21
- # We previously instrumented ActionController::Metal, which missed
22
- # before and after filter timing. Instrumenting Base includes those
23
- # filters, at the expense of missing out on controllers that don't use
24
- # the full Rails stack.
25
- if defined?(::ActionController)
26
- @installed = true
25
+ if !defined?(::ActiveSupport)
26
+ return
27
+ end
28
+
29
+ # The block below runs with `self` equal to the ActionController::Base or ::API module, not this class we're in now. By saving an instance of ourselves into the `this` variable, we can continue accessing what we need.
30
+ this = self
27
31
 
32
+ ActiveSupport.on_load(:action_controller) do
33
+ if this.installed?
34
+ this.logger.info("Skipping ActionController - Already Ran")
35
+ next
36
+ else
37
+ this.logger.info("Instrumenting ActionController (on_load)")
38
+ this.installed!
39
+ end
40
+
41
+ # We previously instrumented ActionController::Metal, which missed
42
+ # before and after filter timing. Instrumenting Base includes those
43
+ # filters, at the expense of missing out on controllers that don't use
44
+ # the full Rails stack.
28
45
  if defined?(::ActionController::Base)
29
- logger.info "Instrumenting ActionController::Base"
46
+ this.logger.info "Instrumenting ActionController::Base"
30
47
  ::ActionController::Base.class_eval do
31
- # include ScoutApm::Tracer
32
48
  include ScoutApm::Instruments::ActionControllerBaseInstruments
33
49
  end
34
50
  end
35
51
 
36
52
  if defined?(::ActionController::Metal)
37
- logger.info "Instrumenting ActionController::Metal"
53
+ this.logger.info "Instrumenting ActionController::Metal"
38
54
  ::ActionController::Metal.class_eval do
39
55
  include ScoutApm::Instruments::ActionControllerMetalInstruments
40
56
  end
41
57
  end
42
58
 
43
59
  if defined?(::ActionController::API)
44
- logger.info "Instrumenting ActionController::Api"
60
+ this.logger.info "Instrumenting ActionController::Api"
45
61
  ::ActionController::API.class_eval do
46
62
  include ScoutApm::Instruments::ActionControllerAPIInstruments
47
63
  end
48
64
  end
49
65
  end
50
66
 
51
- # Returns a new anonymous module each time it is called. So
52
- # we can insert this multiple times into the ancestors
53
- # stack. Otherwise it only exists the first time you include it
54
- # (under Metal, instead of under API) and we miss instrumenting
55
- # before_action callbacks
67
+ ScoutApm::Agent.instance.context.logger.info("Instrumenting ActionController (hook installed)")
56
68
  end
57
69
 
70
+ # Returns a new anonymous module each time it is called. So
71
+ # we can insert this multiple times into the ancestors
72
+ # stack. Otherwise it only exists the first time you include it
73
+ # (under Metal, instead of under API) and we miss instrumenting
74
+ # before_action callbacks
58
75
  def self.build_instrument_module
59
76
  Module.new do
77
+ # Determine the URI of this request to capture. Overridable by users in their controller.
78
+ def scout_transaction_uri(config=ScoutApm::Agent.instance.context.config)
79
+ case config.value("uri_reporting")
80
+ when 'path'
81
+ request.path # strips off the query string for more security
82
+ else # default handles filtered params
83
+ request.filtered_path
84
+ end
85
+ end
86
+
60
87
  def process_action(*args)
61
88
  req = ScoutApm::RequestManager.lookup
62
89
  current_layer = req.current_layer
@@ -72,7 +99,11 @@ module ScoutApm
72
99
  # Don't start a new layer if ActionController::API or ActionController::Base handled it already.
73
100
  super
74
101
  else
75
- req.annotate_request(:uri => ScoutApm::Instruments::ActionControllerRails3Rails4.scout_transaction_uri(request))
102
+ begin
103
+ uri = scout_transaction_uri
104
+ req.annotate_request(:uri => uri)
105
+ rescue
106
+ end
76
107
 
77
108
  # IP Spoofing Protection can throw an exception, just move on w/o remote ip
78
109
  if agent_context.config.value('collect_remote_ip')
@@ -95,16 +126,6 @@ module ScoutApm
95
126
  end
96
127
  end
97
128
 
98
- # Given an +ActionDispatch::Request+, formats the uri based on config settings.
99
- # XXX: Don't lookup context like this - find a way to pass it through
100
- def self.scout_transaction_uri(request, config=ScoutApm::Agent.instance.context.config)
101
- case config.value("uri_reporting")
102
- when 'path'
103
- request.path # strips off the query string for more security
104
- else # default handles filtered params
105
- request.filtered_path
106
- end
107
- end
108
129
  end
109
130
 
110
131
  module ActionControllerMetalInstruments
@@ -75,13 +75,18 @@ module ScoutApm
75
75
  end
76
76
 
77
77
  module ActionViewPartialRendererInstruments
78
+ # In Rails 6, the signature changed to pass the view & template args directly, as opposed to through the instance var
79
+ # New signature is: def render_partial(view, template)
78
80
  def render_partial(*args)
79
81
  req = ScoutApm::RequestManager.lookup
80
82
 
81
- template_name = @template.virtual_path rescue "Unknown Partial"
83
+ maybe_template = args[1]
84
+
85
+ template_name = @template.virtual_path rescue nil # Works on Rails 3.2 -> end of Rails 5 series
86
+ template_name ||= maybe_template.virtual_path rescue nil # Works on Rails 6 -> 6.0.3
82
87
  template_name ||= "Unknown Partial"
83
- layer_name = template_name + "/Rendering"
84
88
 
89
+ layer_name = template_name + "/Rendering"
85
90
  layer = ScoutApm::Layer.new("View", layer_name)
86
91
  layer.subscopable!
87
92
 
@@ -2,7 +2,6 @@ require 'openssl'
2
2
 
3
3
  module ScoutApm
4
4
  class Reporter
5
- CA_FILE = File.join( File.dirname(__FILE__), *%w[.. .. data cacert.pem] )
6
5
  VERIFY_MODE = OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT
7
6
 
8
7
  attr_reader :type
@@ -123,7 +122,7 @@ module ScoutApm
123
122
  proxy_uri.password).new(url.host, url.port)
124
123
  if url.is_a?(URI::HTTPS)
125
124
  http.use_ssl = true
126
- http.ca_file = CA_FILE
125
+ http.ca_file = config.value("ssl_cert_file")
127
126
  http.verify_mode = VERIFY_MODE
128
127
  end
129
128
  http
@@ -51,6 +51,7 @@ module ScoutApm
51
51
  sql.gsub!(PSQL_PLACEHOLDER, '?')
52
52
  sql.gsub!(PSQL_VAR_INTERPOLATION, '')
53
53
  sql.gsub!(PSQL_AFTER_WHERE) {|c| c.gsub(PSQL_REMOVE_STRINGS, '?')}
54
+ sql.gsub!(PSQL_AFTER_SET) {|c| c.gsub(PSQL_REMOVE_STRINGS, '?')}
54
55
  sql.gsub!(PSQL_REMOVE_INTEGERS, '?')
55
56
  sql.gsub!(PSQL_IN_CLAUSE, 'IN (?)')
56
57
  sql.gsub!(MULTIPLE_SPACES, ' ')
@@ -5,13 +5,13 @@ module ScoutApm
5
5
  MULTIPLE_SPACES = %r|\s+|.freeze
6
6
  MULTIPLE_QUESTIONS = /\?(,\?)+/.freeze
7
7
 
8
-
9
8
  PSQL_VAR_INTERPOLATION = %r|\[\[.*\]\]\s*$|.freeze
10
9
  PSQL_REMOVE_STRINGS = /'(?:[^']|'')*'/.freeze
11
10
  PSQL_REMOVE_INTEGERS = /(?<!LIMIT )\b\d+\b/.freeze
12
11
  PSQL_PLACEHOLDER = /\$\d+/.freeze
13
12
  PSQL_IN_CLAUSE = /IN\s+\(\?[^\)]*\)/.freeze
14
13
  PSQL_AFTER_WHERE = /(?:WHERE\s+).*?(?:SELECT|$)/i.freeze
14
+ PSQL_AFTER_SET = /(?:SET\s+).*?(?:WHERE|$)/i.freeze
15
15
 
16
16
  MYSQL_VAR_INTERPOLATION = %r|\[\[.*\]\]\s*$|.freeze
17
17
  MYSQL_REMOVE_INTEGERS = /(?<!LIMIT )\b\d+\b/.freeze
@@ -11,6 +11,7 @@ module ScoutApm
11
11
  PSQL_PLACEHOLDER = /\$\d+/.freeze
12
12
  PSQL_IN_CLAUSE = /IN\s+\(\?[^\)]*\)/.freeze
13
13
  PSQL_AFTER_WHERE = /(?:WHERE\s+).*?(?:SELECT|$)/i.freeze
14
+ PSQL_AFTER_SET = /(?:SET\s+).*?(?:WHERE|$)/i.freeze
14
15
 
15
16
  MYSQL_VAR_INTERPOLATION = %r|\[\[.*\]\]\s*$|.freeze
16
17
  MYSQL_REMOVE_INTEGERS = /\b\d+\b/.freeze
@@ -1,3 +1,3 @@
1
1
  module ScoutApm
2
- VERSION = "2.6.6"
2
+ VERSION = "2.6.9"
3
3
  end
@@ -139,6 +139,13 @@ module ScoutApm
139
139
  assert_equal %q|SELECT `blogs`.* FROM `blogs` WHERE (title = ?)|, ss.to_s
140
140
  end
141
141
 
142
+ def test_set_columns
143
+ sql = %q|UPDATE "mytable" SET "myfield" = 'fieldcontent', "countofthings" = 10 WHERE "user_id" = 10|
144
+
145
+ ss = SqlSanitizer.new(sql).tap{ |it| it.database_engine = :postgres }
146
+ assert_equal %q|UPDATE "mytable" SET "myfield" = ?, "countofthings" = ? WHERE "user_id" = ?|, ss.to_s
147
+ end
148
+
142
149
  def assert_faster_than(target_seconds)
143
150
  t1 = ::Time.now
144
151
  yield
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.6.6
4
+ version: 2.6.9
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-12-19 00:00:00.000000000 Z
12
+ date: 2020-08-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -281,7 +281,6 @@ files:
281
281
  - lib/scout_apm/instant/middleware.rb
282
282
  - lib/scout_apm/instant_reporting.rb
283
283
  - lib/scout_apm/instrument_manager.rb
284
- - lib/scout_apm/instruments/.DS_Store
285
284
  - lib/scout_apm/instruments/action_controller_rails_2.rb
286
285
  - lib/scout_apm/instruments/action_controller_rails_3_rails4.rb
287
286
  - lib/scout_apm/instruments/action_view.rb
@@ -461,7 +460,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
461
460
  - !ruby/object:Gem::Version
462
461
  version: '0'
463
462
  requirements: []
464
- rubygems_version: 3.0.4
463
+ rubygems_version: 3.0.6
465
464
  signing_key:
466
465
  specification_version: 4
467
466
  summary: Ruby application performance monitoring