scout_apm 1.2.12 → 1.2.13

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: 238644dc9ea19370a84d3bb7c352faef442b555e
4
- data.tar.gz: 7c43ada6596aed42f483084fab03c66a50f9732a
3
+ metadata.gz: 0f13ea6034c312de70bf591cd4098cd925439d0a
4
+ data.tar.gz: 46cfdd7065339dd4089eec27cdb9faa855e09224
5
5
  SHA512:
6
- metadata.gz: e882ef1bbf5ac0b908dc249c4ffdde6e7db167a5d909d89c70ca974fdf9deb63ceadf987c33418de5a426782621c0b67d2589f97872642c52a45a185e15ac7cf
7
- data.tar.gz: b40f7a9b49bc263d209d13e27fb6fe448861e166bf17e3bae8a95253ddd4acf07900f30af97171824218dc47b2941e87578bded7db69752aa878c90ad3347003
6
+ metadata.gz: 89411a5bd8b03ef4d7db33297827c03df6f9acc965dbd0b512993c7bf9b5d4eef9f4b2d0e51ca657ff2decfd2f2fd096a3b0dc412c98ce9cdefbe018381afbbc
7
+ data.tar.gz: c0d3c36fd63ca7332826a5ad69eabc2e803b7ebdfcf63bb879372213abb32f5d7c8c6aea75c5a0d48f895f8ba3c36d249bcbff504b5eef31f28336ebf693fe25
@@ -1,6 +1,13 @@
1
+ # 1.2.13
2
+
3
+ * SQL Sanitation-Related performance improvements:
4
+ * Lazy sanitation of SQL queries: only running when needed (a slow transaction is recorded)
5
+ * An SQL sanitation performance improvement (strip! vs. gsub!)
6
+ * Removing the TRAILING_SPACES regex - not used across all db engines and adds a bit more overhead
7
+
1
8
  # 1.2.12
2
9
 
3
- * add uri_reporting option to report bare path (as opposed to fullpath). Default is 'fullpath'; set to 'path' to avoid exposing URL parameters.
10
+ * Add uri_reporting option to report bare path (as opposed to fullpath). Default is 'fullpath'; set to 'path' to avoid exposing URL parameters.
4
11
 
5
12
  # 1.2.11
6
13
 
@@ -33,9 +33,10 @@ module ScoutApm
33
33
  end
34
34
 
35
35
  def database_engine
36
+ return @database_engine if @database_engine
36
37
  default = :mysql
37
38
 
38
- if defined?(ActiveRecord::Base)
39
+ @database_engine = if defined?(ActiveRecord::Base)
39
40
  adapter = get_database_adapter # can be nil
40
41
 
41
42
  case adapter.to_s
@@ -59,4 +60,4 @@ module ScoutApm
59
60
  end
60
61
  end
61
62
  end
62
- end
63
+ end
@@ -60,7 +60,7 @@ module ScoutApm
60
60
  sql, name = args
61
61
  self.class.instrument("ActiveRecord",
62
62
  Utils::ActiveRecordMetricName.new(sql, name).metric_name,
63
- :desc => Utils::SqlSanitizer.new(sql).to_s ) do
63
+ :desc => Utils::SqlSanitizer.new(sql) ) do
64
64
  log_without_scout_instruments(sql, name, &block)
65
65
  end
66
66
  end
@@ -24,7 +24,6 @@ module ScoutApm
24
24
  end
25
25
  end
26
26
  end
27
-
28
27
  end
29
28
 
30
29
  # Take a TrackedRequest and turn it into a hash of:
@@ -55,8 +54,6 @@ module ScoutApm
55
54
  {:scope => scope_layer.legacy_metric_name}
56
55
  end
57
56
 
58
- meta_options.merge!(:desc => layer.desc) if layer.desc
59
-
60
57
  meta = MetricMeta.new(layer.legacy_metric_name, meta_options)
61
58
  metric_hash[meta] ||= MetricStats.new( meta_options.has_key?(:scope) )
62
59
 
@@ -159,7 +156,7 @@ module ScoutApm
159
156
  end
160
157
 
161
158
  # Specific Metric
162
- meta_options.merge!(:desc => layer.desc) if layer.desc
159
+ meta_options.merge!(:desc => layer.desc.to_s) if layer.desc
163
160
  meta = MetricMeta.new(layer.legacy_metric_name, meta_options)
164
161
  meta.extra.merge!(:backtrace => ScoutApm::SlowTransaction.backtrace_parser(layer.backtrace)) if layer.backtrace
165
162
  metric_hash[meta] ||= MetricStats.new( meta_options.has_key?(:scope) )
@@ -12,14 +12,17 @@ module ScoutApm
12
12
  end
13
13
  include ScoutApm::Utils::SqlRegex
14
14
 
15
- attr_reader :sql
16
15
  attr_accessor :database_engine
17
16
 
18
17
  def initialize(sql)
19
- @sql = scrubbed(sql.dup)
18
+ @raw_sql = sql
20
19
  @database_engine = ScoutApm::Environment.instance.database_engine
21
20
  end
22
21
 
22
+ def sql
23
+ @sql ||= scrubbed(@raw_sql.dup) # don't do this in initialize as it is extra work that isn't needed unless we have a slow transaction.
24
+ end
25
+
23
26
  def to_s
24
27
  case database_engine
25
28
  when :postgres then to_s_postgres
@@ -37,7 +40,7 @@ module ScoutApm
37
40
  sql.gsub!(PSQL_REMOVE_INTEGERS, '?')
38
41
  sql.gsub!(PSQL_IN_CLAUSE, 'IN (?)')
39
42
  sql.gsub!(MULTIPLE_SPACES, ' ')
40
- sql.gsub!(TRAILING_SPACES, '')
43
+ sql.strip!
41
44
  sql
42
45
  end
43
46
 
@@ -48,7 +51,7 @@ module ScoutApm
48
51
  sql.gsub!(MYSQL_REMOVE_INTEGERS, '?')
49
52
  sql.gsub!(MYSQL_IN_CLAUSE, '?')
50
53
  sql.gsub!(MULTIPLE_QUESTIONS, '?')
51
- sql.gsub!(TRAILING_SPACES, '')
54
+ sql.strip!
52
55
  sql
53
56
  end
54
57
 
@@ -57,7 +60,8 @@ module ScoutApm
57
60
  sql.gsub!(SQLITE_REMOVE_STRINGS, '?')
58
61
  sql.gsub!(SQLITE_REMOVE_INTEGERS, '?')
59
62
  sql.gsub!(MULTIPLE_SPACES, ' ')
60
- sql.gsub!(TRAILING_SPACES, '')
63
+ sql.strip!
64
+ sql
61
65
  end
62
66
 
63
67
  def has_encodings?(encodings=['UTF-8', 'binary'])
@@ -4,7 +4,6 @@ module ScoutApm
4
4
  module SqlRegex
5
5
  MULTIPLE_SPACES = %r|\s+|.freeze
6
6
  MULTIPLE_QUESTIONS = /\?(,\?)+/.freeze
7
- TRAILING_SPACES = /\s+$/.freeze
8
7
 
9
8
  PSQL_VAR_INTERPOLATION = %r|\[\[.*\]\]\s*$|.freeze
10
9
  PSQL_REMOVE_STRINGS = /'(?:[^']|'')*'/.freeze
@@ -4,7 +4,6 @@ module ScoutApm
4
4
  module SqlRegex
5
5
  MULTIPLE_SPACES = %r|\s+|.freeze
6
6
  MULTIPLE_QUESTIONS = /\?(,\?)+/.freeze
7
- TRAILING_SPACES = /\s+$/.freeze
8
7
 
9
8
  PSQL_VAR_INTERPOLATION = %r|\[\[.*\]\]\s*$|.freeze
10
9
  PSQL_REMOVE_STRINGS = /'(?:[^']|'')*'/.freeze
@@ -1,4 +1,4 @@
1
1
  module ScoutApm
2
- VERSION = "1.2.12"
2
+ VERSION = "1.2.13"
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: 1.2.12
4
+ version: 1.2.13
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-01-29 00:00:00.000000000 Z
12
+ date: 2016-02-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -176,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
176
  version: '0'
177
177
  requirements: []
178
178
  rubyforge_project: scout_apm
179
- rubygems_version: 2.2.2
179
+ rubygems_version: 2.4.6
180
180
  signing_key:
181
181
  specification_version: 4
182
182
  summary: Ruby application performance monitoring