appsignal 3.11.0 → 3.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +109 -0
  3. data/Rakefile +1 -1
  4. data/lib/appsignal/cli/diagnose.rb +1 -1
  5. data/lib/appsignal/config.rb +150 -32
  6. data/lib/appsignal/demo.rb +1 -6
  7. data/lib/appsignal/integrations/grape.rb +7 -0
  8. data/lib/appsignal/integrations/hanami.rb +8 -43
  9. data/lib/appsignal/integrations/padrino.rb +8 -73
  10. data/lib/appsignal/integrations/railtie.rb +35 -13
  11. data/lib/appsignal/integrations/sinatra.rb +8 -19
  12. data/lib/appsignal/loaders/grape.rb +13 -0
  13. data/lib/appsignal/loaders/hanami.rb +40 -0
  14. data/lib/appsignal/loaders/padrino.rb +68 -0
  15. data/lib/appsignal/loaders/sinatra.rb +24 -0
  16. data/lib/appsignal/loaders.rb +92 -0
  17. data/lib/appsignal/rack/abstract_middleware.rb +2 -1
  18. data/lib/appsignal/rack/event_handler.rb +5 -5
  19. data/lib/appsignal/rack.rb +6 -0
  20. data/lib/appsignal/version.rb +1 -1
  21. data/lib/appsignal.rb +163 -9
  22. data/spec/lib/appsignal/cli/demo_spec.rb +0 -1
  23. data/spec/lib/appsignal/cli/diagnose/paths_spec.rb +1 -1
  24. data/spec/lib/appsignal/cli/diagnose_spec.rb +0 -1
  25. data/spec/lib/appsignal/config_spec.rb +153 -1
  26. data/spec/lib/appsignal/demo_spec.rb +1 -2
  27. data/spec/lib/appsignal/environment_spec.rb +4 -2
  28. data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +3 -6
  29. data/spec/lib/appsignal/hooks/activejob_spec.rb +3 -3
  30. data/spec/lib/appsignal/hooks/dry_monitor_spec.rb +4 -7
  31. data/spec/lib/appsignal/hooks/excon_spec.rb +3 -6
  32. data/spec/lib/appsignal/hooks/gvl_spec.rb +2 -2
  33. data/spec/lib/appsignal/hooks/http_spec.rb +1 -3
  34. data/spec/lib/appsignal/hooks/net_http_spec.rb +1 -1
  35. data/spec/lib/appsignal/hooks/redis_client_spec.rb +5 -8
  36. data/spec/lib/appsignal/hooks/redis_spec.rb +3 -6
  37. data/spec/lib/appsignal/hooks/resque_spec.rb +1 -1
  38. data/spec/lib/appsignal/hooks/sequel_spec.rb +3 -5
  39. data/spec/lib/appsignal/hooks/sidekiq_spec.rb +1 -1
  40. data/spec/lib/appsignal/hooks/webmachine_spec.rb +1 -1
  41. data/spec/lib/appsignal/integrations/delayed_job_plugin_spec.rb +2 -2
  42. data/spec/lib/appsignal/integrations/grape_spec.rb +36 -0
  43. data/spec/lib/appsignal/integrations/hanami_spec.rb +9 -178
  44. data/spec/lib/appsignal/integrations/http_spec.rb +1 -5
  45. data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +4 -2
  46. data/spec/lib/appsignal/integrations/net_http_spec.rb +1 -1
  47. data/spec/lib/appsignal/integrations/object_spec.rb +1 -3
  48. data/spec/lib/appsignal/integrations/padrino_spec.rb +8 -330
  49. data/spec/lib/appsignal/integrations/railtie_spec.rb +275 -191
  50. data/spec/lib/appsignal/integrations/shoryuken_spec.rb +1 -1
  51. data/spec/lib/appsignal/integrations/sidekiq_spec.rb +11 -9
  52. data/spec/lib/appsignal/integrations/sinatra_spec.rb +9 -104
  53. data/spec/lib/appsignal/loaders/grape_spec.rb +12 -0
  54. data/spec/lib/appsignal/loaders/hanami_spec.rb +95 -0
  55. data/spec/lib/appsignal/loaders/padrino_spec.rb +277 -0
  56. data/spec/lib/appsignal/loaders/sinatra_spec.rb +47 -0
  57. data/spec/lib/appsignal/loaders_spec.rb +137 -0
  58. data/spec/lib/appsignal/probes/sidekiq_spec.rb +1 -1
  59. data/spec/lib/appsignal/probes_spec.rb +6 -5
  60. data/spec/lib/appsignal/rack/abstract_middleware_spec.rb +3 -2
  61. data/spec/lib/appsignal/rack/event_handler_spec.rb +33 -0
  62. data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +1 -1
  63. data/spec/lib/appsignal/rack/grape_middleware_spec.rb +2 -35
  64. data/spec/lib/appsignal/rack/hanami_middleware_spec.rb +1 -1
  65. data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +3 -3
  66. data/spec/lib/appsignal/span_spec.rb +1 -3
  67. data/spec/lib/appsignal/transaction_spec.rb +4 -2
  68. data/spec/lib/appsignal_spec.rb +278 -26
  69. data/spec/lib/puma/appsignal_spec.rb +0 -3
  70. data/spec/spec_helper.rb +5 -4
  71. data/spec/support/helpers/config_helpers.rb +2 -1
  72. data/spec/support/helpers/loader_helper.rb +21 -0
  73. data/spec/support/stubs/appsignal/loaders/loader_stub.rb +7 -0
  74. data/spec/support/testing.rb +46 -0
  75. metadata +15 -2
@@ -4,6 +4,7 @@ module ConfigHelpers
4
4
  File.join(File.dirname(__FILE__), "../fixtures/projects/valid")
5
5
  )
6
6
  end
7
+ module_function :project_fixture_path
7
8
 
8
9
  def project_fixture_config( # rubocop:disable Metrics/ParameterLists
9
10
  env = "production",
@@ -22,7 +23,7 @@ module ConfigHelpers
22
23
  module_function :project_fixture_config, :project_fixture_path
23
24
 
24
25
  def start_agent(env = "production")
25
- Appsignal.config = project_fixture_config(env)
26
+ Appsignal._config = project_fixture_config(env)
26
27
  Appsignal.start
27
28
  end
28
29
  end
@@ -0,0 +1,21 @@
1
+ module LoaderHelper
2
+ def load_loader(name)
3
+ Appsignal.load(name)
4
+ end
5
+
6
+ def start_loader(name)
7
+ Appsignal::Loaders.instances.fetch(name).on_start
8
+ end
9
+
10
+ def unregister_loader(name)
11
+ Appsignal::Loaders.unregister(name)
12
+ end
13
+
14
+ def define_loader(name, &block)
15
+ Appsignal::Testing.registered_loaders << name
16
+ Class.new(Appsignal::Loaders::Loader) do
17
+ register name
18
+ class_eval(&block) if block_given?
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,7 @@
1
+ module Appsignal
2
+ module Loaders
3
+ class LoaderStub < Loader
4
+ register :loader_stub
5
+ end
6
+ end
7
+ end
@@ -9,11 +9,55 @@ module Appsignal
9
9
  @testing = true unless defined?(@testing)
10
10
  @testing
11
11
  end
12
+
13
+ # @api private
14
+ def clear_started!
15
+ return unless instance_variable_defined?(:@started)
16
+
17
+ remove_instance_variable(:@started)
18
+ end
19
+
20
+ # @api private
21
+ def clear_config!
22
+ @config = nil
23
+ end
24
+
25
+ # @api private
26
+ def clear!
27
+ Appsignal.internal_logger = nil
28
+
29
+ clear_started!
30
+ clear_config!
31
+ end
32
+ end
33
+
34
+ class Config
35
+ def self.clear_loader_defaults!
36
+ @loader_defaults = nil
37
+ end
38
+ end
39
+
40
+ module Loaders
41
+ def self.clear!
42
+ Appsignal::Config.clear_loader_defaults!
43
+ loaders.reject! do |key, _value|
44
+ Appsignal::Testing.registered_loaders.include?(key)
45
+ end
46
+ @instances = nil
47
+ end
12
48
  end
13
49
 
14
50
  # @api private
15
51
  module Testing
16
52
  class << self
53
+ def store
54
+ @store ||= {}
55
+ end
56
+
57
+ def registered_loaders
58
+ @registered_loaders ||= Set.new
59
+ end
60
+
17
61
  def without_testing
18
62
  original_testing = Appsignal.testing?
19
63
  Appsignal.testing = false
@@ -27,7 +71,9 @@ module Appsignal
27
71
  end
28
72
 
29
73
  def clear!
74
+ store.clear
30
75
  transactions.clear
76
+ registered_loaders.clear
31
77
  end
32
78
 
33
79
  attr_writer :keep_transactions, :sample_transactions
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.11.0
4
+ version: 3.12.0
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: 2024-07-15 00:00:00.000000000 Z
13
+ date: 2024-07-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack
@@ -266,6 +266,11 @@ files:
266
266
  - lib/appsignal/integrations/sinatra.rb
267
267
  - lib/appsignal/integrations/unicorn.rb
268
268
  - lib/appsignal/integrations/webmachine.rb
269
+ - lib/appsignal/loaders.rb
270
+ - lib/appsignal/loaders/grape.rb
271
+ - lib/appsignal/loaders/hanami.rb
272
+ - lib/appsignal/loaders/padrino.rb
273
+ - lib/appsignal/loaders/sinatra.rb
269
274
  - lib/appsignal/logger.rb
270
275
  - lib/appsignal/marker.rb
271
276
  - lib/appsignal/probes.rb
@@ -364,6 +369,7 @@ files:
364
369
  - spec/lib/appsignal/hooks_spec.rb
365
370
  - spec/lib/appsignal/integrations/data_mapper_spec.rb
366
371
  - spec/lib/appsignal/integrations/delayed_job_plugin_spec.rb
372
+ - spec/lib/appsignal/integrations/grape_spec.rb
367
373
  - spec/lib/appsignal/integrations/hanami_spec.rb
368
374
  - spec/lib/appsignal/integrations/http_spec.rb
369
375
  - spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb
@@ -376,6 +382,11 @@ files:
376
382
  - spec/lib/appsignal/integrations/sidekiq_spec.rb
377
383
  - spec/lib/appsignal/integrations/sinatra_spec.rb
378
384
  - spec/lib/appsignal/integrations/webmachine_spec.rb
385
+ - spec/lib/appsignal/loaders/grape_spec.rb
386
+ - spec/lib/appsignal/loaders/hanami_spec.rb
387
+ - spec/lib/appsignal/loaders/padrino_spec.rb
388
+ - spec/lib/appsignal/loaders/sinatra_spec.rb
389
+ - spec/lib/appsignal/loaders_spec.rb
379
390
  - spec/lib/appsignal/logger_spec.rb
380
391
  - spec/lib/appsignal/marker_spec.rb
381
392
  - spec/lib/appsignal/probes/gvl_spec.rb
@@ -427,6 +438,7 @@ files:
427
438
  - spec/support/helpers/environment_metdata_helper.rb
428
439
  - spec/support/helpers/example_exception.rb
429
440
  - spec/support/helpers/example_standard_error.rb
441
+ - spec/support/helpers/loader_helper.rb
430
442
  - spec/support/helpers/log_helpers.rb
431
443
  - spec/support/helpers/rails_helper.rb
432
444
  - spec/support/helpers/std_streams_helper.rb
@@ -444,6 +456,7 @@ files:
444
456
  - spec/support/mocks/mock_probe.rb
445
457
  - spec/support/rails/my_app.rb
446
458
  - spec/support/shared_examples/instrument.rb
459
+ - spec/support/stubs/appsignal/loaders/loader_stub.rb
447
460
  - spec/support/stubs/delayed_job.rb
448
461
  - spec/support/stubs/sidekiq/api.rb
449
462
  - spec/support/testing.rb