appsignal 2.10.7 → 2.11.0.alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.semaphore/semaphore.yml +45 -53
- data/CHANGELOG.md +18 -0
- data/build_matrix.yml +13 -6
- data/ext/agent.yml +19 -19
- data/ext/appsignal_extension.c +10 -1
- data/ext/base.rb +15 -4
- data/gemfiles/padrino.gemfile +2 -2
- data/lib/appsignal.rb +21 -1
- data/lib/appsignal/capistrano.rb +2 -0
- data/lib/appsignal/config.rb +6 -2
- data/lib/appsignal/environment.rb +126 -0
- data/lib/appsignal/extension/jruby.rb +10 -0
- data/lib/appsignal/hooks/net_http.rb +2 -0
- data/lib/appsignal/hooks/puma.rb +2 -58
- data/lib/appsignal/hooks/redis.rb +2 -0
- data/lib/appsignal/hooks/sequel.rb +2 -0
- data/lib/appsignal/hooks/sidekiq.rb +2 -99
- data/lib/appsignal/integrations/delayed_job_plugin.rb +16 -3
- data/lib/appsignal/integrations/object.rb +4 -0
- data/lib/appsignal/integrations/resque_active_job.rb +12 -4
- data/lib/appsignal/probes/puma.rb +61 -0
- data/lib/appsignal/probes/sidekiq.rb +102 -0
- data/lib/appsignal/rack/js_exception_catcher.rb +5 -2
- data/lib/appsignal/transaction.rb +22 -7
- data/lib/appsignal/version.rb +1 -1
- data/lib/puma/plugin/appsignal.rb +2 -1
- data/spec/lib/appsignal/cli/diagnose_spec.rb +2 -1
- data/spec/lib/appsignal/config_spec.rb +6 -1
- data/spec/lib/appsignal/environment_spec.rb +167 -0
- data/spec/lib/appsignal/hooks/delayed_job_spec.rb +198 -166
- data/spec/lib/appsignal/hooks/puma_spec.rb +2 -181
- data/spec/lib/appsignal/hooks/sidekiq_spec.rb +256 -462
- data/spec/lib/appsignal/integrations/padrino_spec.rb +1 -1
- data/spec/lib/appsignal/integrations/resque_active_job_spec.rb +55 -13
- data/spec/lib/appsignal/probes/puma_spec.rb +180 -0
- data/spec/lib/appsignal/probes/sidekiq_spec.rb +201 -0
- data/spec/lib/appsignal/rack/js_exception_catcher_spec.rb +9 -4
- data/spec/lib/appsignal/transaction_spec.rb +30 -13
- data/spec/lib/appsignal_spec.rb +22 -0
- data/spec/lib/puma/appsignal_spec.rb +1 -1
- data/spec/support/helpers/dependency_helper.rb +5 -0
- data/spec/support/helpers/env_helpers.rb +1 -1
- data/spec/support/helpers/environment_metdata_helper.rb +16 -0
- data/spec/support/stubs/sidekiq/api.rb +1 -1
- metadata +19 -8
@@ -4,9 +4,12 @@ describe Appsignal::Rack::JSExceptionCatcher do
|
|
4
4
|
let(:config_options) { { :enable_frontend_error_catching => true } }
|
5
5
|
let(:config) { project_fixture_config("production", config_options) }
|
6
6
|
let(:deprecation_message) do
|
7
|
-
"The Appsignal::Rack::JSExceptionCatcher is
|
8
|
-
"
|
9
|
-
"
|
7
|
+
"The Appsignal::Rack::JSExceptionCatcher is " \
|
8
|
+
"deprecated and will be removed in a future version. Please use " \
|
9
|
+
"the official AppSignal JavaScript integration by disabling " \
|
10
|
+
"`enable_frontend_error_catching` in your configuration and " \
|
11
|
+
"installing AppSignal for JavaScript instead. " \
|
12
|
+
"(https://docs.appsignal.com/front-end/)"
|
10
13
|
end
|
11
14
|
before { Appsignal.config = config }
|
12
15
|
|
@@ -32,7 +35,9 @@ describe Appsignal::Rack::JSExceptionCatcher do
|
|
32
35
|
|
33
36
|
describe "#call" do
|
34
37
|
let(:catcher) do
|
35
|
-
silence
|
38
|
+
silence :allowed => ["enable_frontend_error_catching"] do
|
39
|
+
Appsignal::Rack::JSExceptionCatcher.new(app, options)
|
40
|
+
end
|
36
41
|
end
|
37
42
|
after { catcher.call(env) }
|
38
43
|
|
@@ -500,23 +500,40 @@ describe Appsignal::Transaction do
|
|
500
500
|
end
|
501
501
|
|
502
502
|
describe "#set_http_or_background_queue_start" do
|
503
|
-
|
504
|
-
|
505
|
-
let(:env) { { "HTTP_X_REQUEST_START" => (fixed_time * 1000).to_s } }
|
503
|
+
let(:header_factor) { 1_000 }
|
504
|
+
let(:env_queue_start) { fixed_time + 20 } # in seconds
|
506
505
|
|
507
|
-
|
508
|
-
|
506
|
+
context "when a queue time is found in a request header" do
|
507
|
+
let(:header_time) { ((fixed_time + 10) * header_factor).to_i } # in milliseconds
|
508
|
+
let(:env) { { "HTTP_X_REQUEST_START" => "t=#{header_time}" } }
|
509
|
+
|
510
|
+
it "sets the http header value in milliseconds on the transaction" do
|
511
|
+
expect(transaction).to receive(:set_queue_start).with(1_389_783_610_000)
|
509
512
|
|
510
513
|
transaction.set_http_or_background_queue_start
|
511
514
|
end
|
515
|
+
|
516
|
+
context "when a :queue_start key is found in the transaction environment" do
|
517
|
+
let(:env) do
|
518
|
+
{
|
519
|
+
"HTTP_X_REQUEST_START" => "t=#{header_time}",
|
520
|
+
:queue_start => env_queue_start
|
521
|
+
}
|
522
|
+
end
|
523
|
+
|
524
|
+
it "sets the http header value in milliseconds on the transaction" do
|
525
|
+
expect(transaction).to receive(:set_queue_start).with(1_389_783_610_000)
|
526
|
+
|
527
|
+
transaction.set_http_or_background_queue_start
|
528
|
+
end
|
529
|
+
end
|
512
530
|
end
|
513
531
|
|
514
|
-
context "
|
515
|
-
let(:
|
516
|
-
let(:env) { { :queue_start => fixed_time } }
|
532
|
+
context "when a :queue_start key is found in the transaction environment" do
|
533
|
+
let(:env) { { :queue_start => env_queue_start } } # in seconds
|
517
534
|
|
518
|
-
it "
|
519
|
-
expect(transaction).to receive(:set_queue_start).with(
|
535
|
+
it "sets the :queue_start value in milliseconds on the transaction" do
|
536
|
+
expect(transaction).to receive(:set_queue_start).with(1_389_783_620_000)
|
520
537
|
|
521
538
|
transaction.set_http_or_background_queue_start
|
522
539
|
end
|
@@ -910,7 +927,7 @@ describe Appsignal::Transaction do
|
|
910
927
|
context "when queue start is set" do
|
911
928
|
let(:env) { background_env_with_data }
|
912
929
|
|
913
|
-
it { is_expected.to eq
|
930
|
+
it { is_expected.to eq 1_389_783_600_000 }
|
914
931
|
end
|
915
932
|
end
|
916
933
|
|
@@ -949,7 +966,7 @@ describe Appsignal::Transaction do
|
|
949
966
|
it { is_expected.to be_nil }
|
950
967
|
end
|
951
968
|
|
952
|
-
context "with
|
969
|
+
context "with unparsable content at the end" do
|
953
970
|
let(:env) { { "HTTP_X_REQUEST_START" => "t=#{slightly_earlier_time_value}aaaa" } }
|
954
971
|
|
955
972
|
it { is_expected.to eq 1_389_783_599_600 }
|
@@ -969,7 +986,7 @@ describe Appsignal::Transaction do
|
|
969
986
|
end
|
970
987
|
end
|
971
988
|
|
972
|
-
context "time in
|
989
|
+
context "time in milliseconds" do
|
973
990
|
let(:factor) { 1_000 }
|
974
991
|
|
975
992
|
it_should_behave_like "http queue start"
|
data/spec/lib/appsignal_spec.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
describe Appsignal do
|
2
|
+
include EnvironmentMetadataHelper
|
3
|
+
|
2
4
|
before do
|
3
5
|
# Make sure we have a clean state because we want to test
|
4
6
|
# initialization here.
|
@@ -80,18 +82,22 @@ describe Appsignal do
|
|
80
82
|
allow(GC::Profiler).to receive(:enable)
|
81
83
|
Appsignal.config.config_hash[:enable_allocation_tracking] = true
|
82
84
|
Appsignal.config.config_hash[:enable_gc_instrumentation] = true
|
85
|
+
capture_environment_metadata_report_calls
|
83
86
|
end
|
84
87
|
|
85
88
|
it "should enable Ruby's GC::Profiler" do
|
86
89
|
expect(GC::Profiler).to receive(:enable)
|
87
90
|
Appsignal.start
|
91
|
+
expect_environment_metadata("ruby_gc_instrumentation_enabled", "true")
|
88
92
|
end
|
89
93
|
|
90
94
|
unless Appsignal::System.jruby?
|
95
|
+
|
91
96
|
it "installs the allocation event hook" do
|
92
97
|
expect(Appsignal::Extension).to receive(:install_allocation_event_hook)
|
93
98
|
.and_call_original
|
94
99
|
Appsignal.start
|
100
|
+
expect_environment_metadata("ruby_allocation_tracking_enabled", "true")
|
95
101
|
end
|
96
102
|
end
|
97
103
|
end
|
@@ -100,6 +106,7 @@ describe Appsignal do
|
|
100
106
|
before do
|
101
107
|
Appsignal.config.config_hash[:enable_allocation_tracking] = false
|
102
108
|
Appsignal.config.config_hash[:enable_gc_instrumentation] = false
|
109
|
+
capture_environment_metadata_report_calls
|
103
110
|
end
|
104
111
|
|
105
112
|
it "should not enable Ruby's GC::Profiler" do
|
@@ -110,11 +117,13 @@ describe Appsignal do
|
|
110
117
|
it "should not install the allocation event hook" do
|
111
118
|
expect(Appsignal::Minutely).not_to receive(:install_allocation_event_hook)
|
112
119
|
Appsignal.start
|
120
|
+
expect_not_environment_metadata("ruby_allocation_tracking_enabled")
|
113
121
|
end
|
114
122
|
|
115
123
|
it "should not add the gc probe to minutely" do
|
116
124
|
expect(Appsignal::Minutely).not_to receive(:register_garbage_collection_probe)
|
117
125
|
Appsignal.start
|
126
|
+
expect_not_environment_metadata("ruby_gc_instrumentation_enabled")
|
118
127
|
end
|
119
128
|
end
|
120
129
|
|
@@ -139,6 +148,19 @@ describe Appsignal do
|
|
139
148
|
Appsignal.start
|
140
149
|
end
|
141
150
|
end
|
151
|
+
|
152
|
+
describe "environment metadata" do
|
153
|
+
before { capture_environment_metadata_report_calls }
|
154
|
+
|
155
|
+
it "collects and reports environment metadata" do
|
156
|
+
Appsignal.start
|
157
|
+
expect_environment_metadata("ruby_version", "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}")
|
158
|
+
expect_environment_metadata("ruby_engine", RUBY_ENGINE)
|
159
|
+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.3.0")
|
160
|
+
expect_environment_metadata("ruby_engine_version", RUBY_ENGINE_VERSION)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
142
164
|
end
|
143
165
|
|
144
166
|
context "with debug logging" do
|
@@ -62,7 +62,7 @@ RSpec.describe "Puma plugin" do
|
|
62
62
|
expect(launcher.events.on_booted).to_not be_nil
|
63
63
|
|
64
64
|
launcher.events.on_booted.call
|
65
|
-
expect(Appsignal::Minutely.probes[:puma]).to eql(Appsignal::
|
65
|
+
expect(Appsignal::Minutely.probes[:puma]).to eql(Appsignal::Probes::PumaProbe)
|
66
66
|
|
67
67
|
# Minutely probes started and called
|
68
68
|
wait_for("enough probe calls") { probe.calls >= 2 }
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module EnvironmentMetadataHelper
|
2
|
+
def capture_environment_metadata_report_calls
|
3
|
+
allow(Appsignal::Extension).to receive(:set_environment_metadata)
|
4
|
+
.and_call_original
|
5
|
+
end
|
6
|
+
|
7
|
+
def expect_environment_metadata(key, value)
|
8
|
+
expect(Appsignal::Extension).to have_received(:set_environment_metadata)
|
9
|
+
.with(key, value)
|
10
|
+
end
|
11
|
+
|
12
|
+
def expect_not_environment_metadata(key)
|
13
|
+
expect(Appsignal::Extension).to_not have_received(:set_environment_metadata)
|
14
|
+
.with(key, anything)
|
15
|
+
end
|
16
|
+
end
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appsignal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.11.0.alpha.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Beekman
|
8
8
|
- Thijs Cadier
|
9
9
|
- Tom de Bruijn
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-
|
13
|
+
date: 2020-07-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rack
|
@@ -190,6 +190,7 @@ files:
|
|
190
190
|
- lib/appsignal/cli/notify_of_deploy.rb
|
191
191
|
- lib/appsignal/config.rb
|
192
192
|
- lib/appsignal/demo.rb
|
193
|
+
- lib/appsignal/environment.rb
|
193
194
|
- lib/appsignal/event_formatter.rb
|
194
195
|
- lib/appsignal/event_formatter/action_view/render_formatter.rb
|
195
196
|
- lib/appsignal/event_formatter/active_record/instantiation_formatter.rb
|
@@ -240,6 +241,8 @@ files:
|
|
240
241
|
- lib/appsignal/logger.rb
|
241
242
|
- lib/appsignal/marker.rb
|
242
243
|
- lib/appsignal/minutely.rb
|
244
|
+
- lib/appsignal/probes/puma.rb
|
245
|
+
- lib/appsignal/probes/sidekiq.rb
|
243
246
|
- lib/appsignal/rack/generic_instrumentation.rb
|
244
247
|
- lib/appsignal/rack/js_exception_catcher.rb
|
245
248
|
- lib/appsignal/rack/rails_instrumentation.rb
|
@@ -274,6 +277,7 @@ files:
|
|
274
277
|
- spec/lib/appsignal/cli_spec.rb
|
275
278
|
- spec/lib/appsignal/config_spec.rb
|
276
279
|
- spec/lib/appsignal/demo_spec.rb
|
280
|
+
- spec/lib/appsignal/environment_spec.rb
|
277
281
|
- spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
|
278
282
|
- spec/lib/appsignal/event_formatter/active_record/instantiation_formatter_spec.rb
|
279
283
|
- spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb
|
@@ -318,6 +322,8 @@ files:
|
|
318
322
|
- spec/lib/appsignal/logger_spec.rb
|
319
323
|
- spec/lib/appsignal/marker_spec.rb
|
320
324
|
- spec/lib/appsignal/minutely_spec.rb
|
325
|
+
- spec/lib/appsignal/probes/puma_spec.rb
|
326
|
+
- spec/lib/appsignal/probes/sidekiq_spec.rb
|
321
327
|
- spec/lib/appsignal/rack/generic_instrumentation_spec.rb
|
322
328
|
- spec/lib/appsignal/rack/js_exception_catcher_spec.rb
|
323
329
|
- spec/lib/appsignal/rack/rails_instrumentation_spec.rb
|
@@ -348,6 +354,7 @@ files:
|
|
348
354
|
- spec/support/helpers/dependency_helper.rb
|
349
355
|
- spec/support/helpers/directory_helper.rb
|
350
356
|
- spec/support/helpers/env_helpers.rb
|
357
|
+
- spec/support/helpers/environment_metdata_helper.rb
|
351
358
|
- spec/support/helpers/example_exception.rb
|
352
359
|
- spec/support/helpers/example_standard_error.rb
|
353
360
|
- spec/support/helpers/log_helpers.rb
|
@@ -379,7 +386,7 @@ metadata:
|
|
379
386
|
documentation_uri: https://docs.appsignal.com/ruby/
|
380
387
|
homepage_uri: https://docs.appsignal.com/ruby/
|
381
388
|
source_code_uri: https://github.com/appsignal/appsignal-ruby
|
382
|
-
post_install_message:
|
389
|
+
post_install_message:
|
383
390
|
rdoc_options: []
|
384
391
|
require_paths:
|
385
392
|
- lib
|
@@ -391,12 +398,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
391
398
|
version: '1.9'
|
392
399
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
393
400
|
requirements:
|
394
|
-
- - "
|
401
|
+
- - ">"
|
395
402
|
- !ruby/object:Gem::Version
|
396
|
-
version:
|
403
|
+
version: 1.3.1
|
397
404
|
requirements: []
|
398
|
-
rubygems_version: 3.1.
|
399
|
-
signing_key:
|
405
|
+
rubygems_version: 3.1.4
|
406
|
+
signing_key:
|
400
407
|
specification_version: 4
|
401
408
|
summary: Logs performance and exception data from your app to appsignal.com
|
402
409
|
test_files:
|
@@ -414,6 +421,7 @@ test_files:
|
|
414
421
|
- spec/lib/appsignal/cli_spec.rb
|
415
422
|
- spec/lib/appsignal/config_spec.rb
|
416
423
|
- spec/lib/appsignal/demo_spec.rb
|
424
|
+
- spec/lib/appsignal/environment_spec.rb
|
417
425
|
- spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
|
418
426
|
- spec/lib/appsignal/event_formatter/active_record/instantiation_formatter_spec.rb
|
419
427
|
- spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb
|
@@ -458,6 +466,8 @@ test_files:
|
|
458
466
|
- spec/lib/appsignal/logger_spec.rb
|
459
467
|
- spec/lib/appsignal/marker_spec.rb
|
460
468
|
- spec/lib/appsignal/minutely_spec.rb
|
469
|
+
- spec/lib/appsignal/probes/puma_spec.rb
|
470
|
+
- spec/lib/appsignal/probes/sidekiq_spec.rb
|
461
471
|
- spec/lib/appsignal/rack/generic_instrumentation_spec.rb
|
462
472
|
- spec/lib/appsignal/rack/js_exception_catcher_spec.rb
|
463
473
|
- spec/lib/appsignal/rack/rails_instrumentation_spec.rb
|
@@ -488,6 +498,7 @@ test_files:
|
|
488
498
|
- spec/support/helpers/dependency_helper.rb
|
489
499
|
- spec/support/helpers/directory_helper.rb
|
490
500
|
- spec/support/helpers/env_helpers.rb
|
501
|
+
- spec/support/helpers/environment_metdata_helper.rb
|
491
502
|
- spec/support/helpers/example_exception.rb
|
492
503
|
- spec/support/helpers/example_standard_error.rb
|
493
504
|
- spec/support/helpers/log_helpers.rb
|