scout_apm 2.1.32 → 2.2.0.pre0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/CHANGELOG.markdown +2 -161
- data/Rakefile +2 -2
- data/ext/allocations/allocations.c +0 -6
- data/ext/allocations/extconf.rb +0 -1
- data/ext/stacks/extconf.rb +33 -0
- data/ext/stacks/scout_atomics.h +86 -0
- data/ext/stacks/stacks.c +744 -0
- data/lib/scout_apm.rb +16 -24
- data/lib/scout_apm/agent.rb +38 -93
- data/lib/scout_apm/agent/logging.rb +1 -6
- data/lib/scout_apm/agent/reporting.rb +6 -8
- data/lib/scout_apm/app_server_load.rb +10 -21
- data/lib/scout_apm/attribute_arranger.rb +2 -0
- data/lib/scout_apm/background_job_integrations/delayed_job.rb +1 -71
- data/lib/scout_apm/background_job_integrations/sidekiq.rb +27 -66
- data/lib/scout_apm/background_worker.rb +15 -19
- data/lib/scout_apm/capacity.rb +57 -0
- data/lib/scout_apm/config.rb +29 -135
- data/lib/scout_apm/context.rb +5 -9
- 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 +15 -22
- data/lib/scout_apm/histogram.rb +2 -11
- data/lib/scout_apm/instant/assets/xmlhttp_instrumentation.html +2 -2
- data/lib/scout_apm/instant/middleware.rb +57 -198
- data/lib/scout_apm/instruments/action_controller_rails_2.rb +2 -1
- data/lib/scout_apm/instruments/action_controller_rails_3_rails4.rb +59 -90
- data/lib/scout_apm/instruments/active_record.rb +5 -7
- data/lib/scout_apm/instruments/delayed_job.rb +57 -0
- data/lib/scout_apm/instruments/grape.rb +3 -4
- data/lib/scout_apm/instruments/middleware_detailed.rb +6 -4
- data/lib/scout_apm/instruments/middleware_summary.rb +1 -39
- data/lib/scout_apm/instruments/mongoid.rb +3 -24
- data/lib/scout_apm/instruments/net_http.rb +2 -7
- data/lib/scout_apm/instruments/percentile_sampler.rb +19 -36
- data/lib/scout_apm/instruments/process/process_cpu.rb +2 -3
- data/lib/scout_apm/instruments/process/process_memory.rb +3 -3
- data/lib/scout_apm/layaway.rb +33 -76
- data/lib/scout_apm/layer.rb +59 -16
- data/lib/scout_apm/layer_converters/converter_base.rb +0 -199
- data/lib/scout_apm/layer_converters/job_converter.rb +1 -1
- data/lib/scout_apm/layer_converters/metric_converter.rb +1 -1
- data/lib/scout_apm/layer_converters/slow_job_converter.rb +90 -15
- data/lib/scout_apm/layer_converters/slow_request_converter.rb +101 -13
- data/lib/scout_apm/metric_set.rb +1 -9
- data/lib/scout_apm/metric_stats.rb +8 -8
- data/lib/scout_apm/reporter.rb +15 -51
- data/lib/scout_apm/request_histograms.rb +0 -4
- data/lib/scout_apm/request_manager.rb +1 -2
- data/lib/scout_apm/scored_item_set.rb +0 -7
- data/lib/scout_apm/serializers/deploy_serializer.rb +16 -0
- data/lib/scout_apm/serializers/payload_serializer.rb +3 -9
- data/lib/scout_apm/serializers/payload_serializer_to_json.rb +5 -2
- data/lib/scout_apm/serializers/slow_jobs_serializer_to_json.rb +1 -2
- data/lib/scout_apm/server_integrations/puma.rb +2 -5
- data/lib/scout_apm/slow_item_set.rb +80 -0
- data/lib/scout_apm/slow_job_record.rb +1 -6
- data/lib/scout_apm/slow_transaction.rb +2 -20
- data/lib/scout_apm/store.rb +12 -50
- data/lib/scout_apm/trace_compactor.rb +311 -0
- data/lib/scout_apm/tracked_request.rb +37 -128
- data/lib/scout_apm/utils/backtrace_parser.rb +5 -7
- data/lib/scout_apm/utils/fake_stacks.rb +83 -0
- data/lib/scout_apm/version.rb +1 -1
- data/scout_apm.gemspec +4 -6
- data/test/test_helper.rb +0 -56
- data/test/unit/config_test.rb +9 -60
- data/test/unit/histogram_test.rb +0 -14
- data/test/unit/layaway_test.rb +16 -31
- data/test/unit/serializers/payload_serializer_test.rb +105 -3
- data/test/unit/slow_item_set_test.rb +94 -0
- data/test/unit/slow_job_policy_test.rb +49 -0
- data/test/unit/slow_request_policy_test.rb +5 -4
- data/test/unit/utils/backtrace_parser_test.rb +0 -19
- data/tester.rb +53 -0
- metadata +29 -124
- data/.rubocop.yml +0 -8
- data/Guardfile +0 -42
- data/ext/rusage/README.md +0 -26
- data/ext/rusage/extconf.rb +0 -5
- data/ext/rusage/rusage.c +0 -52
- data/lib/scout_apm/background_job_integrations/resque.rb +0 -85
- data/lib/scout_apm/background_recorder.rb +0 -43
- data/lib/scout_apm/debug.rb +0 -37
- data/lib/scout_apm/git_revision.rb +0 -51
- data/lib/scout_apm/instruments/action_view.rb +0 -49
- data/lib/scout_apm/instruments/resque.rb +0 -40
- data/lib/scout_apm/layer_children_set.rb +0 -77
- data/lib/scout_apm/limited_layer.rb +0 -122
- data/lib/scout_apm/rack.rb +0 -26
- data/lib/scout_apm/remote/message.rb +0 -23
- 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 -58
- data/lib/scout_apm/serializers/histograms_serializer_to_json.rb +0 -21
- data/lib/scout_apm/synchronous_recorder.rb +0 -26
- data/lib/scout_apm/utils/gzip_helper.rb +0 -24
- data/lib/scout_apm/utils/numbers.rb +0 -14
- data/lib/scout_apm/utils/scm.rb +0 -14
- data/test/unit/background_job_integrations/sidekiq_test.rb +0 -104
- data/test/unit/context_test.rb +0 -30
- data/test/unit/git_revision_test.rb +0 -15
- data/test/unit/instruments/net_http_test.rb +0 -21
- data/test/unit/instruments/percentile_sampler_test.rb +0 -137
- data/test/unit/layer_children_set_test.rb +0 -88
- data/test/unit/limited_layer_test.rb +0 -53
- 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/store_test.rb +0 -89
- data/test/unit/test_tracked_request.rb +0 -87
- data/test/unit/utils/numbers_test.rb +0 -15
- data/test/unit/utils/scm.rb +0 -17
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class MessageTest < Minitest::Test
|
4
|
-
def test_message_encode_decode_roundtrip
|
5
|
-
message = ScoutApm::Remote::Message.new('type', 'command', ['arg'])
|
6
|
-
encoded = message.encode
|
7
|
-
decoded = ScoutApm::Remote::Message.decode(encoded)
|
8
|
-
assert_equal message.type, decoded.type
|
9
|
-
assert_equal message.command, decoded.command
|
10
|
-
assert_equal message.args, decoded.args
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class RouterTest < Minitest::Test
|
4
|
-
def test_router_handles_record
|
5
|
-
recorder = stub
|
6
|
-
router = ScoutApm::Remote::Router.new(recorder, logger)
|
7
|
-
message = ScoutApm::Remote::Message.new("record", "foo", 1, 2).encode
|
8
|
-
|
9
|
-
recorder.expects(:foo).with(1, 2)
|
10
|
-
|
11
|
-
router.handle(message)
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_router_raises_on_unknown_types
|
15
|
-
recorder = stub
|
16
|
-
router = ScoutApm::Remote::Router.new(recorder, logger)
|
17
|
-
message = ScoutApm::Remote::Message.new("something_else", "foo", 1, 2).encode
|
18
|
-
|
19
|
-
recorder.expects(:foo).never
|
20
|
-
assert_raises do
|
21
|
-
router.handle(message)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def logger
|
26
|
-
@logger ||= Logger.new(logger_io)
|
27
|
-
end
|
28
|
-
|
29
|
-
def logger_io
|
30
|
-
@logger_io ||= StringIO.new
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class TestRemoteServer < Minitest::Test
|
4
|
-
def test_start_and_bind
|
5
|
-
bind = "127.0.0.1"
|
6
|
-
port = 8938
|
7
|
-
router = stub(:router)
|
8
|
-
logger_io = StringIO.new
|
9
|
-
server = ScoutApm::Remote::Server.new(bind, port, router, Logger.new(logger_io))
|
10
|
-
|
11
|
-
server.start
|
12
|
-
sleep 0.01 # Let the server finish starting. The assert should instead allow a time
|
13
|
-
assert server.running?
|
14
|
-
end
|
15
|
-
end
|
data/test/unit/store_test.rb
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
require 'scout_apm/store'
|
4
|
-
|
5
|
-
class FakeFailingLayaway
|
6
|
-
def write_reporting_period(rp)
|
7
|
-
raise "Always fails. Sucks."
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
class StoreTest < Minitest::Test
|
12
|
-
# TODO: Introduce a clock object to avoid having to use 'force'
|
13
|
-
def test_writing_layaway_removes_timestamps
|
14
|
-
s = ScoutApm::Store.new
|
15
|
-
s.track_one!("Controller", "user/show", 10)
|
16
|
-
|
17
|
-
assert_equal(1, s.reporting_periods.size)
|
18
|
-
|
19
|
-
s.write_to_layaway(FakeFailingLayaway.new, true)
|
20
|
-
|
21
|
-
assert_equal({}, s.reporting_periods)
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_writing_layaway_removes_stale_timestamps
|
25
|
-
current_time = Time.now.utc
|
26
|
-
current_rp = ScoutApm::StoreReportingPeriod.new(current_time)
|
27
|
-
stale_rp = ScoutApm::StoreReportingPeriod.new(current_time - current_time.sec - 120)
|
28
|
-
|
29
|
-
s = ScoutApm::Store.new
|
30
|
-
ScoutApm::Instruments::Process::ProcessMemory.new(Logger.new(StringIO.new)).metrics(stale_rp.timestamp, s)
|
31
|
-
ScoutApm::Instruments::Process::ProcessMemory.new(Logger.new(StringIO.new)).metrics(current_rp.timestamp, s)
|
32
|
-
assert_equal 2, s.reporting_periods.size
|
33
|
-
|
34
|
-
s.write_to_layaway(FakeFailingLayaway.new, true)
|
35
|
-
|
36
|
-
assert_equal({}, s.reporting_periods)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
class StoreReportingPeriodTest < Minitest::Test
|
41
|
-
HistogramReport = ScoutApm::Instruments::HistogramReport
|
42
|
-
|
43
|
-
attr_reader :subject
|
44
|
-
|
45
|
-
def setup
|
46
|
-
@subject = ScoutApm::StoreReportingPeriod.new(ScoutApm::StoreReportingPeriodTimestamp.new)
|
47
|
-
end
|
48
|
-
|
49
|
-
# Check default values at creation time
|
50
|
-
def test_empty_values
|
51
|
-
assert_equal [], subject.histograms
|
52
|
-
assert_equal ScoutApm::ScoredItemSet.new, subject.request_traces
|
53
|
-
assert_equal ScoutApm::ScoredItemSet.new, subject.job_traces
|
54
|
-
assert_equal ScoutApm::MetricSet.new, subject.metric_set
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_merge_histograms
|
58
|
-
histogramFoo1 = histogram
|
59
|
-
histogramFoo2 = histogram
|
60
|
-
histogramBar1 = histogram
|
61
|
-
histogramBar2 = histogram
|
62
|
-
|
63
|
-
# This assertion may be fragile to reordering in the merge_histograms! function.
|
64
|
-
histogramFoo1.expects(:combine!).with(histogramFoo2)
|
65
|
-
histogramBar1.expects(:combine!).with(histogramBar2)
|
66
|
-
|
67
|
-
subject.merge_histograms!([
|
68
|
-
HistogramReport.new("foo", histogramFoo1),
|
69
|
-
HistogramReport.new("bar", histogramBar1),
|
70
|
-
])
|
71
|
-
|
72
|
-
subject.merge_histograms!([
|
73
|
-
HistogramReport.new("foo", histogramFoo2),
|
74
|
-
HistogramReport.new("bar", histogramBar2),
|
75
|
-
])
|
76
|
-
|
77
|
-
result = subject.histograms
|
78
|
-
assert_equal 2, result.length
|
79
|
-
assert_equal ["bar", "foo"], result.map(&:name).sort
|
80
|
-
end
|
81
|
-
|
82
|
-
###############################################################################
|
83
|
-
# Helpers
|
84
|
-
###############################################################################
|
85
|
-
def histogram
|
86
|
-
max_bins = 20
|
87
|
-
ScoutApm::NumericHistogram.new(max_bins)
|
88
|
-
end
|
89
|
-
end
|
@@ -1,87 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class TrackedRequestDumpAndLoadTest < Minitest::Test
|
4
|
-
# TrackedRequest must be marshalable
|
5
|
-
def test_marshal_dump_load
|
6
|
-
tr = ScoutApm::TrackedRequest.new(ScoutApm::FakeStore.new)
|
7
|
-
tr.prepare_to_dump!
|
8
|
-
|
9
|
-
dumped = Marshal.dump(tr)
|
10
|
-
loaded = Marshal.load(dumped)
|
11
|
-
assert_false loaded.nil?
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_restore_store
|
15
|
-
faux = ScoutApm::FakeStore.new
|
16
|
-
tr = ScoutApm::TrackedRequest.new(faux)
|
17
|
-
assert_equal faux, tr.instance_variable_get("@store")
|
18
|
-
|
19
|
-
tr.prepare_to_dump!
|
20
|
-
assert_nil tr.instance_variable_get("@store")
|
21
|
-
|
22
|
-
tr.restore_store
|
23
|
-
assert_equal ScoutApm::Agent.instance.store, tr.instance_variable_get("@store")
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
class TrackedRequestFlagsTest < Minitest::Test
|
28
|
-
def test_set_web
|
29
|
-
tr = ScoutApm::TrackedRequest.new(ScoutApm::FakeStore.new)
|
30
|
-
assert_false tr.web?
|
31
|
-
tr.web!
|
32
|
-
assert tr.web?
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_set_job
|
36
|
-
tr = ScoutApm::TrackedRequest.new(ScoutApm::FakeStore.new)
|
37
|
-
assert ! tr.job?
|
38
|
-
tr.job!
|
39
|
-
assert tr.job?
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_set_error
|
43
|
-
tr = ScoutApm::TrackedRequest.new(ScoutApm::FakeStore.new)
|
44
|
-
assert_false tr.error?
|
45
|
-
tr.error!
|
46
|
-
assert tr.error?
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_set_error_and_web
|
50
|
-
tr = ScoutApm::TrackedRequest.new(ScoutApm::FakeStore.new)
|
51
|
-
assert_false tr.error?
|
52
|
-
assert_false tr.web?
|
53
|
-
|
54
|
-
tr.web!
|
55
|
-
assert_false tr.error?
|
56
|
-
assert tr.web?
|
57
|
-
|
58
|
-
tr.error!
|
59
|
-
assert tr.error?
|
60
|
-
assert tr.web?
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
class TrackedRequestLayerManipulationTest < Minitest::Test
|
65
|
-
def test_start_layer
|
66
|
-
tr = ScoutApm::TrackedRequest.new(ScoutApm::FakeStore.new)
|
67
|
-
tr.start_layer(ScoutApm::Layer.new("Foo", "Bar"))
|
68
|
-
|
69
|
-
assert_equal "Foo", tr.current_layer.type
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_start_several_layers
|
73
|
-
# layers are Controller -> ActiveRecord
|
74
|
-
controller_layer = ScoutApm::Layer.new("Controller", "users/index")
|
75
|
-
ar_layer = ScoutApm::Layer.new("ActiveRecord", "Users#find")
|
76
|
-
|
77
|
-
tr = ScoutApm::TrackedRequest.new(ScoutApm::FakeStore.new)
|
78
|
-
tr.start_layer(controller_layer)
|
79
|
-
tr.start_layer(ar_layer)
|
80
|
-
|
81
|
-
assert_equal "ActiveRecord", tr.current_layer.type
|
82
|
-
|
83
|
-
tr.stop_layer
|
84
|
-
|
85
|
-
assert_equal "Controller", tr.current_layer.type
|
86
|
-
end
|
87
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require_relative '../../test_helper'
|
2
|
-
require 'scout_apm/utils/numbers'
|
3
|
-
|
4
|
-
class NumbersTest < Minitest::Test
|
5
|
-
Numbers = ScoutApm::Utils::Numbers
|
6
|
-
|
7
|
-
def test_round
|
8
|
-
assert_equal 12, Numbers.round(12.1234567, 0)
|
9
|
-
assert_equal 12.1, Numbers.round(12.1234567, 1)
|
10
|
-
assert_equal 12.12, Numbers.round(12.1234567, 2)
|
11
|
-
assert_equal 12.123, Numbers.round(12.1234567, 3)
|
12
|
-
|
13
|
-
assert_equal 12, Numbers.round(12.0000, 2)
|
14
|
-
end
|
15
|
-
end
|
data/test/unit/utils/scm.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require_relative '../../test_helper'
|
2
|
-
require 'scout_apm/utils/scm'
|
3
|
-
|
4
|
-
class ScmTest < Minitest::Test
|
5
|
-
|
6
|
-
def test_relative_scm_path_blank
|
7
|
-
assert_equal 'app/models/person.rb', ScoutApm::Utils::Scm.relative_scm_path('app/models/person.rb', '')
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_relative_scm_path_not_blank
|
11
|
-
assert_equal 'src/app/models/person.rb', ScoutApm::Utils::Scm.relative_scm_path('app/models/person.rb', 'src')
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_relative_scm_path_not_blank_with_slashes
|
15
|
-
assert_equal 'src/app/models/person.rb', ScoutApm::Utils::Scm.relative_scm_path('app/models/person.rb', '/src/')
|
16
|
-
end
|
17
|
-
end
|