scout_apm 1.3.3 → 1.3.4

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: ab8171fe01697f83d482fe4de6f9adf5362bd7e0
4
- data.tar.gz: 1769b4fb75335f58c6c23e72b53f34b1748c584e
3
+ metadata.gz: b6fbe68e8addf7bfe056ee52866c15e10af61a1d
4
+ data.tar.gz: d3dbd902ea249c19be319e72bd9bb4147e8c5612
5
5
  SHA512:
6
- metadata.gz: 874b8ecc93712deb4067b4c1b3c14c2a5449d9f2374dc18b881ca8e278681803c88d7f96eabb95b04a670ab57c036459044487058974eaddd66897ea83e0dd16
7
- data.tar.gz: 5fb6e5098f9db249fb57b549525d4e25b8d590837f052eb4dc43ebdb6b9205d142806be17204fa325ffe78affdcc6e1829913d049ab3b82245e1af171897ddd7
6
+ metadata.gz: 3702bf98e121cb3701d7e350f6d73aaf961b976cdf627a809848bf06c5185e7ad2837d0a33f40f2540732e89f6f5feb78309bedbb84bbf2bdb9cbcb10458fee9
7
+ data.tar.gz: 1811b990165b63124cc5dbc56f34416ed77b0c1008f556f96e29b8e4f9f9c9d8e9be2cad352b632dc5ec732cf39dd4bdb1b9b36866fb34fc91b115a78475766c
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,7 @@
1
+ # 1.3.4
2
+
3
+ * Fix backtracking issue with on of the SQL sanitization regexes
4
+
1
5
  # 1.3.3
2
6
 
3
7
  * Handling nil scope in LayerSlowTransactionConverter
@@ -49,7 +49,7 @@ module ScoutApm
49
49
  sql.gsub!(MYSQL_REMOVE_SINGLE_QUOTE_STRINGS, '?')
50
50
  sql.gsub!(MYSQL_REMOVE_DOUBLE_QUOTE_STRINGS, '?')
51
51
  sql.gsub!(MYSQL_REMOVE_INTEGERS, '?')
52
- sql.gsub!(MYSQL_IN_CLAUSE, '?')
52
+ sql.gsub!(MYSQL_IN_CLAUSE, 'IN (?)')
53
53
  sql.gsub!(MULTIPLE_QUESTIONS, '?')
54
54
  sql.strip!
55
55
  sql
@@ -7,17 +7,15 @@ module ScoutApm
7
7
 
8
8
  PSQL_VAR_INTERPOLATION = %r|\[\[.*\]\]\s*$|.freeze
9
9
  PSQL_REMOVE_STRINGS = /'(?:[^']|'')*'/.freeze
10
-
11
10
  PSQL_REMOVE_INTEGERS = /(?<!LIMIT )\b\d+\b/.freeze
12
-
13
11
  PSQL_PLACEHOLDER = /\$\d+/.freeze
14
- PSQL_IN_CLAUSE = /IN\s+\((\s*\?,?\s*)*\)/.freeze
12
+ PSQL_IN_CLAUSE = /IN\s+\(\?[^\)]*\)/.freeze
15
13
 
16
14
  MYSQL_VAR_INTERPOLATION = %r|\[\[.*\]\]\s*$|.freeze
17
15
  MYSQL_REMOVE_INTEGERS = /(?<!LIMIT )\b\d+\b/.freeze
18
16
  MYSQL_REMOVE_SINGLE_QUOTE_STRINGS = /'(?:[^']|'')*'/.freeze
19
17
  MYSQL_REMOVE_DOUBLE_QUOTE_STRINGS = /"(?:[^"]|"")*"/.freeze
20
- MYSQL_IN_CLAUSE = /IN\s+\((\s*\?,?\s*)*\)/.freeze
18
+ MYSQL_IN_CLAUSE = /IN\s+\(\?[^\)]*\)/.freeze
21
19
 
22
20
  SQLITE_VAR_INTERPOLATION = %r|\[\[.*\]\]\s*$|.freeze
23
21
  SQLITE_REMOVE_STRINGS = /'(?:[^']|'')*'/.freeze
@@ -9,13 +9,13 @@ module ScoutApm
9
9
  PSQL_REMOVE_STRINGS = /'(?:[^']|'')*'/.freeze
10
10
  PSQL_REMOVE_INTEGERS = /\b\d+\b/.freeze
11
11
  PSQL_PLACEHOLDER = /\$\d+/.freeze
12
- PSQL_IN_CLAUSE = /IN\s+\((\s*\?,?\s*)*\)/.freeze
12
+ PSQL_IN_CLAUSE = /IN\s+\(\?[^\)]*\)/.freeze
13
13
 
14
14
  MYSQL_VAR_INTERPOLATION = %r|\[\[.*\]\]\s*$|.freeze
15
15
  MYSQL_REMOVE_INTEGERS = /\b\d+\b/.freeze
16
16
  MYSQL_REMOVE_SINGLE_QUOTE_STRINGS = /'(?:[^']|'')*'/.freeze
17
17
  MYSQL_REMOVE_DOUBLE_QUOTE_STRINGS = /"(?:[^"]|"")*"/.freeze
18
- MYSQL_IN_CLAUSE = /IN\s+\((\s*\?,?\s*)*\)/.freeze
18
+ MYSQL_IN_CLAUSE = /IN\s+\(\?[^\)]*\)/.freeze
19
19
 
20
20
  SQLITE_VAR_INTERPOLATION = %r|\[\[.*\]\]\s*$|.freeze
21
21
  SQLITE_REMOVE_STRINGS = /'(?:[^']|'')*'/.freeze
@@ -1,4 +1,4 @@
1
1
  module ScoutApm
2
- VERSION = "1.3.3"
2
+ VERSION = "1.3.4"
3
3
  end
4
4
 
@@ -45,6 +45,15 @@ module ScoutApm
45
45
  assert_equal %q|SELECT "blogs".* FROM "blogs" WHERE id IN (?)|, ss.to_s
46
46
  end
47
47
 
48
+ def test_postgres_collapse_in_clause_performacne
49
+ sql = 'SELECT "users".* FROM "users" WHERE "users"."id" IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?)'
50
+ ss = SqlSanitizer.new(sql).tap{ |it| it.database_engine = :postgres }
51
+
52
+ assert_faster_than(0.01) do
53
+ assert_equal %q|SELECT "users".* FROM "users" WHERE "users"."id" IN (?)|, ss.to_s
54
+ end
55
+ end
56
+
48
57
  def test_mysql_where
49
58
  sql = %q|SELECT `users`.* FROM `users` WHERE `users`.`name` = ? [["name", "chris"]]|
50
59
  ss = SqlSanitizer.new(sql).tap{ |it| it.database_engine = :mysql }
@@ -57,6 +66,15 @@ module ScoutApm
57
66
  assert_equal %q|SELECT `blogs`.* FROM `blogs` ORDER BY `blogs`.`id` ASC LIMIT 1|, ss.to_s
58
67
  end
59
68
 
69
+ def test_mysql_collpase_in_clause_performance
70
+ sql = 'SELECT `users`.* FROM `users` WHERE `users`.`id` IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?)'
71
+ ss = SqlSanitizer.new(sql).tap{ |it| it.database_engine = :mysql }
72
+
73
+ assert_faster_than(0.01) do
74
+ assert_equal %q|SELECT `users`.* FROM `users` WHERE `users`.`id` IN (?)|, ss.to_s
75
+ end
76
+ end
77
+
60
78
  def test_mysql_literals
61
79
  sql = %q|SELECT `blogs`.* FROM `blogs` WHERE (title = 'abc')|
62
80
  ss = SqlSanitizer.new(sql).tap{ |it| it.database_engine = :mysql }
@@ -74,6 +92,15 @@ module ScoutApm
74
92
  assert_equal %q|SELECT `blogs`.* FROM `blogs` WHERE (title = 'a_c')|, ss.sql
75
93
  assert_equal %q|SELECT `blogs`.* FROM `blogs` WHERE (title = ?)|, ss.to_s
76
94
  end
95
+
96
+ def assert_faster_than(target_seconds)
97
+ t1 = ::Time.now
98
+ yield
99
+ t2 = ::Time.now
100
+
101
+ actual_time = t2.to_f - t1.to_f
102
+ assert (actual_time < target_seconds), "Code took too long to execute, expected time: #{target_seconds}, actual time: #{actual_time}}"
103
+ end
77
104
  end
78
105
  end
79
106
  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: 1.3.3
4
+ version: 1.3.4
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-02-10 00:00:00.000000000 Z
12
+ date: 2016-02-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest