scout_apm 2.4.0.pre2 → 2.4.0.pre3

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: 08385e64d3b8d96ae39c02f892b637dfd0a9b154
4
- data.tar.gz: 3ab13e2996230a611bca4907bd439d5503b05af5
3
+ metadata.gz: 29cede8ad70dd0d7cb0be6a777da5d346309ff24
4
+ data.tar.gz: 17f98116601cc9b75c3d0da0e9f315f2250af174
5
5
  SHA512:
6
- metadata.gz: 50d959241a2921399d5d05e67add7b75000782e24ae9276c3a99460b9dcfcb076f72b230c6e35f29cb47f3dd3a75e2fb6487490e084f97403dfe030e4cf7210a
7
- data.tar.gz: 6d36b242cc269e99981dae5fda755aa8bee1ef73616e1afc9dbabcd9a81aca3190f42d27fc6dddcc5b7309078b0ad6086e17008720ad90b35af0765f7ec237b2
6
+ metadata.gz: 4b5717805b91c5f13ab00e22c5739b4bba32ab7f4bf1eae18118607019937cfba7ad53dfd76086ddc1c5d8fcd2f2350686b594cbb5b6b3a44a61b4759305cad3
7
+ data.tar.gz: 60b82a60a84001d6a480f2ebdbf16cb5c964e729b30bcbc82c47b0cd526aea71802e3b753bb568176d5a4beca02a1a2d5bdf9b012a0bb48318fc6fb6b2908307
data/CHANGELOG.markdown CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  * Rework agent startup sequence
4
4
 
5
+ # 2.3.3
6
+
7
+ * Capture ActiveRecord calls that generate more complex queries
8
+
5
9
  # 2.3.2
6
10
 
7
11
  * More robust startup sequence when using `rails server` vs. directly launching an app server
@@ -1,6 +1,38 @@
1
1
  require 'scout_apm/utils/sql_sanitizer'
2
2
 
3
3
  module ScoutApm
4
+ class SqlList
5
+ attr_reader :sqls
6
+
7
+ def initialize(sql=nil)
8
+ @sqls = []
9
+
10
+ if !sql.nil?
11
+ push(sql)
12
+ end
13
+ end
14
+
15
+ def <<(sql)
16
+ push(sql)
17
+ end
18
+
19
+ def push(sql)
20
+ if !(Utils::SqlSanitizer === sql)
21
+ sql = Utils::SqlSanitizer.new(sql)
22
+ end
23
+ @sqls << sql
24
+ end
25
+
26
+ # All of this one, then all of the other.
27
+ def merge(other)
28
+ @sqls += other.sqls
29
+ end
30
+
31
+ def to_s
32
+ @sqls.map{|s| s.to_s }.join(";\n")
33
+ end
34
+ end
35
+
4
36
  module Instruments
5
37
  class ActiveRecord
6
38
  attr_reader :context
@@ -129,13 +161,12 @@ module ScoutApm
129
161
  # Extract data from the arguments
130
162
  sql, name = args
131
163
  metric_name = Utils::ActiveRecordMetricName.new(sql, name)
132
- desc = Utils::SqlSanitizer.new(sql)
164
+ desc = SqlList.new(sql)
133
165
 
134
166
  # Get current ScoutApm context
135
167
  req = ScoutApm::RequestManager.lookup
136
168
  current_layer = req.current_layer
137
169
 
138
-
139
170
  # If we call #log, we have a real query to run, and we've already
140
171
  # gotten through the cache gatekeeper. Since we want to only trace real
141
172
  # queries, and not repeated identical queries that just hit cache, we
@@ -150,9 +181,13 @@ module ScoutApm
150
181
  # TODO: Get rid of call .to_s, need to find this without forcing a previous run of the name logic
151
182
  if current_layer.name.to_s == Utils::ActiveRecordMetricName::DEFAULT_METRIC
152
183
  current_layer.name = metric_name
153
- current_layer.desc = desc
154
184
  end
155
185
 
186
+ if current_layer.desc.nil?
187
+ current_layer.desc = SqlList.new
188
+ end
189
+ current_layer.desc.merge(desc)
190
+
156
191
  log_without_scout_instruments(*args, &block)
157
192
 
158
193
  # OR: Start a new layer, we didn't pick up instrumentation earlier in the stack.
@@ -229,6 +264,7 @@ module ScoutApm
229
264
  req = ScoutApm::RequestManager.lookup
230
265
  layer = ScoutApm::Layer.new("ActiveRecord", Utils::ActiveRecordMetricName::DEFAULT_METRIC)
231
266
  layer.annotate_layer(:ignorable => true)
267
+ layer.desc = SqlList.new
232
268
  req.start_layer(layer)
233
269
  req.ignore_children!
234
270
  begin
@@ -247,6 +283,7 @@ module ScoutApm
247
283
 
248
284
  req = ScoutApm::RequestManager.lookup
249
285
  layer = ScoutApm::Layer.new("ActiveRecord", Utils::ActiveRecordMetricName.new("", "#{model} #{operation}"))
286
+ layer.desc = SqlList.new
250
287
  req.start_layer(layer)
251
288
  req.ignore_children!
252
289
  begin
@@ -145,7 +145,7 @@ module ScoutApm
145
145
  end
146
146
  end
147
147
 
148
- def make_meta_options_desc_hash(layer, max_desc_length=1000)
148
+ def make_meta_options_desc_hash(layer, max_desc_length=32768)
149
149
  if layer.desc
150
150
  desc_s = layer.desc.to_s
151
151
  trimmed_desc = desc_s[0 .. max_desc_length]
@@ -74,8 +74,10 @@ module ScoutApm
74
74
  encodings.all?{|enc| Encoding.find(enc) rescue false}
75
75
  end
76
76
 
77
+ MAX_SQL_LENGTH = 16384
78
+
77
79
  def scrubbed(str)
78
- return '' if !str.is_a?(String) || str.length > 4000 # safeguard - don't sanitize or scrub large SQL statements
80
+ return '' if !str.is_a?(String) || str.length > MAX_SQL_LENGTH # safeguard - don't sanitize or scrub large SQL statements
79
81
  return str if !str.respond_to?(:encode) # Ruby <= 1.8 doesn't have string encoding
80
82
  return str if str.valid_encoding? # Whatever encoding it is, it is valid and we can operate on it
81
83
  ScoutApm::Agent.instance.context.logger.debug "Scrubbing invalid sql encoding."
@@ -1,4 +1,4 @@
1
1
  module ScoutApm
2
- VERSION = "2.4.0.pre2"
2
+ VERSION = "2.4.0.pre3"
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.4.0.pre2
4
+ version: 2.4.0.pre3
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: 2017-12-13 00:00:00.000000000 Z
12
+ date: 2017-12-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest