scout_apm 2.6.10 → 3.0.0.pre0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -2
- data/.rubocop.yml +3 -11
- data/CHANGELOG.markdown +4 -362
- data/Gemfile +1 -14
- data/README.markdown +7 -52
- data/Rakefile +1 -0
- data/ext/allocations/allocations.c +1 -7
- data/ext/allocations/extconf.rb +0 -1
- data/ext/rusage/rusage.c +0 -26
- data/ext/stacks/extconf.rb +37 -0
- data/ext/stacks/scout_atomics.h +86 -0
- data/ext/stacks/stacks.c +811 -0
- data/lib/scout_apm/agent/logging.rb +69 -0
- data/lib/scout_apm/agent/reporting.rb +126 -0
- data/lib/scout_apm/agent.rb +259 -138
- data/lib/scout_apm/app_server_load.rb +15 -41
- data/lib/scout_apm/attribute_arranger.rb +3 -14
- data/lib/scout_apm/background_job_integrations/delayed_job.rb +1 -70
- data/lib/scout_apm/background_job_integrations/sidekiq.rb +24 -31
- data/lib/scout_apm/background_worker.rb +12 -23
- data/lib/scout_apm/capacity.rb +57 -0
- data/lib/scout_apm/config.rb +37 -206
- data/lib/scout_apm/context.rb +4 -20
- data/lib/scout_apm/deploy_integrations/capistrano_2.cap +12 -0
- data/lib/scout_apm/deploy_integrations/capistrano_2.rb +83 -0
- data/lib/scout_apm/deploy_integrations/capistrano_3.cap +12 -0
- data/lib/scout_apm/deploy_integrations/capistrano_3.rb +88 -0
- data/lib/scout_apm/environment.rb +28 -42
- data/lib/scout_apm/fake_store.rb +0 -12
- data/lib/scout_apm/framework_integrations/rails_2.rb +1 -2
- data/lib/scout_apm/framework_integrations/rails_3_or_4.rb +6 -17
- data/lib/scout_apm/framework_integrations/sinatra.rb +1 -1
- data/lib/scout_apm/histogram.rb +3 -12
- data/lib/scout_apm/instant/assets/xmlhttp_instrumentation.html +2 -2
- data/lib/scout_apm/instant/middleware.rb +54 -202
- data/lib/scout_apm/instant_reporting.rb +7 -7
- data/lib/scout_apm/instruments/.DS_Store +0 -0
- data/lib/scout_apm/instruments/action_controller_rails_2.rb +9 -15
- data/lib/scout_apm/instruments/action_controller_rails_3_rails4.rb +76 -124
- data/lib/scout_apm/instruments/active_record.rb +29 -324
- data/lib/scout_apm/instruments/delayed_job.rb +57 -0
- data/lib/scout_apm/instruments/elasticsearch.rb +6 -10
- data/lib/scout_apm/instruments/grape.rb +9 -12
- data/lib/scout_apm/instruments/http_client.rb +7 -14
- data/lib/scout_apm/instruments/influxdb.rb +6 -10
- data/lib/scout_apm/instruments/middleware_detailed.rb +11 -15
- data/lib/scout_apm/instruments/middleware_summary.rb +5 -11
- data/lib/scout_apm/instruments/mongoid.rb +8 -39
- data/lib/scout_apm/instruments/moped.rb +6 -11
- data/lib/scout_apm/instruments/net_http.rb +9 -27
- data/lib/scout_apm/instruments/percentile_sampler.rb +23 -42
- data/lib/scout_apm/instruments/process/process_cpu.rb +6 -11
- data/lib/scout_apm/instruments/process/process_memory.rb +12 -17
- data/lib/scout_apm/instruments/rails_router.rb +6 -12
- data/lib/scout_apm/instruments/redis.rb +6 -10
- data/lib/scout_apm/instruments/sinatra.rb +4 -5
- data/lib/scout_apm/job_record.rb +2 -4
- data/lib/scout_apm/layaway.rb +34 -88
- data/lib/scout_apm/layaway_file.rb +3 -13
- data/lib/scout_apm/layer.rb +60 -25
- data/lib/scout_apm/layer_converters/allocation_metric_converter.rb +6 -7
- data/lib/scout_apm/layer_converters/converter_base.rb +14 -203
- data/lib/scout_apm/layer_converters/depth_first_walker.rb +10 -22
- data/lib/scout_apm/layer_converters/error_converter.rb +8 -8
- data/lib/scout_apm/layer_converters/job_converter.rb +50 -37
- data/lib/scout_apm/layer_converters/metric_converter.rb +19 -18
- data/lib/scout_apm/layer_converters/request_queue_time_converter.rb +13 -13
- data/lib/scout_apm/layer_converters/slow_job_converter.rb +116 -52
- data/lib/scout_apm/layer_converters/slow_request_converter.rb +120 -51
- data/lib/scout_apm/metric_meta.rb +5 -0
- data/lib/scout_apm/metric_set.rb +1 -9
- data/lib/scout_apm/metric_stats.rb +8 -7
- data/lib/scout_apm/middleware.rb +9 -7
- data/lib/scout_apm/reporter.rb +24 -71
- data/lib/scout_apm/request_histograms.rb +0 -12
- data/lib/scout_apm/request_manager.rb +7 -5
- data/lib/scout_apm/scored_item_set.rb +0 -7
- data/lib/scout_apm/serializers/app_server_load_serializer.rb +0 -4
- data/lib/scout_apm/serializers/deploy_serializer.rb +16 -0
- data/lib/scout_apm/serializers/directive_serializer.rb +0 -4
- data/lib/scout_apm/serializers/payload_serializer.rb +4 -11
- data/lib/scout_apm/serializers/payload_serializer_to_json.rb +16 -35
- data/lib/scout_apm/serializers/slow_jobs_serializer_to_json.rb +1 -2
- data/lib/scout_apm/server_integrations/passenger.rb +1 -1
- data/lib/scout_apm/server_integrations/puma.rb +2 -5
- data/lib/scout_apm/slow_job_policy.rb +13 -25
- data/lib/scout_apm/slow_job_record.rb +4 -13
- data/lib/scout_apm/slow_request_policy.rb +13 -25
- data/lib/scout_apm/slow_transaction.rb +5 -25
- data/lib/scout_apm/store.rb +32 -99
- data/lib/scout_apm/trace_compactor.rb +312 -0
- data/lib/scout_apm/tracer.rb +31 -35
- data/lib/scout_apm/tracked_request.rb +95 -262
- data/lib/scout_apm/utils/active_record_metric_name.rb +13 -88
- data/lib/scout_apm/utils/backtrace_parser.rb +4 -7
- data/lib/scout_apm/utils/fake_stacks.rb +87 -0
- data/lib/scout_apm/utils/installed_gems.rb +3 -7
- data/lib/scout_apm/utils/klass_helper.rb +2 -8
- data/lib/scout_apm/utils/null_logger.rb +13 -0
- data/lib/scout_apm/utils/sql_sanitizer.rb +5 -16
- data/lib/scout_apm/utils/sql_sanitizer_regex.rb +0 -7
- data/lib/scout_apm/utils/sql_sanitizer_regex_1_8_7.rb +0 -6
- data/lib/scout_apm/utils/unique_id.rb +0 -27
- data/lib/scout_apm/version.rb +2 -1
- data/lib/scout_apm.rb +25 -84
- data/scout_apm.gemspec +3 -17
- data/test/test_helper.rb +3 -57
- data/test/unit/agent_test.rb +54 -1
- data/test/unit/background_job_integrations/sidekiq_test.rb +3 -0
- data/test/unit/config_test.rb +12 -25
- data/test/unit/context_test.rb +4 -4
- data/test/unit/histogram_test.rb +4 -25
- data/test/unit/ignored_uris_test.rb +1 -1
- data/test/unit/instruments/active_record_instruments_test.rb +5 -0
- data/test/unit/layaway_test.rb +2 -62
- data/test/unit/serializers/payload_serializer_test.rb +15 -43
- data/test/unit/slow_request_policy_test.rb +6 -15
- data/test/unit/sql_sanitizer_test.rb +6 -53
- data/test/unit/store_test.rb +4 -73
- data/test/unit/utils/active_record_metric_name_test.rb +5 -59
- data/test/unit/utils/backtrace_parser_test.rb +1 -6
- data/tester.rb +53 -0
- metadata +28 -229
- data/.travis.yml +0 -26
- data/Guardfile +0 -43
- data/gems/README.md +0 -28
- data/gems/octoshark.gemfile +0 -4
- data/gems/rails3.gemfile +0 -5
- data/gems/rails4.gemfile +0 -4
- data/gems/rails5.gemfile +0 -4
- data/gems/rails6.gemfile +0 -4
- data/lib/scout_apm/agent/exit_handler.rb +0 -65
- data/lib/scout_apm/agent/preconditions.rb +0 -81
- data/lib/scout_apm/agent_context.rb +0 -261
- data/lib/scout_apm/auto_instrument/instruction_sequence.rb +0 -31
- data/lib/scout_apm/auto_instrument/layer.rb +0 -23
- data/lib/scout_apm/auto_instrument/parser.rb +0 -27
- data/lib/scout_apm/auto_instrument/rails.rb +0 -175
- data/lib/scout_apm/auto_instrument.rb +0 -5
- data/lib/scout_apm/background_job_integrations/legacy_sneakers.rb +0 -55
- data/lib/scout_apm/background_job_integrations/que.rb +0 -134
- data/lib/scout_apm/background_job_integrations/resque.rb +0 -88
- data/lib/scout_apm/background_job_integrations/shoryuken.rb +0 -124
- data/lib/scout_apm/background_job_integrations/sneakers.rb +0 -87
- data/lib/scout_apm/background_recorder.rb +0 -48
- data/lib/scout_apm/db_query_metric_set.rb +0 -97
- data/lib/scout_apm/db_query_metric_stats.rb +0 -102
- data/lib/scout_apm/debug.rb +0 -37
- data/lib/scout_apm/detailed_trace.rb +0 -217
- data/lib/scout_apm/error.rb +0 -27
- data/lib/scout_apm/error_service/error_buffer.rb +0 -39
- data/lib/scout_apm/error_service/error_record.rb +0 -211
- data/lib/scout_apm/error_service/ignored_exceptions.rb +0 -66
- data/lib/scout_apm/error_service/middleware.rb +0 -32
- data/lib/scout_apm/error_service/notifier.rb +0 -33
- data/lib/scout_apm/error_service/payload.rb +0 -47
- data/lib/scout_apm/error_service/periodic_work.rb +0 -17
- data/lib/scout_apm/error_service/railtie.rb +0 -11
- data/lib/scout_apm/error_service/sidekiq.rb +0 -80
- data/lib/scout_apm/error_service.rb +0 -32
- data/lib/scout_apm/extensions/config.rb +0 -87
- data/lib/scout_apm/extensions/transaction_callback_payload.rb +0 -74
- data/lib/scout_apm/git_revision.rb +0 -59
- data/lib/scout_apm/instrument_manager.rb +0 -88
- data/lib/scout_apm/instruments/action_view.rb +0 -141
- data/lib/scout_apm/instruments/http.rb +0 -48
- data/lib/scout_apm/instruments/memcached.rb +0 -43
- data/lib/scout_apm/instruments/resque.rb +0 -39
- data/lib/scout_apm/instruments/samplers.rb +0 -11
- data/lib/scout_apm/layer_children_set.rb +0 -86
- data/lib/scout_apm/layer_converters/database_converter.rb +0 -70
- data/lib/scout_apm/layer_converters/find_layer_by_type.rb +0 -38
- data/lib/scout_apm/layer_converters/histograms.rb +0 -15
- data/lib/scout_apm/layer_converters/trace_converter.rb +0 -184
- data/lib/scout_apm/limited_layer.rb +0 -126
- data/lib/scout_apm/logger.rb +0 -158
- data/lib/scout_apm/periodic_work.rb +0 -47
- data/lib/scout_apm/rack.rb +0 -26
- data/lib/scout_apm/remote/message.rb +0 -27
- data/lib/scout_apm/remote/recorder.rb +0 -57
- data/lib/scout_apm/remote/router.rb +0 -49
- data/lib/scout_apm/remote/server.rb +0 -60
- data/lib/scout_apm/reporting.rb +0 -143
- data/lib/scout_apm/serializers/db_query_serializer_to_json.rb +0 -15
- data/lib/scout_apm/serializers/histograms_serializer_to_json.rb +0 -21
- data/lib/scout_apm/synchronous_recorder.rb +0 -30
- data/lib/scout_apm/tasks/doctor.rb +0 -75
- data/lib/scout_apm/tasks/support.rb +0 -22
- data/lib/scout_apm/transaction.rb +0 -13
- data/lib/scout_apm/transaction_time_consumed.rb +0 -51
- data/lib/scout_apm/utils/gzip_helper.rb +0 -24
- data/lib/scout_apm/utils/marshal_logging.rb +0 -90
- data/lib/scout_apm/utils/numbers.rb +0 -14
- data/lib/scout_apm/utils/scm.rb +0 -14
- data/lib/tasks/doctor.rake +0 -11
- data/test/tmp/README.md +0 -17
- data/test/unit/agent_context_test.rb +0 -15
- data/test/unit/auto_instrument/assignments-instrumented.rb +0 -31
- data/test/unit/auto_instrument/assignments.rb +0 -31
- data/test/unit/auto_instrument/controller-ast.txt +0 -57
- data/test/unit/auto_instrument/controller-instrumented.rb +0 -49
- data/test/unit/auto_instrument/controller.rb +0 -49
- data/test/unit/auto_instrument/rescue_from-instrumented.rb +0 -13
- data/test/unit/auto_instrument/rescue_from.rb +0 -13
- data/test/unit/auto_instrument_test.rb +0 -54
- data/test/unit/db_query_metric_set_test.rb +0 -67
- data/test/unit/db_query_metric_stats_test.rb +0 -113
- data/test/unit/error_service/error_buffer_test.rb +0 -25
- data/test/unit/error_service/ignored_exceptions_test.rb +0 -49
- data/test/unit/extensions/periodic_callbacks_test.rb +0 -58
- data/test/unit/extensions/transaction_callbacks_test.rb +0 -58
- data/test/unit/fake_store_test.rb +0 -10
- data/test/unit/git_revision_test.rb +0 -15
- data/test/unit/instruments/active_record_test.rb +0 -40
- data/test/unit/instruments/net_http_test.rb +0 -27
- data/test/unit/instruments/percentile_sampler_test.rb +0 -133
- data/test/unit/layer_children_set_test.rb +0 -97
- data/test/unit/layer_converters/depth_first_walker_test.rb +0 -70
- data/test/unit/layer_converters/metric_converter_test.rb +0 -22
- data/test/unit/layer_converters/stubs.rb +0 -33
- data/test/unit/limited_layer_test.rb +0 -53
- data/test/unit/logger_test.rb +0 -69
- data/test/unit/remote/test_message.rb +0 -13
- data/test/unit/remote/test_router.rb +0 -33
- data/test/unit/remote/test_server.rb +0 -15
- data/test/unit/request_histograms_test.rb +0 -17
- data/test/unit/tracer_test.rb +0 -76
- data/test/unit/tracked_request_test.rb +0 -71
- data/test/unit/transaction_test.rb +0 -14
- data/test/unit/transaction_time_consumed_test.rb +0 -46
- data/test/unit/utils/numbers_test.rb +0 -15
- data/test/unit/utils/scm.rb +0 -17
@@ -0,0 +1,87 @@
|
|
1
|
+
# A fake implementation of the allocations native extension, for systems that don't support it.
|
2
|
+
module ScoutApm
|
3
|
+
module Instruments
|
4
|
+
class Stacks
|
5
|
+
ENABLED = false
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def install(*args)
|
9
|
+
# noop
|
10
|
+
end
|
11
|
+
|
12
|
+
def uninstall(*args)
|
13
|
+
# noop
|
14
|
+
end
|
15
|
+
|
16
|
+
def start(*args)
|
17
|
+
# noop
|
18
|
+
end
|
19
|
+
|
20
|
+
def add_profiled_thread(*args)
|
21
|
+
# noop
|
22
|
+
end
|
23
|
+
|
24
|
+
def remove_profiled_thread(*args)
|
25
|
+
# noop
|
26
|
+
end
|
27
|
+
|
28
|
+
def profile_frames(*args)
|
29
|
+
[] # frames that were profiled (none)
|
30
|
+
end
|
31
|
+
|
32
|
+
def start_sampling(*args)
|
33
|
+
# noop
|
34
|
+
end
|
35
|
+
|
36
|
+
def stop_sampling(*args)
|
37
|
+
# noop
|
38
|
+
end
|
39
|
+
|
40
|
+
def update_indexes(*args)
|
41
|
+
# noop
|
42
|
+
true
|
43
|
+
end
|
44
|
+
|
45
|
+
def current_trace_index(*args)
|
46
|
+
:opaque_value
|
47
|
+
end
|
48
|
+
|
49
|
+
def current_frame_index(*args)
|
50
|
+
:opaque_value
|
51
|
+
end
|
52
|
+
|
53
|
+
def frame_klass(*args)
|
54
|
+
nil
|
55
|
+
end
|
56
|
+
|
57
|
+
def frame_method(*args)
|
58
|
+
nil
|
59
|
+
end
|
60
|
+
|
61
|
+
def frame_file(*args)
|
62
|
+
nil
|
63
|
+
end
|
64
|
+
|
65
|
+
def frame_lineno(*args)
|
66
|
+
nil
|
67
|
+
end
|
68
|
+
|
69
|
+
def skipped_in_gc(*args)
|
70
|
+
0
|
71
|
+
end
|
72
|
+
|
73
|
+
def skipped_in_handler(*args)
|
74
|
+
0
|
75
|
+
end
|
76
|
+
|
77
|
+
def skipped_in_job_registered(*args)
|
78
|
+
0
|
79
|
+
end
|
80
|
+
|
81
|
+
def skipped_in_not_running(*args)
|
82
|
+
0
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -1,14 +1,10 @@
|
|
1
1
|
module ScoutApm
|
2
2
|
module Utils
|
3
3
|
class InstalledGems
|
4
|
-
attr_reader :
|
4
|
+
attr_reader :logger
|
5
5
|
|
6
|
-
def initialize(
|
7
|
-
@
|
8
|
-
end
|
9
|
-
|
10
|
-
def logger
|
11
|
-
context.logger
|
6
|
+
def initialize(logger=ScoutApm::Agent.instance.logger)
|
7
|
+
@logger = logger
|
12
8
|
end
|
13
9
|
|
14
10
|
def run
|
@@ -5,12 +5,6 @@ module ScoutApm
|
|
5
5
|
# KlassHelper.defined?("ActiveRecord::Base") #=> true / false
|
6
6
|
|
7
7
|
def self.defined?(*names)
|
8
|
-
lookup(*names) != :missing_class
|
9
|
-
end
|
10
|
-
|
11
|
-
# KlassHelper.lookup("ActiveRecord::Base") => ActiveRecord::Base
|
12
|
-
# KlassHelper.lookup("ActiveRecord::SomethingThatDoesNotExist") => :missing_class
|
13
|
-
def self.lookup(*names)
|
14
8
|
if names.length == 1
|
15
9
|
names = names[0].split("::")
|
16
10
|
end
|
@@ -21,11 +15,11 @@ module ScoutApm
|
|
21
15
|
begin
|
22
16
|
obj = obj.const_get(name)
|
23
17
|
rescue NameError
|
24
|
-
return
|
18
|
+
return false
|
25
19
|
end
|
26
20
|
end
|
27
21
|
|
28
|
-
|
22
|
+
true
|
29
23
|
end
|
30
24
|
end
|
31
25
|
end
|
@@ -16,7 +16,7 @@ module ScoutApm
|
|
16
16
|
|
17
17
|
def initialize(sql)
|
18
18
|
@raw_sql = sql
|
19
|
-
@database_engine = ScoutApm::
|
19
|
+
@database_engine = ScoutApm::Environment.instance.database_engine
|
20
20
|
@sanitized = false # only sanitize once.
|
21
21
|
end
|
22
22
|
|
@@ -34,24 +34,15 @@ module ScoutApm
|
|
34
34
|
when :postgres then to_s_postgres
|
35
35
|
when :mysql then to_s_mysql
|
36
36
|
when :sqlite then to_s_sqlite
|
37
|
-
when :sqlserver then to_s_sqlserver
|
38
37
|
end
|
39
38
|
end
|
40
39
|
|
41
40
|
private
|
42
41
|
|
43
|
-
def to_s_sqlserver
|
44
|
-
sql.gsub!(SQLSERVER_EXECUTESQL, '\1')
|
45
|
-
sql.gsub!(SQLSERVER_REMOVE_INTEGERS, '?')
|
46
|
-
sql.gsub!(SQLSERVER_IN_CLAUSE, 'IN (?)')
|
47
|
-
sql
|
48
|
-
end
|
49
|
-
|
50
42
|
def to_s_postgres
|
51
43
|
sql.gsub!(PSQL_PLACEHOLDER, '?')
|
52
44
|
sql.gsub!(PSQL_VAR_INTERPOLATION, '')
|
53
|
-
sql.gsub!(
|
54
|
-
sql.gsub!(PSQL_AFTER_SET) {|c| c.gsub(PSQL_REMOVE_STRINGS, '?')}
|
45
|
+
sql.gsub!(PSQL_REMOVE_STRINGS, '?')
|
55
46
|
sql.gsub!(PSQL_REMOVE_INTEGERS, '?')
|
56
47
|
sql.gsub!(PSQL_IN_CLAUSE, 'IN (?)')
|
57
48
|
sql.gsub!(MULTIPLE_SPACES, ' ')
|
@@ -83,19 +74,17 @@ module ScoutApm
|
|
83
74
|
encodings.all?{|enc| Encoding.find(enc) rescue false}
|
84
75
|
end
|
85
76
|
|
86
|
-
MAX_SQL_LENGTH = 16384
|
87
|
-
|
88
77
|
def scrubbed(str)
|
89
|
-
return '' if !str.is_a?(String) || str.length >
|
78
|
+
return '' if !str.is_a?(String) || str.length > 4000 # safeguard - don't sanitize or scrub large SQL statements
|
90
79
|
return str if !str.respond_to?(:encode) # Ruby <= 1.8 doesn't have string encoding
|
91
80
|
return str if str.valid_encoding? # Whatever encoding it is, it is valid and we can operate on it
|
92
|
-
ScoutApm::Agent.instance.
|
81
|
+
ScoutApm::Agent.instance.logger.debug "Scrubbing invalid sql encoding."
|
93
82
|
if str.respond_to?(:scrub) # Prefer to scrub before we have to convert
|
94
83
|
return str.scrub('_')
|
95
84
|
elsif has_encodings?(['UTF-8', 'binary'])
|
96
85
|
return str.encode('UTF-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '_')
|
97
86
|
end
|
98
|
-
ScoutApm::Agent.instance.
|
87
|
+
ScoutApm::Agent.instance.logger.debug "Unable to scrub invalid sql encoding."
|
99
88
|
''
|
100
89
|
end
|
101
90
|
|
@@ -10,8 +10,6 @@ module ScoutApm
|
|
10
10
|
PSQL_REMOVE_INTEGERS = /(?<!LIMIT )\b\d+\b/.freeze
|
11
11
|
PSQL_PLACEHOLDER = /\$\d+/.freeze
|
12
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
13
|
|
16
14
|
MYSQL_VAR_INTERPOLATION = %r|\[\[.*\]\]\s*$|.freeze
|
17
15
|
MYSQL_REMOVE_INTEGERS = /(?<!LIMIT )\b\d+\b/.freeze
|
@@ -22,11 +20,6 @@ module ScoutApm
|
|
22
20
|
SQLITE_VAR_INTERPOLATION = %r|\[\[.*\]\]\s*$|.freeze
|
23
21
|
SQLITE_REMOVE_STRINGS = /'(?:[^']|'')*'/.freeze
|
24
22
|
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
23
|
end
|
31
24
|
end
|
32
25
|
end
|
@@ -10,8 +10,6 @@ module ScoutApm
|
|
10
10
|
PSQL_REMOVE_INTEGERS = /\b\d+\b/.freeze
|
11
11
|
PSQL_PLACEHOLDER = /\$\d+/.freeze
|
12
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
13
|
|
16
14
|
MYSQL_VAR_INTERPOLATION = %r|\[\[.*\]\]\s*$|.freeze
|
17
15
|
MYSQL_REMOVE_INTEGERS = /\b\d+\b/.freeze
|
@@ -23,10 +21,6 @@ module ScoutApm
|
|
23
21
|
SQLITE_REMOVE_STRINGS = /'(?:[^']|'')*'/.freeze
|
24
22
|
SQLITE_REMOVE_INTEGERS = /\b\d+\b/.freeze
|
25
23
|
|
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
24
|
end
|
31
25
|
end
|
32
26
|
end
|
@@ -11,32 +11,5 @@ module ScoutApm
|
|
11
11
|
s
|
12
12
|
end
|
13
13
|
end
|
14
|
-
|
15
|
-
# Represents a random ID that we can use to track a certain transaction.
|
16
|
-
# The `trans` prefix is only for ease of reading logs - it should not be
|
17
|
-
# interpreted to convey any sort of meaning.
|
18
|
-
class TransactionId
|
19
|
-
def initialize
|
20
|
-
@random = SecureRandom.hex(16)
|
21
|
-
end
|
22
|
-
|
23
|
-
def to_s
|
24
|
-
"trans-#{@random}"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
# Represents a random ID that we can use to track a certain span. The
|
29
|
-
# `span` prefix is only for ease of reading logs - it should not be
|
30
|
-
# interpreted to convey any sort of meaning.
|
31
|
-
class SpanId
|
32
|
-
def initialize
|
33
|
-
@random = SecureRandom.hex(16)
|
34
|
-
end
|
35
|
-
|
36
|
-
def to_s
|
37
|
-
"span-#{@random}"
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
14
|
end
|
42
15
|
end
|
data/lib/scout_apm/version.rb
CHANGED
data/lib/scout_apm.rb
CHANGED
@@ -6,7 +6,6 @@ end
|
|
6
6
|
#####################################
|
7
7
|
require 'cgi'
|
8
8
|
require 'logger'
|
9
|
-
require 'monitor'
|
10
9
|
require 'net/http'
|
11
10
|
require 'openssl'
|
12
11
|
require 'pp'
|
@@ -15,7 +14,7 @@ require 'socket'
|
|
15
14
|
require 'thread'
|
16
15
|
require 'time'
|
17
16
|
require 'yaml'
|
18
|
-
require '
|
17
|
+
require 'rbconfig'
|
19
18
|
|
20
19
|
#####################################
|
21
20
|
# Gem Requires
|
@@ -27,11 +26,8 @@ require 'rusage'
|
|
27
26
|
#####################################
|
28
27
|
require 'scout_apm/version'
|
29
28
|
|
30
|
-
require 'scout_apm/debug'
|
31
29
|
require 'scout_apm/tracked_request'
|
32
30
|
require 'scout_apm/layer'
|
33
|
-
require 'scout_apm/limited_layer'
|
34
|
-
require 'scout_apm/layer_children_set'
|
35
31
|
require 'scout_apm/request_manager'
|
36
32
|
require 'scout_apm/call_set'
|
37
33
|
|
@@ -41,13 +37,9 @@ require 'scout_apm/layer_converters/error_converter'
|
|
41
37
|
require 'scout_apm/layer_converters/job_converter'
|
42
38
|
require 'scout_apm/layer_converters/slow_job_converter'
|
43
39
|
require 'scout_apm/layer_converters/metric_converter'
|
44
|
-
require 'scout_apm/layer_converters/database_converter'
|
45
40
|
require 'scout_apm/layer_converters/slow_request_converter'
|
46
41
|
require 'scout_apm/layer_converters/request_queue_time_converter'
|
47
42
|
require 'scout_apm/layer_converters/allocation_metric_converter'
|
48
|
-
require 'scout_apm/layer_converters/trace_converter'
|
49
|
-
require 'scout_apm/layer_converters/histograms'
|
50
|
-
require 'scout_apm/layer_converters/find_layer_by_type'
|
51
43
|
|
52
44
|
require 'scout_apm/server_integrations/passenger'
|
53
45
|
require 'scout_apm/server_integrations/puma'
|
@@ -59,11 +51,6 @@ require 'scout_apm/server_integrations/null'
|
|
59
51
|
|
60
52
|
require 'scout_apm/background_job_integrations/sidekiq'
|
61
53
|
require 'scout_apm/background_job_integrations/delayed_job'
|
62
|
-
require 'scout_apm/background_job_integrations/resque'
|
63
|
-
require 'scout_apm/background_job_integrations/shoryuken'
|
64
|
-
require 'scout_apm/background_job_integrations/sneakers'
|
65
|
-
require 'scout_apm/background_job_integrations/que'
|
66
|
-
require 'scout_apm/background_job_integrations/legacy_sneakers'
|
67
54
|
|
68
55
|
require 'scout_apm/framework_integrations/rails_2'
|
69
56
|
require 'scout_apm/framework_integrations/rails_3_or_4'
|
@@ -76,29 +63,35 @@ require 'scout_apm/platform_integrations/server'
|
|
76
63
|
|
77
64
|
require 'scout_apm/histogram'
|
78
65
|
|
66
|
+
require 'scout_apm/deploy_integrations/capistrano_3'
|
67
|
+
# require 'scout_apm/deploy_integrations/capistrano_2'
|
68
|
+
|
79
69
|
require 'scout_apm/instruments/net_http'
|
80
70
|
require 'scout_apm/instruments/http_client'
|
81
71
|
require 'scout_apm/instruments/moped'
|
82
72
|
require 'scout_apm/instruments/mongoid'
|
83
|
-
require 'scout_apm/instruments/memcached'
|
84
73
|
require 'scout_apm/instruments/redis'
|
85
74
|
require 'scout_apm/instruments/influxdb'
|
86
75
|
require 'scout_apm/instruments/elasticsearch'
|
76
|
+
require 'scout_apm/instruments/delayed_job'
|
87
77
|
require 'scout_apm/instruments/active_record'
|
88
78
|
require 'scout_apm/instruments/action_controller_rails_2'
|
89
79
|
require 'scout_apm/instruments/action_controller_rails_3_rails4'
|
90
|
-
require 'scout_apm/instruments/action_view'
|
91
80
|
require 'scout_apm/instruments/middleware_summary'
|
92
|
-
require 'scout_apm/instruments/middleware_detailed' #
|
81
|
+
# require 'scout_apm/instruments/middleware_detailed' # Currently disabled functionality, see the file for details.
|
93
82
|
require 'scout_apm/instruments/rails_router'
|
94
83
|
require 'scout_apm/instruments/grape'
|
95
84
|
require 'scout_apm/instruments/sinatra'
|
96
|
-
require 'allocations'
|
97
|
-
|
98
85
|
require 'scout_apm/instruments/process/process_cpu'
|
99
86
|
require 'scout_apm/instruments/process/process_memory'
|
100
87
|
require 'scout_apm/instruments/percentile_sampler'
|
101
|
-
require '
|
88
|
+
require 'allocations'
|
89
|
+
|
90
|
+
begin
|
91
|
+
require 'stacks'
|
92
|
+
rescue LoadError
|
93
|
+
require 'scout_apm/utils/fake_stacks'
|
94
|
+
end
|
102
95
|
|
103
96
|
require 'scout_apm/app_server_load'
|
104
97
|
|
@@ -107,19 +100,16 @@ require 'scout_apm/utils/active_record_metric_name'
|
|
107
100
|
require 'scout_apm/utils/backtrace_parser'
|
108
101
|
require 'scout_apm/utils/installed_gems'
|
109
102
|
require 'scout_apm/utils/klass_helper'
|
110
|
-
require 'scout_apm/utils/
|
103
|
+
require 'scout_apm/utils/null_logger'
|
111
104
|
require 'scout_apm/utils/sql_sanitizer'
|
112
105
|
require 'scout_apm/utils/time'
|
113
106
|
require 'scout_apm/utils/unique_id'
|
114
|
-
require 'scout_apm/utils/numbers'
|
115
|
-
require 'scout_apm/utils/gzip_helper'
|
116
|
-
require 'scout_apm/utils/marshal_logging'
|
117
107
|
|
118
108
|
require 'scout_apm/config'
|
119
109
|
require 'scout_apm/environment'
|
120
110
|
require 'scout_apm/agent'
|
121
|
-
require 'scout_apm/
|
122
|
-
require 'scout_apm/reporting'
|
111
|
+
require 'scout_apm/agent/logging'
|
112
|
+
require 'scout_apm/agent/reporting'
|
123
113
|
require 'scout_apm/layaway'
|
124
114
|
require 'scout_apm/layaway_file'
|
125
115
|
require 'scout_apm/reporter'
|
@@ -127,75 +117,39 @@ require 'scout_apm/background_worker'
|
|
127
117
|
require 'scout_apm/bucket_name_splitter'
|
128
118
|
require 'scout_apm/stack_item'
|
129
119
|
require 'scout_apm/metric_set'
|
130
|
-
require 'scout_apm/db_query_metric_set'
|
131
120
|
require 'scout_apm/store'
|
132
121
|
require 'scout_apm/fake_store'
|
133
122
|
require 'scout_apm/tracer'
|
134
|
-
require 'scout_apm/transaction'
|
135
123
|
require 'scout_apm/context'
|
136
124
|
require 'scout_apm/instant_reporting'
|
137
|
-
require 'scout_apm/
|
138
|
-
require 'scout_apm/synchronous_recorder'
|
125
|
+
require 'scout_apm/trace_compactor'
|
139
126
|
|
140
127
|
require 'scout_apm/metric_meta'
|
141
128
|
require 'scout_apm/metric_stats'
|
142
|
-
require 'scout_apm/db_query_metric_stats'
|
143
129
|
require 'scout_apm/slow_transaction'
|
144
130
|
require 'scout_apm/slow_job_record'
|
145
|
-
require 'scout_apm/detailed_trace'
|
146
131
|
require 'scout_apm/scored_item_set'
|
147
132
|
require 'scout_apm/slow_request_policy'
|
148
133
|
require 'scout_apm/slow_job_policy'
|
149
134
|
require 'scout_apm/job_record'
|
150
135
|
require 'scout_apm/request_histograms'
|
151
|
-
require 'scout_apm/transaction_time_consumed'
|
152
136
|
|
137
|
+
require 'scout_apm/capacity'
|
153
138
|
require 'scout_apm/attribute_arranger'
|
154
|
-
require 'scout_apm/git_revision'
|
155
139
|
|
156
140
|
require 'scout_apm/serializers/payload_serializer'
|
157
141
|
require 'scout_apm/serializers/payload_serializer_to_json'
|
158
142
|
require 'scout_apm/serializers/jobs_serializer_to_json'
|
159
143
|
require 'scout_apm/serializers/slow_jobs_serializer_to_json'
|
160
144
|
require 'scout_apm/serializers/metrics_to_json_serializer'
|
161
|
-
require 'scout_apm/serializers/histograms_serializer_to_json'
|
162
|
-
require 'scout_apm/serializers/db_query_serializer_to_json'
|
163
145
|
require 'scout_apm/serializers/directive_serializer'
|
164
146
|
require 'scout_apm/serializers/app_server_load_serializer'
|
147
|
+
require 'scout_apm/serializers/deploy_serializer'
|
165
148
|
|
166
149
|
require 'scout_apm/middleware'
|
167
150
|
|
168
151
|
require 'scout_apm/instant/middleware'
|
169
152
|
|
170
|
-
require 'scout_apm/rack'
|
171
|
-
|
172
|
-
require 'scout_apm/remote/server'
|
173
|
-
require 'scout_apm/remote/router'
|
174
|
-
require 'scout_apm/remote/message'
|
175
|
-
require 'scout_apm/remote/recorder'
|
176
|
-
require 'scout_apm/instruments/resque'
|
177
|
-
|
178
|
-
require 'scout_apm/agent_context'
|
179
|
-
require 'scout_apm/instrument_manager'
|
180
|
-
require 'scout_apm/periodic_work'
|
181
|
-
require 'scout_apm/agent/preconditions'
|
182
|
-
require 'scout_apm/agent/exit_handler'
|
183
|
-
require 'scout_apm/tasks/doctor'
|
184
|
-
require 'scout_apm/tasks/support'
|
185
|
-
|
186
|
-
require 'scout_apm/extensions/config'
|
187
|
-
require 'scout_apm/extensions/transaction_callback_payload'
|
188
|
-
|
189
|
-
require 'scout_apm/error_service'
|
190
|
-
require 'scout_apm/error_service/middleware'
|
191
|
-
require 'scout_apm/error_service/notifier'
|
192
|
-
require 'scout_apm/error_service/sidekiq'
|
193
|
-
require 'scout_apm/error_service/ignored_exceptions'
|
194
|
-
require 'scout_apm/error_service/error_buffer'
|
195
|
-
require 'scout_apm/error_service/error_record'
|
196
|
-
require 'scout_apm/error_service/periodic_work'
|
197
|
-
require 'scout_apm/error_service/payload'
|
198
|
-
|
199
153
|
if defined?(Rails) && defined?(Rails::VERSION) && defined?(Rails::VERSION::MAJOR) && Rails::VERSION::MAJOR >= 3 && defined?(Rails::Railtie)
|
200
154
|
module ScoutApm
|
201
155
|
class Railtie < Rails::Railtie
|
@@ -206,32 +160,19 @@ if defined?(Rails) && defined?(Rails::VERSION) && defined?(Rails::VERSION::MAJOR
|
|
206
160
|
app.middleware.use ScoutApm::Middleware
|
207
161
|
|
208
162
|
# Attempt to start right away, this will work best for preloading apps, Unicorn & Puma & similar
|
209
|
-
ScoutApm::Agent.instance.
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
else
|
215
|
-
ScoutApm::Agent.instance.context.logger.debug("AutoInstruments is disabled.")
|
216
|
-
end
|
217
|
-
|
218
|
-
if ScoutApm::Agent.instance.context.config.value("errors_enabled")
|
219
|
-
app.config.middleware.insert_after ActionDispatch::DebugExceptions, ScoutApm::ErrorService::Middleware
|
220
|
-
ScoutApm::ErrorService::Sidekiq.new.install
|
221
|
-
end
|
222
|
-
|
163
|
+
ScoutApm::Agent.instance.start
|
164
|
+
end
|
165
|
+
end
|
166
|
+
class Railtie < Rails::Railtie
|
167
|
+
initializer 'scout_apm.start' do |app|
|
223
168
|
# Install the middleware every time in development mode.
|
224
169
|
# The middleware is a noop if dev_trace is not enabled in config
|
225
170
|
if Rails.env.development?
|
226
171
|
app.middleware.use ScoutApm::Instant::Middleware
|
227
172
|
end
|
228
173
|
end
|
229
|
-
|
230
|
-
rake_tasks do
|
231
|
-
load "tasks/doctor.rake"
|
232
|
-
end
|
233
174
|
end
|
234
175
|
end
|
235
176
|
else
|
236
|
-
ScoutApm::Agent.instance.
|
177
|
+
ScoutApm::Agent.instance.start
|
237
178
|
end
|
data/scout_apm.gemspec
CHANGED
@@ -19,27 +19,13 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib","data"]
|
21
21
|
s.extensions << 'ext/allocations/extconf.rb'
|
22
|
+
s.extensions << 'ext/stacks/extconf.rb'
|
22
23
|
s.extensions << 'ext/rusage/extconf.rb'
|
23
24
|
|
24
25
|
s.add_development_dependency "minitest"
|
25
|
-
s.add_development_dependency
|
26
|
+
s.add_development_dependency 'mocha'
|
26
27
|
s.add_development_dependency "pry"
|
28
|
+
s.add_development_dependency "m"
|
27
29
|
s.add_development_dependency "simplecov"
|
28
30
|
s.add_development_dependency "rake-compiler"
|
29
|
-
s.add_development_dependency "addressable"
|
30
|
-
s.add_development_dependency "activesupport"
|
31
|
-
s.add_runtime_dependency "parser"
|
32
|
-
|
33
|
-
# These are general development dependencies which are used in instrumentation
|
34
|
-
# tests. Specific versions are pulled in using specific gemfiles, e.g.
|
35
|
-
# `gems/rails3.gemfile`.
|
36
|
-
s.add_development_dependency "activerecord"
|
37
|
-
s.add_development_dependency "sqlite3"
|
38
|
-
|
39
|
-
if RUBY_VERSION >= "1.9.3"
|
40
|
-
s.add_development_dependency "rubocop"
|
41
|
-
s.add_development_dependency "guard"
|
42
|
-
s.add_development_dependency "guard-minitest"
|
43
|
-
s.add_development_dependency "m"
|
44
|
-
end
|
45
31
|
end
|
data/test/test_helper.rb
CHANGED
@@ -5,12 +5,10 @@ SimpleCov.start
|
|
5
5
|
require 'minitest/autorun'
|
6
6
|
require 'minitest/unit'
|
7
7
|
require 'minitest/pride'
|
8
|
-
require 'mocha/
|
8
|
+
require 'mocha/mini_test'
|
9
9
|
require 'pry'
|
10
10
|
|
11
11
|
|
12
|
-
require 'active_support/core_ext/string/inflections'
|
13
|
-
|
14
12
|
require 'scout_apm'
|
15
13
|
|
16
14
|
Kernel.module_eval do
|
@@ -18,14 +16,6 @@ Kernel.module_eval do
|
|
18
16
|
def self.const_unset(const)
|
19
17
|
self.instance_eval { remove_const(const) }
|
20
18
|
end
|
21
|
-
|
22
|
-
def silence_warnings(&block)
|
23
|
-
warn_level = $VERBOSE
|
24
|
-
$VERBOSE = nil
|
25
|
-
result = block.call
|
26
|
-
$VERBOSE = warn_level
|
27
|
-
result
|
28
|
-
end
|
29
19
|
end
|
30
20
|
|
31
21
|
# A test helper class to create a temporary "configuration" we can control entirely purposes
|
@@ -41,14 +31,6 @@ class FakeConfigOverlay
|
|
41
31
|
def has_key?(key)
|
42
32
|
@values.has_key?(key)
|
43
33
|
end
|
44
|
-
|
45
|
-
def name
|
46
|
-
"agent-test-config-overlay"
|
47
|
-
end
|
48
|
-
|
49
|
-
def any_keys_found?
|
50
|
-
true
|
51
|
-
end
|
52
34
|
end
|
53
35
|
|
54
36
|
class FakeEnvironment
|
@@ -68,14 +50,13 @@ end
|
|
68
50
|
# Helpers available to all tests
|
69
51
|
class Minitest::Test
|
70
52
|
def setup
|
71
|
-
Thread.current[:scout_request] = nil
|
72
53
|
reopen_logger
|
73
54
|
FileUtils.mkdir_p(DATA_FILE_DIR)
|
74
55
|
ENV['SCOUT_DATA_FILE'] = DATA_FILE_PATH
|
75
56
|
end
|
76
57
|
|
77
58
|
def teardown
|
78
|
-
ScoutApm::Agent.instance.
|
59
|
+
ScoutApm::Agent.instance.shutdown
|
79
60
|
File.delete(DATA_FILE_PATH) if File.exist?(DATA_FILE_PATH)
|
80
61
|
end
|
81
62
|
|
@@ -94,46 +75,11 @@ class Minitest::Test
|
|
94
75
|
FakeEnvironment.new(values)
|
95
76
|
end
|
96
77
|
|
97
|
-
# XXX: Make it easy to override context here?
|
98
78
|
def make_fake_config(values)
|
99
|
-
ScoutApm::Config.new(
|
100
|
-
end
|
101
|
-
|
102
|
-
def agent_context
|
103
|
-
ScoutApm::Agent.instance.context
|
79
|
+
ScoutApm::Config.new(FakeConfigOverlay.new(values))
|
104
80
|
end
|
105
81
|
|
106
82
|
DATA_FILE_DIR = File.dirname(__FILE__) + '/tmp'
|
107
83
|
DATA_FILE_PATH = "#{DATA_FILE_DIR}/scout_apm.db"
|
108
84
|
end
|
109
85
|
|
110
|
-
class FakeRecorder
|
111
|
-
attr_reader :requests
|
112
|
-
|
113
|
-
def initialize
|
114
|
-
@requests = []
|
115
|
-
end
|
116
|
-
|
117
|
-
def start
|
118
|
-
# nothing to do
|
119
|
-
self
|
120
|
-
end
|
121
|
-
|
122
|
-
def stop
|
123
|
-
# nothing to do
|
124
|
-
end
|
125
|
-
|
126
|
-
def record!(request)
|
127
|
-
@requests << request
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
module CustomAsserts
|
132
|
-
def assert_false(thing)
|
133
|
-
assert !thing
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
class Minitest::Test
|
138
|
-
include CustomAsserts
|
139
|
-
end
|