scout_apm 4.0.4 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +4 -0
- data/CHANGELOG.markdown +33 -0
- data/LICENSE.md +21 -28
- data/gems/typhoeus.gemfile +3 -0
- data/lib/scout_apm/agent/preconditions.rb +3 -3
- data/lib/scout_apm/auto_instrument/rails.rb +0 -1
- data/lib/scout_apm/background_job_integrations/shoryuken.rb +2 -0
- data/lib/scout_apm/background_job_integrations/sidekiq.rb +13 -2
- data/lib/scout_apm/config.rb +10 -0
- data/lib/scout_apm/error_service/middleware.rb +2 -2
- data/lib/scout_apm/error_service/payload.rb +1 -1
- data/lib/scout_apm/error_service.rb +3 -1
- data/lib/scout_apm/external_service_metric_set.rb +97 -0
- data/lib/scout_apm/external_service_metric_stats.rb +85 -0
- data/lib/scout_apm/fake_store.rb +3 -0
- data/lib/scout_apm/framework_integrations/rails_3_or_4.rb +5 -1
- data/lib/scout_apm/git_revision.rb +9 -0
- data/lib/scout_apm/ignored_uris.rb +3 -1
- data/lib/scout_apm/instant/middleware.rb +2 -0
- data/lib/scout_apm/instruments/action_controller_rails_3_rails4.rb +5 -2
- data/lib/scout_apm/instruments/action_view.rb +13 -5
- data/lib/scout_apm/instruments/active_record.rb +2 -0
- data/lib/scout_apm/instruments/elasticsearch.rb +2 -0
- data/lib/scout_apm/instruments/sinatra.rb +2 -0
- data/lib/scout_apm/instruments/typhoeus.rb +8 -6
- data/lib/scout_apm/layer_converters/external_service_converter.rb +65 -0
- data/lib/scout_apm/layer_converters/find_layer_by_type.rb +4 -0
- data/lib/scout_apm/layer_converters/request_queue_time_converter.rb +2 -0
- data/lib/scout_apm/logger.rb +2 -2
- data/lib/scout_apm/reporting.rb +2 -1
- data/lib/scout_apm/serializers/external_service_serializer_to_json.rb +15 -0
- data/lib/scout_apm/serializers/payload_serializer.rb +4 -3
- data/lib/scout_apm/serializers/payload_serializer_to_json.rb +4 -1
- data/lib/scout_apm/store.rb +21 -1
- data/lib/scout_apm/tracked_request.rb +7 -1
- data/lib/scout_apm/utils/sql_sanitizer.rb +32 -6
- data/lib/scout_apm/version.rb +1 -1
- data/lib/scout_apm.rb +5 -0
- data/scout_apm.gemspec +0 -2
- data/test/unit/auto_instrument/anonymous_block_value.rb +7 -0
- data/test/unit/auto_instrument/hanging_method.rb +6 -0
- data/test/unit/auto_instrument_test.rb +8 -0
- data/test/unit/external_service_metric_set_test.rb +67 -0
- data/test/unit/external_service_metric_stats_test.rb +106 -0
- data/test/unit/ignored_uris_test.rb +6 -0
- data/test/unit/instruments/typhoeus_test.rb +42 -0
- data/test/unit/remote/{test_message.rb → message_test.rb} +0 -0
- data/test/unit/remote/{test_router.rb → route_test.rb} +0 -0
- data/test/unit/remote/{test_server.rb → server_test.rb} +4 -1
- data/test/unit/serializers/payload_serializer_test.rb +3 -3
- data/test/unit/sql_sanitizer_test.rb +19 -2
- metadata +16 -9
- data/.travis.yml +0 -22
- data/lib/scout_apm/utils/sql_sanitizer_regex.rb +0 -32
- data/lib/scout_apm/utils/sql_sanitizer_regex_1_8_7.rb +0 -32
@@ -8,7 +8,7 @@ class PayloadSerializerTest < Minitest::Test
|
|
8
8
|
:unique_id => "unique_idz",
|
9
9
|
:agent_version => 123
|
10
10
|
}
|
11
|
-
payload = ScoutApm::Serializers::PayloadSerializerToJson.serialize(metadata, {}, {}, [], [], [], {}, [])
|
11
|
+
payload = ScoutApm::Serializers::PayloadSerializerToJson.serialize(metadata, {}, {}, [], [], [], {}, {}, [])
|
12
12
|
|
13
13
|
# symbol keys turn to strings
|
14
14
|
formatted_metadata = {
|
@@ -49,7 +49,7 @@ class PayloadSerializerTest < Minitest::Test
|
|
49
49
|
stats.total_exclusive_time = 0.078132088
|
50
50
|
}
|
51
51
|
}
|
52
|
-
payload = ScoutApm::Serializers::PayloadSerializerToJson.serialize({}, metrics, {}, [], [], [], {}, [])
|
52
|
+
payload = ScoutApm::Serializers::PayloadSerializerToJson.serialize({}, metrics, {}, [], [], [], {}, {}, [])
|
53
53
|
formatted_metrics = [
|
54
54
|
{
|
55
55
|
"key" => {
|
@@ -94,7 +94,7 @@ class PayloadSerializerTest < Minitest::Test
|
|
94
94
|
:quotie => "here are some \"quotes\"",
|
95
95
|
:payload_version => 2,
|
96
96
|
}
|
97
|
-
payload = ScoutApm::Serializers::PayloadSerializerToJson.serialize(metadata, {}, {}, [], [], [], {}, [])
|
97
|
+
payload = ScoutApm::Serializers::PayloadSerializerToJson.serialize(metadata, {}, {}, [], [], [], {}, {}, [])
|
98
98
|
|
99
99
|
# symbol keys turn to strings
|
100
100
|
formatted_metadata = {
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
|
1
3
|
require 'test_helper'
|
2
4
|
|
3
5
|
module ScoutApm
|
@@ -38,9 +40,9 @@ module ScoutApm
|
|
38
40
|
end
|
39
41
|
|
40
42
|
def test_postgres_strips_subquery_strings
|
41
|
-
raw_sql = %q|"SELECT
|
43
|
+
raw_sql = %q|"SELECT "orgs".* FROM "orgs" WHERE "orgs"."name" = 'Scout' AND "orgs"."created_by_user_id" IN (SELECT "users"."id" FROM "users" WHERE (id > AVG(id)) AND "type" = 'USER' AND "created_at" BETWEEN '2019-04-17 12:28:00.000000' AND '2019-04-18 12:28:00.000000')"|
|
42
44
|
sanitized_sql = SqlSanitizer.new(raw_sql).tap { |it| it.database_engine = :postgres}
|
43
|
-
expected_sql = %q|"SELECT
|
45
|
+
expected_sql = %q|"SELECT "orgs".* FROM "orgs" WHERE "orgs"."name" = ? AND "orgs"."created_by_user_id" IN (SELECT "users"."id" FROM "users" WHERE (id > AVG(id)) AND "type" = ? AND "created_at" BETWEEN ? AND ?)"|
|
44
46
|
assert_equal expected_sql, sanitized_sql.to_s
|
45
47
|
end
|
46
48
|
|
@@ -66,6 +68,21 @@ module ScoutApm
|
|
66
68
|
end
|
67
69
|
end
|
68
70
|
|
71
|
+
def test_postgres_inner_join_subquery
|
72
|
+
sql = %q{SELECT x AS y
|
73
|
+
FROM t1
|
74
|
+
INNER JOIN (
|
75
|
+
SELECT id,
|
76
|
+
(ts_rank((to_tsvector('simple', coalesce("pg_search_documents"."content"::text, ''))), (to_tsquery('simple', 'xyz' || 'omg' || 'secret')), ?)) AS rank
|
77
|
+
FROM t2
|
78
|
+
WHERE name = 'literal') sub ON sub.id = t1.id WHERE age > 10}
|
79
|
+
|
80
|
+
expected = %q{SELECT x AS y FROM t1 INNER JOIN ( SELECT id, (ts_rank((to_tsvector(?, coalesce("pg_search_documents"."content"::text, ?))), (to_tsquery(?, ? || ? || ?)), ?)) AS rank FROM t2 WHERE name = ?) sub ON sub.id = t1.id WHERE age > ?}
|
81
|
+
ss = SqlSanitizer.new(sql).tap{ |it| it.database_engine = :postgres }
|
82
|
+
|
83
|
+
assert_equal expected, ss.to_s
|
84
|
+
end
|
85
|
+
|
69
86
|
def test_mysql_where
|
70
87
|
sql = %q|SELECT `users`.* FROM `users` WHERE `users`.`name` = ? [["name", "chris"]]|
|
71
88
|
ss = SqlSanitizer.new(sql).tap{ |it| it.database_engine = :mysql }
|
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:
|
4
|
+
version: 5.0.0
|
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: 2021-02
|
12
|
+
date: 2021-11-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
@@ -219,7 +219,6 @@ files:
|
|
219
219
|
- ".github/workflows/test.yml"
|
220
220
|
- ".gitignore"
|
221
221
|
- ".rubocop.yml"
|
222
|
-
- ".travis.yml"
|
223
222
|
- CHANGELOG.markdown
|
224
223
|
- Gemfile
|
225
224
|
- Guardfile
|
@@ -238,6 +237,7 @@ files:
|
|
238
237
|
- gems/rails4.gemfile
|
239
238
|
- gems/rails5.gemfile
|
240
239
|
- gems/rails6.gemfile
|
240
|
+
- gems/typhoeus.gemfile
|
241
241
|
- lib/scout_apm.rb
|
242
242
|
- lib/scout_apm/agent.rb
|
243
243
|
- lib/scout_apm/agent/exit_handler.rb
|
@@ -282,6 +282,8 @@ files:
|
|
282
282
|
- lib/scout_apm/error_service/sidekiq.rb
|
283
283
|
- lib/scout_apm/extensions/config.rb
|
284
284
|
- lib/scout_apm/extensions/transaction_callback_payload.rb
|
285
|
+
- lib/scout_apm/external_service_metric_set.rb
|
286
|
+
- lib/scout_apm/external_service_metric_stats.rb
|
285
287
|
- lib/scout_apm/fake_store.rb
|
286
288
|
- lib/scout_apm/framework_integrations/rails_2.rb
|
287
289
|
- lib/scout_apm/framework_integrations/rails_3_or_4.rb
|
@@ -328,6 +330,7 @@ files:
|
|
328
330
|
- lib/scout_apm/layer_converters/database_converter.rb
|
329
331
|
- lib/scout_apm/layer_converters/depth_first_walker.rb
|
330
332
|
- lib/scout_apm/layer_converters/error_converter.rb
|
333
|
+
- lib/scout_apm/layer_converters/external_service_converter.rb
|
331
334
|
- lib/scout_apm/layer_converters/find_layer_by_type.rb
|
332
335
|
- lib/scout_apm/layer_converters/histograms.rb
|
333
336
|
- lib/scout_apm/layer_converters/job_converter.rb
|
@@ -359,6 +362,7 @@ files:
|
|
359
362
|
- lib/scout_apm/serializers/app_server_load_serializer.rb
|
360
363
|
- lib/scout_apm/serializers/db_query_serializer_to_json.rb
|
361
364
|
- lib/scout_apm/serializers/directive_serializer.rb
|
365
|
+
- lib/scout_apm/serializers/external_service_serializer_to_json.rb
|
362
366
|
- lib/scout_apm/serializers/histograms_serializer_to_json.rb
|
363
367
|
- lib/scout_apm/serializers/jobs_serializer_to_json.rb
|
364
368
|
- lib/scout_apm/serializers/metrics_to_json_serializer.rb
|
@@ -398,8 +402,6 @@ files:
|
|
398
402
|
- lib/scout_apm/utils/numbers.rb
|
399
403
|
- lib/scout_apm/utils/scm.rb
|
400
404
|
- lib/scout_apm/utils/sql_sanitizer.rb
|
401
|
-
- lib/scout_apm/utils/sql_sanitizer_regex.rb
|
402
|
-
- lib/scout_apm/utils/sql_sanitizer_regex_1_8_7.rb
|
403
405
|
- lib/scout_apm/utils/time.rb
|
404
406
|
- lib/scout_apm/utils/unique_id.rb
|
405
407
|
- lib/scout_apm/version.rb
|
@@ -410,11 +412,13 @@ files:
|
|
410
412
|
- test/tmp/README.md
|
411
413
|
- test/unit/agent_context_test.rb
|
412
414
|
- test/unit/agent_test.rb
|
415
|
+
- test/unit/auto_instrument/anonymous_block_value.rb
|
413
416
|
- test/unit/auto_instrument/assignments-instrumented.rb
|
414
417
|
- test/unit/auto_instrument/assignments.rb
|
415
418
|
- test/unit/auto_instrument/controller-ast.txt
|
416
419
|
- test/unit/auto_instrument/controller-instrumented.rb
|
417
420
|
- test/unit/auto_instrument/controller.rb
|
421
|
+
- test/unit/auto_instrument/hanging_method.rb
|
418
422
|
- test/unit/auto_instrument/rescue_from-instrumented.rb
|
419
423
|
- test/unit/auto_instrument/rescue_from.rb
|
420
424
|
- test/unit/auto_instrument_test.rb
|
@@ -428,6 +432,8 @@ files:
|
|
428
432
|
- test/unit/error_service/ignored_exceptions_test.rb
|
429
433
|
- test/unit/extensions/periodic_callbacks_test.rb
|
430
434
|
- test/unit/extensions/transaction_callbacks_test.rb
|
435
|
+
- test/unit/external_service_metric_set_test.rb
|
436
|
+
- test/unit/external_service_metric_stats_test.rb
|
431
437
|
- test/unit/fake_store_test.rb
|
432
438
|
- test/unit/git_revision_test.rb
|
433
439
|
- test/unit/histogram_test.rb
|
@@ -435,6 +441,7 @@ files:
|
|
435
441
|
- test/unit/instruments/active_record_test.rb
|
436
442
|
- test/unit/instruments/net_http_test.rb
|
437
443
|
- test/unit/instruments/percentile_sampler_test.rb
|
444
|
+
- test/unit/instruments/typhoeus_test.rb
|
438
445
|
- test/unit/layaway_test.rb
|
439
446
|
- test/unit/layer_children_set_test.rb
|
440
447
|
- test/unit/layer_converters/depth_first_walker_test.rb
|
@@ -443,9 +450,9 @@ files:
|
|
443
450
|
- test/unit/limited_layer_test.rb
|
444
451
|
- test/unit/logger_test.rb
|
445
452
|
- test/unit/metric_set_test.rb
|
446
|
-
- test/unit/remote/
|
447
|
-
- test/unit/remote/
|
448
|
-
- test/unit/remote/
|
453
|
+
- test/unit/remote/message_test.rb
|
454
|
+
- test/unit/remote/route_test.rb
|
455
|
+
- test/unit/remote/server_test.rb
|
449
456
|
- test/unit/request_histograms_test.rb
|
450
457
|
- test/unit/scored_item_set_test.rb
|
451
458
|
- test/unit/serializers/payload_serializer_test.rb
|
@@ -480,7 +487,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
480
487
|
- !ruby/object:Gem::Version
|
481
488
|
version: '0'
|
482
489
|
requirements: []
|
483
|
-
rubygems_version: 3.
|
490
|
+
rubygems_version: 3.0.3
|
484
491
|
signing_key:
|
485
492
|
specification_version: 4
|
486
493
|
summary: Ruby application performance monitoring
|
data/.travis.yml
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
dist: xenial
|
3
|
-
cache: bundler
|
4
|
-
|
5
|
-
matrix:
|
6
|
-
include:
|
7
|
-
- rvm: 2.1
|
8
|
-
gemfile: gems/rails3.gemfile
|
9
|
-
- rvm: 2.2
|
10
|
-
- rvm: 2.3
|
11
|
-
- rvm: 2.4
|
12
|
-
- rvm: 2.5
|
13
|
-
- rvm: 2.6
|
14
|
-
- rvm: 2.7
|
15
|
-
- rvm: 3.0
|
16
|
-
- rvm: 2.6
|
17
|
-
gemfile: gems/octoshark.gemfile
|
18
|
-
- rvm: 2.6
|
19
|
-
name: rubocop yo
|
20
|
-
script: bundle exec rubocop
|
21
|
-
- rvm: 2.6
|
22
|
-
gemfile: gems/rails3.gemfile
|
@@ -1,32 +0,0 @@
|
|
1
|
-
|
2
|
-
module ScoutApm
|
3
|
-
module Utils
|
4
|
-
module SqlRegex
|
5
|
-
MULTIPLE_SPACES = %r|\s+|.freeze
|
6
|
-
MULTIPLE_QUESTIONS = /\?(,\?)+/.freeze
|
7
|
-
|
8
|
-
PSQL_VAR_INTERPOLATION = %r|\[\[.*\]\]\s*\z|.freeze
|
9
|
-
PSQL_REMOVE_STRINGS = /'(?:[^']|'')*'/.freeze
|
10
|
-
PSQL_REMOVE_INTEGERS = /(?<!LIMIT )\b\d+\b/.freeze
|
11
|
-
PSQL_PLACEHOLDER = /\$\d+/.freeze
|
12
|
-
PSQL_IN_CLAUSE = /IN\s+\(\?[^\)]*\)/.freeze
|
13
|
-
PSQL_AFTER_WHERE = /(?:WHERE\s+).*?(?:SELECT|\z)/im.freeze
|
14
|
-
PSQL_AFTER_SET = /(?:SET\s+).*?(?:WHERE|\z)/im.freeze
|
15
|
-
|
16
|
-
MYSQL_VAR_INTERPOLATION = %r|\[\[.*\]\]\s*$|.freeze
|
17
|
-
MYSQL_REMOVE_INTEGERS = /(?<!LIMIT )\b\d+\b/.freeze
|
18
|
-
MYSQL_REMOVE_SINGLE_QUOTE_STRINGS = %r{'(?:\\'|[^']|'')*'}.freeze
|
19
|
-
MYSQL_REMOVE_DOUBLE_QUOTE_STRINGS = %r{"(?:\\"|[^"]|"")*"}.freeze
|
20
|
-
MYSQL_IN_CLAUSE = /IN\s+\(\?[^\)]*\)/.freeze
|
21
|
-
|
22
|
-
SQLITE_VAR_INTERPOLATION = %r|\[\[.*\]\]\s*$|.freeze
|
23
|
-
SQLITE_REMOVE_STRINGS = /'(?:[^']|'')*'/.freeze
|
24
|
-
SQLITE_REMOVE_INTEGERS = /(?<!LIMIT )\b\d+\b/.freeze
|
25
|
-
|
26
|
-
# => "EXEC sp_executesql N'SELECT [users].* FROM [users] WHERE (age > 50) ORDER BY [users].[id] ASC OFFSET 0 ROWS FETCH NEXT @0 ROWS ONLY', N'@0 int', @0 = 10"
|
27
|
-
SQLSERVER_EXECUTESQL = /EXEC sp_executesql N'(.*?)'.*/
|
28
|
-
SQLSERVER_REMOVE_INTEGERS = /(?<!LIMIT )\b(?<!@)\d+\b/.freeze
|
29
|
-
SQLSERVER_IN_CLAUSE = /IN\s+\(\?[^\)]*\)/.freeze
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
|
2
|
-
module ScoutApm
|
3
|
-
module Utils
|
4
|
-
module SqlRegex
|
5
|
-
MULTIPLE_SPACES = %r|\s+|.freeze
|
6
|
-
MULTIPLE_QUESTIONS = /\?(,\?)+/.freeze
|
7
|
-
|
8
|
-
PSQL_VAR_INTERPOLATION = %r|\[\[.*\]\]\s*$|.freeze
|
9
|
-
PSQL_REMOVE_STRINGS = /'(?:[^']|'')*'/.freeze
|
10
|
-
PSQL_REMOVE_INTEGERS = /\b\d+\b/.freeze
|
11
|
-
PSQL_PLACEHOLDER = /\$\d+/.freeze
|
12
|
-
PSQL_IN_CLAUSE = /IN\s+\(\?[^\)]*\)/.freeze
|
13
|
-
PSQL_AFTER_WHERE = /(?:WHERE\s+).*?(?:SELECT|$)/i.freeze
|
14
|
-
PSQL_AFTER_SET = /(?:SET\s+).*?(?:WHERE|$)/i.freeze
|
15
|
-
|
16
|
-
MYSQL_VAR_INTERPOLATION = %r|\[\[.*\]\]\s*$|.freeze
|
17
|
-
MYSQL_REMOVE_INTEGERS = /\b\d+\b/.freeze
|
18
|
-
MYSQL_REMOVE_SINGLE_QUOTE_STRINGS = /'(?:\\'|[^']|'')*'/.freeze
|
19
|
-
MYSQL_REMOVE_DOUBLE_QUOTE_STRINGS = /"(?:\\"|[^"]|"")*"/.freeze
|
20
|
-
MYSQL_IN_CLAUSE = /IN\s+\(\?[^\)]*\)/.freeze
|
21
|
-
|
22
|
-
SQLITE_VAR_INTERPOLATION = %r|\[\[.*\]\]\s*$|.freeze
|
23
|
-
SQLITE_REMOVE_STRINGS = /'(?:[^']|'')*'/.freeze
|
24
|
-
SQLITE_REMOVE_INTEGERS = /\b\d+\b/.freeze
|
25
|
-
|
26
|
-
# This is not officially supported, but will do its best.
|
27
|
-
SQLSERVER_EXECUTESQL = /EXEC sp_executesql N'(.*?)'.*/
|
28
|
-
SQLSERVER_REMOVE_INTEGERS = /\b\d+\b/.freeze
|
29
|
-
SQLSERVER_IN_CLAUSE = /IN\s+\(\?[^\)]*\)/.freeze
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|