appsignal 3.0.0.beta.1 → 3.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +1 -1
  3. data/.semaphore/semaphore.yml +88 -88
  4. data/CHANGELOG.md +41 -1
  5. data/Rakefile +12 -4
  6. data/appsignal.gemspec +7 -5
  7. data/build_matrix.yml +11 -11
  8. data/ext/agent.yml +17 -17
  9. data/gemfiles/no_dependencies.gemfile +0 -7
  10. data/lib/appsignal.rb +1 -2
  11. data/lib/appsignal/config.rb +1 -1
  12. data/lib/appsignal/extension.rb +50 -0
  13. data/lib/appsignal/helpers/instrumentation.rb +69 -5
  14. data/lib/appsignal/hooks.rb +16 -0
  15. data/lib/appsignal/hooks/action_cable.rb +10 -2
  16. data/lib/appsignal/hooks/sidekiq.rb +9 -142
  17. data/lib/appsignal/integrations/object.rb +21 -43
  18. data/lib/appsignal/integrations/railtie.rb +0 -4
  19. data/lib/appsignal/integrations/sidekiq.rb +171 -0
  20. data/lib/appsignal/minutely.rb +6 -0
  21. data/lib/appsignal/transaction.rb +2 -2
  22. data/lib/appsignal/version.rb +1 -1
  23. data/spec/lib/appsignal/config_spec.rb +2 -0
  24. data/spec/lib/appsignal/extension_install_failure_spec.rb +0 -7
  25. data/spec/lib/appsignal/extension_spec.rb +43 -9
  26. data/spec/lib/appsignal/hooks/action_cable_spec.rb +88 -0
  27. data/spec/lib/appsignal/hooks/sidekiq_spec.rb +60 -458
  28. data/spec/lib/appsignal/hooks_spec.rb +41 -0
  29. data/spec/lib/appsignal/integrations/object_spec.rb +91 -4
  30. data/spec/lib/appsignal/integrations/sidekiq_spec.rb +524 -0
  31. data/spec/lib/appsignal/transaction_spec.rb +17 -0
  32. data/spec/lib/appsignal/utils/data_spec.rb +133 -87
  33. data/spec/lib/appsignal_spec.rb +162 -47
  34. data/spec/lib/puma/appsignal_spec.rb +28 -0
  35. data/spec/spec_helper.rb +22 -0
  36. data/spec/support/testing.rb +11 -1
  37. metadata +9 -8
  38. data/gemfiles/rails-4.0.gemfile +0 -6
  39. data/gemfiles/rails-4.1.gemfile +0 -6
@@ -23,6 +23,27 @@ RSpec.describe "Puma plugin" do
23
23
  def self.stats
24
24
  end
25
25
 
26
+ def self.run
27
+ # Capture threads running before application is preloaded
28
+ before = Thread.list.reject { |t| t.thread_variable_get(:fork_safe) }
29
+
30
+ # An abbreviated version of what happens in Puma::Cluster#run
31
+ launcher = MockPumaLauncher.new
32
+ plugin = Plugin.plugin.new
33
+ plugin.start(launcher)
34
+ launcher.events.on_booted.call
35
+
36
+ # Wait for minutely probe thread to finish starting
37
+ sleep 0.005
38
+
39
+ # Capture any new threads running after application is preloaded.
40
+ # Any threads created during the preloading phase will not be
41
+ # carried over into the forked workers. Puma warns about these
42
+ # but the minutely probe thread should only exist in the main process.
43
+ after = Thread.list.reject { |t| t.thread_variable_get(:fork_safe) }
44
+ $stdout.puts "! WARNING: Detected #{after.size - before.size} Thread(s) started in app boot" if after.size > before.size
45
+ end
46
+
26
47
  class Plugin
27
48
  class << self
28
49
  attr_reader :plugin
@@ -68,6 +89,13 @@ RSpec.describe "Puma plugin" do
68
89
  wait_for("enough probe calls") { probe.calls >= 2 }
69
90
  end
70
91
 
92
+ it "marks the PumaProbe thread as fork-safe" do
93
+ out_stream = std_stream
94
+ capture_stdout(out_stream) { Puma.run }
95
+
96
+ expect(out_stream.read).not_to include("WARNING: Detected 1 Thread")
97
+ end
98
+
71
99
  context "without Puma.stats" do
72
100
  before { Puma.singleton_class.send(:remove_method, :stats) }
73
101
 
data/spec/spec_helper.rb CHANGED
@@ -117,6 +117,28 @@ RSpec.configure do |config|
117
117
  allow(Appsignal::Config).to receive(:system_tmp_dir).and_return(spec_system_tmp_dir)
118
118
  end
119
119
 
120
+ # These tests are not run by default. They require a failed extension
121
+ # installation. See the `rake test:failure` task. If a test with this tag was
122
+ # run, run `rake extension:install` again to fix the extension installation
123
+ # before running other tests.
124
+ config.before :extension_installation_failure => true do
125
+ next unless Appsignal.extension_loaded?
126
+
127
+ raise "Extension is loaded, please run the following task and rerun the test." \
128
+ "\n\n rake test:prepare_failure"
129
+ end
130
+
131
+ # Check to see if the extension is loaded before running the specs. If the
132
+ # extension is not loaded it can result in unexpected behavior.
133
+ config.before do |example|
134
+ next if Appsignal.extension_loaded?
135
+ next if example.metadata[:extension_installation_failure]
136
+
137
+ puts "\nWARNING: The AppSignal extension is not loaded, please run the "\
138
+ "following task and rerun the test." \
139
+ "\n\n rake extension:install\n"
140
+ end
141
+
120
142
  config.after do
121
143
  Appsignal::Testing.clear!
122
144
  clear_current_transaction!
@@ -1,16 +1,26 @@
1
1
  module Appsignal
2
2
  class << self
3
+ attr_writer :testing
3
4
  remove_method :testing?
4
5
 
5
6
  # @api private
6
7
  def testing?
7
- true
8
+ @testing = true unless defined?(@testing)
9
+ @testing
8
10
  end
9
11
  end
10
12
 
11
13
  # @api private
12
14
  module Testing
13
15
  class << self
16
+ def without_testing
17
+ original_testing = Appsignal.testing?
18
+ Appsignal.testing = false
19
+ yield
20
+ ensure
21
+ Appsignal.testing = original_testing
22
+ end
23
+
14
24
  def transactions
15
25
  @transactions ||= []
16
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appsignal
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.beta.1
4
+ version: 3.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Beekman
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-01-28 00:00:00.000000000 Z
13
+ date: 2021-04-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack
@@ -165,8 +165,6 @@ files:
165
165
  - gemfiles/que.gemfile
166
166
  - gemfiles/que_beta.gemfile
167
167
  - gemfiles/rails-3.2.gemfile
168
- - gemfiles/rails-4.0.gemfile
169
- - gemfiles/rails-4.1.gemfile
170
168
  - gemfiles/rails-4.2.gemfile
171
169
  - gemfiles/rails-5.0.gemfile
172
170
  - gemfiles/rails-5.1.gemfile
@@ -241,6 +239,7 @@ files:
241
239
  - lib/appsignal/integrations/rake.rb
242
240
  - lib/appsignal/integrations/redis.rb
243
241
  - lib/appsignal/integrations/resque.rb
242
+ - lib/appsignal/integrations/sidekiq.rb
244
243
  - lib/appsignal/integrations/sinatra.rb
245
244
  - lib/appsignal/integrations/unicorn.rb
246
245
  - lib/appsignal/integrations/webmachine.rb
@@ -326,6 +325,7 @@ files:
326
325
  - spec/lib/appsignal/integrations/padrino_spec.rb
327
326
  - spec/lib/appsignal/integrations/que_spec.rb
328
327
  - spec/lib/appsignal/integrations/railtie_spec.rb
328
+ - spec/lib/appsignal/integrations/sidekiq_spec.rb
329
329
  - spec/lib/appsignal/integrations/sinatra_spec.rb
330
330
  - spec/lib/appsignal/integrations/webmachine_spec.rb
331
331
  - spec/lib/appsignal/logger_spec.rb
@@ -404,14 +404,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
404
404
  requirements:
405
405
  - - ">="
406
406
  - !ruby/object:Gem::Version
407
- version: '1.9'
407
+ version: '2.0'
408
408
  required_rubygems_version: !ruby/object:Gem::Requirement
409
409
  requirements:
410
- - - ">"
410
+ - - ">="
411
411
  - !ruby/object:Gem::Version
412
- version: 1.3.1
412
+ version: '0'
413
413
  requirements: []
414
- rubygems_version: 3.2.6
414
+ rubygems_version: 3.2.16
415
415
  signing_key:
416
416
  specification_version: 4
417
417
  summary: Logs performance and exception data from your app to appsignal.com
@@ -473,6 +473,7 @@ test_files:
473
473
  - spec/lib/appsignal/integrations/padrino_spec.rb
474
474
  - spec/lib/appsignal/integrations/que_spec.rb
475
475
  - spec/lib/appsignal/integrations/railtie_spec.rb
476
+ - spec/lib/appsignal/integrations/sidekiq_spec.rb
476
477
  - spec/lib/appsignal/integrations/sinatra_spec.rb
477
478
  - spec/lib/appsignal/integrations/webmachine_spec.rb
478
479
  - spec/lib/appsignal/logger_spec.rb
@@ -1,6 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'rails', '~> 4.0.0'
4
- gem 'mime-types', '~> 2.6'
5
-
6
- gemspec :path => '../'
@@ -1,6 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'rails', '~> 4.1.0'
4
- gem 'mime-types', '~> 2.6'
5
-
6
- gemspec :path => '../'