appsignal 4.0.5 → 4.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (203) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -0
  3. data/Rakefile +9 -9
  4. data/appsignal.gemspec +22 -1
  5. data/build_matrix.yml +2 -1
  6. data/ext/agent.rb +27 -27
  7. data/lib/appsignal/check_in/scheduler.rb +3 -4
  8. data/lib/appsignal/check_in.rb +1 -1
  9. data/lib/appsignal/config.rb +1 -3
  10. data/lib/appsignal/integrations/que.rb +8 -2
  11. data/lib/appsignal/integrations/resque.rb +1 -6
  12. data/lib/appsignal/utils/hash_sanitizer.rb +4 -0
  13. data/lib/appsignal/version.rb +1 -1
  14. metadata +2 -191
  15. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -31
  16. data/.github/ISSUE_TEMPLATE/chore.md +0 -14
  17. data/.github/workflows/ci.yml +0 -3150
  18. data/.github/workflows/create_release_from_tag.yml +0 -62
  19. data/.gitignore +0 -35
  20. data/.gitmodules +0 -3
  21. data/.rspec +0 -4
  22. data/.yardopts +0 -8
  23. data/benchmark.rake +0 -139
  24. data/gemfiles/capistrano2.gemfile +0 -6
  25. data/gemfiles/capistrano3.gemfile +0 -7
  26. data/gemfiles/dry-monitor.gemfile +0 -5
  27. data/gemfiles/grape.gemfile +0 -5
  28. data/gemfiles/hanami-2.0.gemfile +0 -7
  29. data/gemfiles/hanami-2.1.gemfile +0 -7
  30. data/gemfiles/http5.gemfile +0 -5
  31. data/gemfiles/no_dependencies.gemfile +0 -10
  32. data/gemfiles/padrino.gemfile +0 -7
  33. data/gemfiles/psych-3.gemfile +0 -5
  34. data/gemfiles/psych-4.gemfile +0 -5
  35. data/gemfiles/que.gemfile +0 -5
  36. data/gemfiles/rails-6.0.gemfile +0 -10
  37. data/gemfiles/rails-6.1.gemfile +0 -11
  38. data/gemfiles/rails-7.0.gemfile +0 -11
  39. data/gemfiles/rails-7.1.gemfile +0 -11
  40. data/gemfiles/rails-7.2.gemfile +0 -11
  41. data/gemfiles/redis-4.gemfile +0 -5
  42. data/gemfiles/redis-5.gemfile +0 -6
  43. data/gemfiles/resque-2.gemfile +0 -6
  44. data/gemfiles/sequel.gemfile +0 -10
  45. data/gemfiles/sinatra.gemfile +0 -5
  46. data/gemfiles/webmachine1.gemfile +0 -7
  47. data/gemfiles/webmachine2.gemfile +0 -6
  48. data/mono.yml +0 -16
  49. data/spec/.rubocop.yml +0 -7
  50. data/spec/lib/appsignal/auth_check_spec.rb +0 -84
  51. data/spec/lib/appsignal/capistrano2_spec.rb +0 -227
  52. data/spec/lib/appsignal/capistrano3_spec.rb +0 -284
  53. data/spec/lib/appsignal/check_in/cron_spec.rb +0 -202
  54. data/spec/lib/appsignal/check_in/scheduler_spec.rb +0 -443
  55. data/spec/lib/appsignal/cli/demo_spec.rb +0 -46
  56. data/spec/lib/appsignal/cli/diagnose/paths_spec.rb +0 -16
  57. data/spec/lib/appsignal/cli/diagnose/utils_spec.rb +0 -86
  58. data/spec/lib/appsignal/cli/diagnose_spec.rb +0 -1553
  59. data/spec/lib/appsignal/cli/helpers_spec.rb +0 -179
  60. data/spec/lib/appsignal/cli/install_spec.rb +0 -848
  61. data/spec/lib/appsignal/cli_spec.rb +0 -56
  62. data/spec/lib/appsignal/config_spec.rb +0 -1380
  63. data/spec/lib/appsignal/demo_spec.rb +0 -83
  64. data/spec/lib/appsignal/environment_spec.rb +0 -190
  65. data/spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb +0 -60
  66. data/spec/lib/appsignal/event_formatter/active_record/instantiation_formatter_spec.rb +0 -21
  67. data/spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb +0 -21
  68. data/spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb +0 -52
  69. data/spec/lib/appsignal/event_formatter/faraday/request_formatter_spec.rb +0 -21
  70. data/spec/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter_spec.rb +0 -84
  71. data/spec/lib/appsignal/event_formatter/rom/sql_formatter_spec.rb +0 -22
  72. data/spec/lib/appsignal/event_formatter/sequel/sql_formatter_spec.rb +0 -30
  73. data/spec/lib/appsignal/event_formatter/view_component/render_formatter_spec.rb +0 -41
  74. data/spec/lib/appsignal/event_formatter_spec.rb +0 -193
  75. data/spec/lib/appsignal/extension/jruby_spec.rb +0 -46
  76. data/spec/lib/appsignal/extension_install_failure_spec.rb +0 -20
  77. data/spec/lib/appsignal/extension_spec.rb +0 -178
  78. data/spec/lib/appsignal/garbage_collection_spec.rb +0 -98
  79. data/spec/lib/appsignal/hooks/action_cable_spec.rb +0 -345
  80. data/spec/lib/appsignal/hooks/action_mailer_spec.rb +0 -55
  81. data/spec/lib/appsignal/hooks/active_support_notifications/finish_with_state_shared_examples.rb +0 -23
  82. data/spec/lib/appsignal/hooks/active_support_notifications/instrument_shared_examples.rb +0 -99
  83. data/spec/lib/appsignal/hooks/active_support_notifications/start_finish_shared_examples.rb +0 -47
  84. data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +0 -47
  85. data/spec/lib/appsignal/hooks/activejob_spec.rb +0 -650
  86. data/spec/lib/appsignal/hooks/at_exit_spec.rb +0 -105
  87. data/spec/lib/appsignal/hooks/celluloid_spec.rb +0 -40
  88. data/spec/lib/appsignal/hooks/data_mapper_spec.rb +0 -40
  89. data/spec/lib/appsignal/hooks/delayed_job_spec.rb +0 -38
  90. data/spec/lib/appsignal/hooks/dry_monitor_spec.rb +0 -83
  91. data/spec/lib/appsignal/hooks/excon_spec.rb +0 -67
  92. data/spec/lib/appsignal/hooks/gvl_spec.rb +0 -145
  93. data/spec/lib/appsignal/hooks/http_spec.rb +0 -37
  94. data/spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb +0 -46
  95. data/spec/lib/appsignal/hooks/mri_spec.rb +0 -23
  96. data/spec/lib/appsignal/hooks/net_http_spec.rb +0 -18
  97. data/spec/lib/appsignal/hooks/passenger_spec.rb +0 -30
  98. data/spec/lib/appsignal/hooks/puma_spec.rb +0 -80
  99. data/spec/lib/appsignal/hooks/que_spec.rb +0 -19
  100. data/spec/lib/appsignal/hooks/rake_spec.rb +0 -144
  101. data/spec/lib/appsignal/hooks/redis_client_spec.rb +0 -218
  102. data/spec/lib/appsignal/hooks/redis_spec.rb +0 -124
  103. data/spec/lib/appsignal/hooks/resque_spec.rb +0 -27
  104. data/spec/lib/appsignal/hooks/sequel_spec.rb +0 -44
  105. data/spec/lib/appsignal/hooks/shoryuken_spec.rb +0 -29
  106. data/spec/lib/appsignal/hooks/sidekiq_spec.rb +0 -115
  107. data/spec/lib/appsignal/hooks/unicorn_spec.rb +0 -63
  108. data/spec/lib/appsignal/hooks/webmachine_spec.rb +0 -24
  109. data/spec/lib/appsignal/hooks_spec.rb +0 -124
  110. data/spec/lib/appsignal/integrations/data_mapper_spec.rb +0 -74
  111. data/spec/lib/appsignal/integrations/delayed_job_plugin_spec.rb +0 -454
  112. data/spec/lib/appsignal/integrations/http_spec.rb +0 -111
  113. data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +0 -154
  114. data/spec/lib/appsignal/integrations/net_http_spec.rb +0 -33
  115. data/spec/lib/appsignal/integrations/object_spec.rb +0 -347
  116. data/spec/lib/appsignal/integrations/puma_spec.rb +0 -150
  117. data/spec/lib/appsignal/integrations/que_spec.rb +0 -152
  118. data/spec/lib/appsignal/integrations/railtie_spec.rb +0 -457
  119. data/spec/lib/appsignal/integrations/resque_spec.rb +0 -155
  120. data/spec/lib/appsignal/integrations/shoryuken_spec.rb +0 -165
  121. data/spec/lib/appsignal/integrations/sidekiq_spec.rb +0 -640
  122. data/spec/lib/appsignal/integrations/webmachine_spec.rb +0 -136
  123. data/spec/lib/appsignal/loaders/grape_spec.rb +0 -12
  124. data/spec/lib/appsignal/loaders/hanami_spec.rb +0 -92
  125. data/spec/lib/appsignal/loaders/padrino_spec.rb +0 -273
  126. data/spec/lib/appsignal/loaders/sinatra_spec.rb +0 -44
  127. data/spec/lib/appsignal/loaders_spec.rb +0 -144
  128. data/spec/lib/appsignal/logger_spec.rb +0 -205
  129. data/spec/lib/appsignal/marker_spec.rb +0 -51
  130. data/spec/lib/appsignal/probes/gvl_spec.rb +0 -164
  131. data/spec/lib/appsignal/probes/mri_spec.rb +0 -162
  132. data/spec/lib/appsignal/probes/sidekiq_spec.rb +0 -333
  133. data/spec/lib/appsignal/probes_spec.rb +0 -411
  134. data/spec/lib/appsignal/rack/abstract_middleware_spec.rb +0 -370
  135. data/spec/lib/appsignal/rack/body_wrapper_spec.rb +0 -319
  136. data/spec/lib/appsignal/rack/event_handler_spec.rb +0 -441
  137. data/spec/lib/appsignal/rack/grape_middleware_spec.rb +0 -201
  138. data/spec/lib/appsignal/rack/hanami_middleware_spec.rb +0 -36
  139. data/spec/lib/appsignal/rack/instrumentation_middleware_spec.rb +0 -38
  140. data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +0 -126
  141. data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +0 -217
  142. data/spec/lib/appsignal/rack_spec.rb +0 -243
  143. data/spec/lib/appsignal/sample_data_spec.rb +0 -238
  144. data/spec/lib/appsignal/span_spec.rb +0 -141
  145. data/spec/lib/appsignal/system_spec.rb +0 -126
  146. data/spec/lib/appsignal/transaction_spec.rb +0 -2111
  147. data/spec/lib/appsignal/transmitter_spec.rb +0 -198
  148. data/spec/lib/appsignal/utils/data_spec.rb +0 -166
  149. data/spec/lib/appsignal/utils/hash_sanitizer_spec.rb +0 -182
  150. data/spec/lib/appsignal/utils/integration_logger_spec.rb +0 -21
  151. data/spec/lib/appsignal/utils/integration_memory_logger_spec.rb +0 -153
  152. data/spec/lib/appsignal/utils/json_spec.rb +0 -44
  153. data/spec/lib/appsignal/utils/query_params_sanitizer_spec.rb +0 -192
  154. data/spec/lib/appsignal_spec.rb +0 -1919
  155. data/spec/lib/puma/appsignal_spec.rb +0 -334
  156. data/spec/spec_helper.rb +0 -173
  157. data/spec/support/fixtures/generated_config.yml +0 -24
  158. data/spec/support/fixtures/projects/broken/config/appsignal.yml +0 -1
  159. data/spec/support/fixtures/projects/valid/config/appsignal.yml +0 -57
  160. data/spec/support/fixtures/projects/valid/log/.gitkeep +0 -0
  161. data/spec/support/fixtures/projects/valid_with_rails_app/config/application.rb +0 -16
  162. data/spec/support/fixtures/projects/valid_with_rails_app/config/appsignal.yml +0 -56
  163. data/spec/support/fixtures/projects/valid_with_rails_app/config/environment.rb +0 -10
  164. data/spec/support/fixtures/projects/valid_with_rails_app/log/.gitkeep +0 -0
  165. data/spec/support/fixtures/uploaded_file.txt +0 -0
  166. data/spec/support/hanami/hanami_app.rb +0 -29
  167. data/spec/support/helpers/action_mailer_helpers.rb +0 -25
  168. data/spec/support/helpers/activejob_helpers.rb +0 -27
  169. data/spec/support/helpers/api_request_helper.rb +0 -20
  170. data/spec/support/helpers/cli_helpers.rb +0 -40
  171. data/spec/support/helpers/config_helpers.rb +0 -66
  172. data/spec/support/helpers/dependency_helper.rb +0 -150
  173. data/spec/support/helpers/directory_helper.rb +0 -27
  174. data/spec/support/helpers/env_helpers.rb +0 -41
  175. data/spec/support/helpers/environment_metdata_helper.rb +0 -16
  176. data/spec/support/helpers/example_exception.rb +0 -13
  177. data/spec/support/helpers/example_standard_error.rb +0 -13
  178. data/spec/support/helpers/loader_helper.rb +0 -21
  179. data/spec/support/helpers/log_helpers.rb +0 -36
  180. data/spec/support/helpers/rails_helper.rb +0 -28
  181. data/spec/support/helpers/std_streams_helper.rb +0 -94
  182. data/spec/support/helpers/system_helpers.rb +0 -8
  183. data/spec/support/helpers/take_at_most_helper.rb +0 -21
  184. data/spec/support/helpers/time_helpers.rb +0 -11
  185. data/spec/support/helpers/transaction_helpers.rb +0 -122
  186. data/spec/support/helpers/wait_for_helper.rb +0 -39
  187. data/spec/support/matchers/contains_log.rb +0 -26
  188. data/spec/support/matchers/have_colorized_text.rb +0 -28
  189. data/spec/support/matchers/transaction.rb +0 -200
  190. data/spec/support/mocks/appsignal_mock.rb +0 -18
  191. data/spec/support/mocks/dummy_app.rb +0 -20
  192. data/spec/support/mocks/fake_gc_profiler.rb +0 -19
  193. data/spec/support/mocks/fake_gvl_tools.rb +0 -28
  194. data/spec/support/mocks/hash_like.rb +0 -10
  195. data/spec/support/mocks/mock_probe.rb +0 -13
  196. data/spec/support/mocks/puma_mock.rb +0 -43
  197. data/spec/support/shared_examples/instrument.rb +0 -48
  198. data/spec/support/stubs/appsignal/loaders/loader_stub.rb +0 -7
  199. data/spec/support/stubs/delayed_job.rb +0 -0
  200. data/spec/support/stubs/sidekiq/api.rb +0 -4
  201. data/spec/support/testing.rb +0 -194
  202. data/support/bundler_wrapper +0 -12
  203. data/support/install_deps +0 -33
@@ -1,115 +0,0 @@
1
- describe Appsignal::Hooks::SidekiqHook do
2
- describe "#dependencies_present?" do
3
- subject { described_class.new.dependencies_present? }
4
-
5
- context "when Sidekiq constant is found" do
6
- before { stub_const "Sidekiq", Class.new }
7
-
8
- it { is_expected.to be_truthy }
9
- end
10
-
11
- context "when Sidekiq constant is not found" do
12
- before { hide_const "Sidekiq" }
13
-
14
- it { is_expected.to be_falsy }
15
- end
16
- end
17
-
18
- describe "#install" do
19
- class SidekiqMiddlewareMockWithPrepend < Array
20
- alias add <<
21
- alias exists? include?
22
-
23
- unless method_defined? :prepend
24
- # For Ruby < 2.5
25
- def prepend(middleware)
26
- insert(0, middleware)
27
- end
28
- end
29
- end
30
-
31
- class SidekiqMiddlewareMockWithoutPrepend < Array
32
- alias add <<
33
- alias exists? include?
34
-
35
- undef_method :prepend if method_defined? :prepend # For Ruby >= 2.5
36
- end
37
-
38
- module SidekiqMock
39
- def self.middleware_mock=(mock)
40
- @middlewares = mock.new
41
- end
42
-
43
- def self.middlewares
44
- @middlewares
45
- end
46
-
47
- def self.configure_server
48
- yield self
49
- end
50
-
51
- def self.server_middleware
52
- yield middlewares if block_given?
53
- middlewares
54
- end
55
-
56
- def self.error_handlers
57
- @error_handlers ||= []
58
- end
59
- end
60
-
61
- def add_middleware(middleware)
62
- Sidekiq.configure_server do |sidekiq_config|
63
- sidekiq_config.middlewares.add(middleware)
64
- end
65
- end
66
-
67
- before do
68
- start_agent
69
- stub_const "Sidekiq", SidekiqMock
70
- end
71
-
72
- it "adds error handler" do
73
- Sidekiq.middleware_mock = SidekiqMiddlewareMockWithPrepend
74
- described_class.new.install
75
- expect(Sidekiq.error_handlers).to include(Appsignal::Integrations::SidekiqErrorHandler)
76
- end
77
-
78
- context "when Sidekiq middleware responds to prepend method" do # Sidekiq 3.3.0 and newer
79
- before { Sidekiq.middleware_mock = SidekiqMiddlewareMockWithPrepend }
80
-
81
- it "adds the AppSignal SidekiqPlugin to the Sidekiq middleware chain in the first position" do
82
- user_middleware1 = proc {}
83
- add_middleware(user_middleware1)
84
- described_class.new.install
85
- user_middleware2 = proc {}
86
- add_middleware(user_middleware2)
87
-
88
- expect(Sidekiq.server_middleware).to eql([
89
- Appsignal::Integrations::SidekiqMiddleware, # Prepend makes it the first entry
90
- user_middleware1,
91
- user_middleware2
92
- ])
93
- end
94
- end
95
-
96
- context "when Sidekiq middleware does not respond to prepend method" do
97
- before { Sidekiq.middleware_mock = SidekiqMiddlewareMockWithoutPrepend }
98
-
99
- it "adds the AppSignal SidekiqPlugin to the Sidekiq middleware chain" do
100
- user_middleware1 = proc {}
101
- add_middleware(user_middleware1)
102
- described_class.new.install
103
- user_middleware2 = proc {}
104
- add_middleware(user_middleware2)
105
-
106
- # Add middlewares in whatever order they were added
107
- expect(Sidekiq.server_middleware).to eql([
108
- user_middleware1,
109
- Appsignal::Integrations::SidekiqMiddleware,
110
- user_middleware2
111
- ])
112
- end
113
- end
114
- end
115
- end
@@ -1,63 +0,0 @@
1
- describe Appsignal::Hooks::UnicornHook do
2
- context "with unicorn" do
3
- before :context do
4
- module Unicorn
5
- class HttpServer
6
- def worker_loop(_worker)
7
- @worker_loop = true
8
- end
9
-
10
- def worker_loop?
11
- @worker_loop == true
12
- end
13
- end
14
-
15
- class Worker
16
- def close
17
- @close = true
18
- end
19
-
20
- def close?
21
- @close == true
22
- end
23
- end
24
- end
25
- Appsignal::Hooks::UnicornHook.new.install
26
- end
27
- after(:context) { Object.send(:remove_const, :Unicorn) }
28
-
29
- describe "#dependencies_present?" do
30
- subject { described_class.new.dependencies_present? }
31
-
32
- it { is_expected.to be_truthy }
33
- end
34
-
35
- it "adds behavior to Unicorn::HttpServer#worker_loop" do
36
- server = Unicorn::HttpServer.new
37
- worker = double
38
-
39
- expect(Appsignal).to receive(:forked)
40
-
41
- server.worker_loop(worker)
42
-
43
- expect(server.worker_loop?).to be true
44
- end
45
-
46
- it "adds behavior to Unicorn::Worker#close" do
47
- worker = Unicorn::Worker.new
48
-
49
- expect(Appsignal).to receive(:stop)
50
-
51
- worker.close
52
- expect(worker.close?).to be true
53
- end
54
- end
55
-
56
- context "without unicorn" do
57
- describe "#dependencies_present?" do
58
- subject { described_class.new.dependencies_present? }
59
-
60
- it { is_expected.to be_falsy }
61
- end
62
- end
63
- end
@@ -1,24 +0,0 @@
1
- describe Appsignal::Hooks::WebmachineHook do
2
- if DependencyHelper.webmachine_present?
3
- context "with webmachine" do
4
- let(:fsm) { Webmachine::Decision::FSM.new(double(:trace? => false), double, double) }
5
- before { start_agent }
6
-
7
- describe "#dependencies_present?" do
8
- subject { described_class.new.dependencies_present? }
9
-
10
- it { is_expected.to be_truthy }
11
- end
12
-
13
- it "adds behavior to Webmachine::Decision::FSM" do
14
- expect(fsm.class.ancestors.first).to eq(Appsignal::Integrations::WebmachineIntegration)
15
- end
16
- end
17
- else
18
- describe "#dependencies_present?" do
19
- subject { described_class.new.dependencies_present? }
20
-
21
- it { is_expected.to be_falsy }
22
- end
23
- end
24
- end
@@ -1,124 +0,0 @@
1
- class MockPresentHook < Appsignal::Hooks::Hook
2
- def dependencies_present?
3
- true
4
- end
5
-
6
- def install
7
- MockPresentHook.call_something
8
- end
9
-
10
- def self.call_something
11
- end
12
- end
13
-
14
- class MockNotPresentHook < Appsignal::Hooks::Hook
15
- def dependencies_present?
16
- false
17
- end
18
-
19
- def install
20
- MockNotPresentHook.call_something
21
- end
22
- end
23
-
24
- class MockErrorHook < Appsignal::Hooks::Hook
25
- def dependencies_present?
26
- true
27
- end
28
-
29
- def install
30
- raise "error"
31
- end
32
- end
33
-
34
- describe Appsignal::Hooks do
35
- it "should register and install a hook once" do
36
- Appsignal::Hooks::Hook.register(:mock_present_hook, MockPresentHook)
37
-
38
- expect(Appsignal::Hooks.hooks[:mock_present_hook]).to be_instance_of(MockPresentHook)
39
- expect(Appsignal::Hooks.hooks[:mock_present_hook].installed?).to be_falsy
40
-
41
- expect(MockPresentHook).to receive(:call_something).once
42
-
43
- Appsignal::Hooks.load_hooks
44
- Appsignal::Hooks.load_hooks
45
- Appsignal::Hooks.load_hooks
46
- expect(Appsignal::Hooks.hooks[:mock_present_hook].installed?).to be_truthy
47
- Appsignal::Hooks.hooks.delete(:mock_present_hook)
48
- end
49
-
50
- it "should not install if dependencies are not present" do
51
- Appsignal::Hooks::Hook.register(:mock_not_present_hook, MockNotPresentHook)
52
-
53
- expect(Appsignal::Hooks.hooks[:mock_not_present_hook]).to be_instance_of(MockNotPresentHook)
54
- expect(Appsignal::Hooks.hooks[:mock_not_present_hook].installed?).to be_falsy
55
-
56
- expect(MockPresentHook).to_not receive(:call_something)
57
-
58
- Appsignal::Hooks.load_hooks
59
-
60
- expect(Appsignal::Hooks.hooks[:mock_not_present_hook].installed?).to be_falsy
61
- Appsignal::Hooks.hooks.delete(:mock_not_present_hook)
62
- end
63
-
64
- it "should not install if there is an error while installing" do
65
- Appsignal::Hooks::Hook.register(:mock_error_hook, MockErrorHook)
66
-
67
- expect(Appsignal::Hooks.hooks[:mock_error_hook]).to be_instance_of(MockErrorHook)
68
- expect(Appsignal::Hooks.hooks[:mock_error_hook].installed?).to be_falsy
69
-
70
- expect(Appsignal.internal_logger).to receive(:error)
71
- .with("Error while installing mock_error_hook hook: error").once
72
- expect(Appsignal.internal_logger).to receive(:debug).ordered do |message|
73
- expect(message).to eq("Installing mock_error_hook hook")
74
- end
75
- expect(Appsignal.internal_logger).to receive(:debug).ordered do |message|
76
- # Start of the error backtrace as debug log
77
- expect(message).to start_with(File.expand_path("../../..", __dir__))
78
- end
79
-
80
- Appsignal::Hooks.load_hooks
81
-
82
- expect(Appsignal::Hooks.hooks[:mock_error_hook].installed?).to be_falsy
83
- Appsignal::Hooks.hooks.delete(:mock_error_hook)
84
- end
85
- end
86
-
87
- describe Appsignal::Hooks::Helpers do
88
- class ClassWithHelpers
89
- include Appsignal::Hooks::Helpers
90
- end
91
- let(:with_helpers) { ClassWithHelpers.new }
92
-
93
- describe "#truncate" do
94
- let(:very_long_text) do
95
- "a" * 400
96
- end
97
-
98
- it "should truncate the text to 200 chars max" do
99
- expect(with_helpers.truncate(very_long_text)).to eq "#{"a" * 197}..."
100
- end
101
- end
102
-
103
- describe "#string_or_inspect" do
104
- context "when string" do
105
- it "should return the string" do
106
- expect(with_helpers.string_or_inspect("foo")).to eq "foo"
107
- end
108
- end
109
-
110
- context "when integer" do
111
- it "should return the string" do
112
- expect(with_helpers.string_or_inspect(1)).to eq "1"
113
- end
114
- end
115
-
116
- context "when object" do
117
- let(:object) { Object.new }
118
-
119
- it "should return the string" do
120
- expect(with_helpers.string_or_inspect(object)).to eq object.inspect
121
- end
122
- end
123
- end
124
- end
@@ -1,74 +0,0 @@
1
- require "appsignal/integrations/data_mapper"
2
-
3
- describe Appsignal::Hooks::DataMapperLogListener do
4
- module DataMapperLog
5
- def log(message)
6
- end
7
- end
8
-
9
- describe "#log" do
10
- let(:transaction) { http_request_transaction }
11
- let(:message) do
12
- double(
13
- :query => "SELECT * from users",
14
- :duration => 100_000_000 # nanoseconds
15
- )
16
- end
17
- let(:connection_class) do
18
- module DataObjects
19
- module Sqlite3
20
- class Connection
21
- include DataMapperLog
22
- include Appsignal::Hooks::DataMapperLogListener
23
- end
24
- end
25
- end
26
- end
27
- before do
28
- start_agent
29
- set_current_transaction(transaction)
30
- end
31
- around { |example| keep_transactions { example.run } }
32
-
33
- def log_message
34
- connection_class.new.log(message)
35
- end
36
-
37
- it "records the log entry in an event" do
38
- log_message
39
-
40
- expect(transaction).to include_event(
41
- "name" => "query.data_mapper",
42
- "title" => "DataMapper Query",
43
- "body" => "SELECT * from users",
44
- "body_format" => Appsignal::EventFormatter::SQL_BODY_FORMAT,
45
- "duration" => 100.0
46
- )
47
- end
48
-
49
- context "when the scheme is not sql-like" do
50
- let(:connection_class) do
51
- module DataObjects
52
- module MongoDB
53
- class Connection
54
- include DataMapperLog
55
- include Appsignal::Hooks::DataMapperLogListener
56
- end
57
- end
58
- end
59
- end
60
-
61
- it "records the log entry in an event without body" do
62
- log_message
63
-
64
- expect(transaction).to include_event(
65
- "name" => "query.data_mapper",
66
- "title" => "DataMapper Query",
67
- "body" => "",
68
- "body_format" => Appsignal::EventFormatter::DEFAULT,
69
- "duration" => 100.0
70
- )
71
- end
72
- end
73
- end
74
- end