appsignal 2.5.0.alpha.1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (211) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +33 -0
  3. data/.rspec +4 -0
  4. data/.rubocop.yml +66 -0
  5. data/.rubocop_todo.yml +124 -0
  6. data/.travis.yml +72 -0
  7. data/.yardopts +8 -0
  8. data/CHANGELOG.md +639 -0
  9. data/Gemfile +3 -0
  10. data/LICENSE +20 -0
  11. data/README.md +264 -0
  12. data/Rakefile +214 -0
  13. data/appsignal.gemspec +42 -0
  14. data/benchmark.rake +77 -0
  15. data/bin/appsignal +13 -0
  16. data/ext/Rakefile +27 -0
  17. data/ext/agent.yml +64 -0
  18. data/ext/appsignal_extension.c +692 -0
  19. data/ext/base.rb +79 -0
  20. data/ext/extconf.rb +35 -0
  21. data/gemfiles/capistrano2.gemfile +7 -0
  22. data/gemfiles/capistrano3.gemfile +7 -0
  23. data/gemfiles/grape.gemfile +7 -0
  24. data/gemfiles/no_dependencies.gemfile +5 -0
  25. data/gemfiles/padrino.gemfile +7 -0
  26. data/gemfiles/que.gemfile +5 -0
  27. data/gemfiles/rails-3.2.gemfile +6 -0
  28. data/gemfiles/rails-4.0.gemfile +6 -0
  29. data/gemfiles/rails-4.1.gemfile +6 -0
  30. data/gemfiles/rails-4.2.gemfile +10 -0
  31. data/gemfiles/rails-5.0.gemfile +5 -0
  32. data/gemfiles/rails-5.1.gemfile +5 -0
  33. data/gemfiles/resque.gemfile +12 -0
  34. data/gemfiles/sequel-435.gemfile +11 -0
  35. data/gemfiles/sequel.gemfile +11 -0
  36. data/gemfiles/sinatra.gemfile +6 -0
  37. data/gemfiles/webmachine.gemfile +5 -0
  38. data/lib/appsignal.rb +804 -0
  39. data/lib/appsignal/auth_check.rb +65 -0
  40. data/lib/appsignal/capistrano.rb +10 -0
  41. data/lib/appsignal/cli.rb +108 -0
  42. data/lib/appsignal/cli/demo.rb +63 -0
  43. data/lib/appsignal/cli/diagnose.rb +500 -0
  44. data/lib/appsignal/cli/helpers.rb +72 -0
  45. data/lib/appsignal/cli/install.rb +277 -0
  46. data/lib/appsignal/cli/notify_of_deploy.rb +113 -0
  47. data/lib/appsignal/config.rb +287 -0
  48. data/lib/appsignal/demo.rb +107 -0
  49. data/lib/appsignal/event_formatter.rb +74 -0
  50. data/lib/appsignal/event_formatter/action_view/render_formatter.rb +24 -0
  51. data/lib/appsignal/event_formatter/active_record/instantiation_formatter.rb +14 -0
  52. data/lib/appsignal/event_formatter/active_record/sql_formatter.rb +14 -0
  53. data/lib/appsignal/event_formatter/elastic_search/search_formatter.rb +32 -0
  54. data/lib/appsignal/event_formatter/faraday/request_formatter.rb +19 -0
  55. data/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter.rb +89 -0
  56. data/lib/appsignal/event_formatter/moped/query_formatter.rb +80 -0
  57. data/lib/appsignal/extension.rb +63 -0
  58. data/lib/appsignal/extension/jruby.rb +460 -0
  59. data/lib/appsignal/garbage_collection_profiler.rb +48 -0
  60. data/lib/appsignal/hooks.rb +105 -0
  61. data/lib/appsignal/hooks/action_cable.rb +113 -0
  62. data/lib/appsignal/hooks/active_support_notifications.rb +52 -0
  63. data/lib/appsignal/hooks/celluloid.rb +30 -0
  64. data/lib/appsignal/hooks/data_mapper.rb +18 -0
  65. data/lib/appsignal/hooks/delayed_job.rb +19 -0
  66. data/lib/appsignal/hooks/mongo_ruby_driver.rb +21 -0
  67. data/lib/appsignal/hooks/net_http.rb +29 -0
  68. data/lib/appsignal/hooks/passenger.rb +22 -0
  69. data/lib/appsignal/hooks/puma.rb +35 -0
  70. data/lib/appsignal/hooks/que.rb +21 -0
  71. data/lib/appsignal/hooks/rake.rb +39 -0
  72. data/lib/appsignal/hooks/redis.rb +30 -0
  73. data/lib/appsignal/hooks/sequel.rb +60 -0
  74. data/lib/appsignal/hooks/shoryuken.rb +43 -0
  75. data/lib/appsignal/hooks/sidekiq.rb +144 -0
  76. data/lib/appsignal/hooks/unicorn.rb +40 -0
  77. data/lib/appsignal/hooks/webmachine.rb +23 -0
  78. data/lib/appsignal/integrations/capistrano/appsignal.cap +39 -0
  79. data/lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb +52 -0
  80. data/lib/appsignal/integrations/data_mapper.rb +33 -0
  81. data/lib/appsignal/integrations/delayed_job_plugin.rb +54 -0
  82. data/lib/appsignal/integrations/grape.rb +53 -0
  83. data/lib/appsignal/integrations/mongo_ruby_driver.rb +55 -0
  84. data/lib/appsignal/integrations/object.rb +35 -0
  85. data/lib/appsignal/integrations/padrino.rb +84 -0
  86. data/lib/appsignal/integrations/que.rb +43 -0
  87. data/lib/appsignal/integrations/railtie.rb +41 -0
  88. data/lib/appsignal/integrations/rake.rb +2 -0
  89. data/lib/appsignal/integrations/resque.rb +20 -0
  90. data/lib/appsignal/integrations/resque_active_job.rb +30 -0
  91. data/lib/appsignal/integrations/sinatra.rb +17 -0
  92. data/lib/appsignal/integrations/webmachine.rb +38 -0
  93. data/lib/appsignal/js_exception_transaction.rb +54 -0
  94. data/lib/appsignal/marker.rb +63 -0
  95. data/lib/appsignal/minutely.rb +42 -0
  96. data/lib/appsignal/rack/generic_instrumentation.rb +49 -0
  97. data/lib/appsignal/rack/js_exception_catcher.rb +70 -0
  98. data/lib/appsignal/rack/rails_instrumentation.rb +51 -0
  99. data/lib/appsignal/rack/sinatra_instrumentation.rb +99 -0
  100. data/lib/appsignal/rack/streaming_listener.rb +73 -0
  101. data/lib/appsignal/system.rb +81 -0
  102. data/lib/appsignal/transaction.rb +498 -0
  103. data/lib/appsignal/transmitter.rb +107 -0
  104. data/lib/appsignal/utils.rb +127 -0
  105. data/lib/appsignal/utils/params_sanitizer.rb +59 -0
  106. data/lib/appsignal/utils/query_params_sanitizer.rb +55 -0
  107. data/lib/appsignal/version.rb +3 -0
  108. data/lib/sequel/extensions/appsignal_integration.rb +3 -0
  109. data/resources/appsignal.yml.erb +39 -0
  110. data/resources/cacert.pem +3866 -0
  111. data/spec/.rubocop.yml +7 -0
  112. data/spec/lib/appsignal/auth_check_spec.rb +80 -0
  113. data/spec/lib/appsignal/capistrano2_spec.rb +224 -0
  114. data/spec/lib/appsignal/capistrano3_spec.rb +237 -0
  115. data/spec/lib/appsignal/cli/demo_spec.rb +67 -0
  116. data/spec/lib/appsignal/cli/diagnose_spec.rb +988 -0
  117. data/spec/lib/appsignal/cli/helpers_spec.rb +171 -0
  118. data/spec/lib/appsignal/cli/install_spec.rb +632 -0
  119. data/spec/lib/appsignal/cli/notify_of_deploy_spec.rb +168 -0
  120. data/spec/lib/appsignal/cli_spec.rb +56 -0
  121. data/spec/lib/appsignal/config_spec.rb +637 -0
  122. data/spec/lib/appsignal/demo_spec.rb +87 -0
  123. data/spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb +44 -0
  124. data/spec/lib/appsignal/event_formatter/active_record/instantiation_formatter_spec.rb +21 -0
  125. data/spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb +21 -0
  126. data/spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb +52 -0
  127. data/spec/lib/appsignal/event_formatter/faraday/request_formatter_spec.rb +21 -0
  128. data/spec/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter_spec.rb +113 -0
  129. data/spec/lib/appsignal/event_formatter/moped/query_formatter_spec.rb +112 -0
  130. data/spec/lib/appsignal/event_formatter_spec.rb +100 -0
  131. data/spec/lib/appsignal/extension/jruby_spec.rb +43 -0
  132. data/spec/lib/appsignal/extension_spec.rb +137 -0
  133. data/spec/lib/appsignal/garbage_collection_profiler_spec.rb +66 -0
  134. data/spec/lib/appsignal/hooks/action_cable_spec.rb +370 -0
  135. data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +92 -0
  136. data/spec/lib/appsignal/hooks/celluloid_spec.rb +35 -0
  137. data/spec/lib/appsignal/hooks/data_mapper_spec.rb +39 -0
  138. data/spec/lib/appsignal/hooks/delayed_job_spec.rb +358 -0
  139. data/spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb +44 -0
  140. data/spec/lib/appsignal/hooks/net_http_spec.rb +53 -0
  141. data/spec/lib/appsignal/hooks/passenger_spec.rb +30 -0
  142. data/spec/lib/appsignal/hooks/puma_spec.rb +80 -0
  143. data/spec/lib/appsignal/hooks/que_spec.rb +19 -0
  144. data/spec/lib/appsignal/hooks/rake_spec.rb +73 -0
  145. data/spec/lib/appsignal/hooks/redis_spec.rb +55 -0
  146. data/spec/lib/appsignal/hooks/sequel_spec.rb +46 -0
  147. data/spec/lib/appsignal/hooks/shoryuken_spec.rb +192 -0
  148. data/spec/lib/appsignal/hooks/sidekiq_spec.rb +419 -0
  149. data/spec/lib/appsignal/hooks/unicorn_spec.rb +52 -0
  150. data/spec/lib/appsignal/hooks/webmachine_spec.rb +35 -0
  151. data/spec/lib/appsignal/hooks_spec.rb +195 -0
  152. data/spec/lib/appsignal/integrations/data_mapper_spec.rb +65 -0
  153. data/spec/lib/appsignal/integrations/grape_spec.rb +225 -0
  154. data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +127 -0
  155. data/spec/lib/appsignal/integrations/object_spec.rb +249 -0
  156. data/spec/lib/appsignal/integrations/padrino_spec.rb +323 -0
  157. data/spec/lib/appsignal/integrations/que_spec.rb +174 -0
  158. data/spec/lib/appsignal/integrations/railtie_spec.rb +129 -0
  159. data/spec/lib/appsignal/integrations/resque_active_job_spec.rb +83 -0
  160. data/spec/lib/appsignal/integrations/resque_spec.rb +92 -0
  161. data/spec/lib/appsignal/integrations/sinatra_spec.rb +73 -0
  162. data/spec/lib/appsignal/integrations/webmachine_spec.rb +69 -0
  163. data/spec/lib/appsignal/js_exception_transaction_spec.rb +128 -0
  164. data/spec/lib/appsignal/marker_spec.rb +51 -0
  165. data/spec/lib/appsignal/minutely_spec.rb +50 -0
  166. data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +90 -0
  167. data/spec/lib/appsignal/rack/js_exception_catcher_spec.rb +147 -0
  168. data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +117 -0
  169. data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +213 -0
  170. data/spec/lib/appsignal/rack/streaming_listener_spec.rb +161 -0
  171. data/spec/lib/appsignal/system_spec.rb +131 -0
  172. data/spec/lib/appsignal/transaction_spec.rb +1146 -0
  173. data/spec/lib/appsignal/transmitter_spec.rb +152 -0
  174. data/spec/lib/appsignal/utils/params_sanitizer_spec.rb +136 -0
  175. data/spec/lib/appsignal/utils/query_params_sanitizer_spec.rb +192 -0
  176. data/spec/lib/appsignal/utils_spec.rb +150 -0
  177. data/spec/lib/appsignal_spec.rb +1049 -0
  178. data/spec/spec_helper.rb +116 -0
  179. data/spec/support/fixtures/containers/cgroups/docker +14 -0
  180. data/spec/support/fixtures/containers/cgroups/docker_systemd +8 -0
  181. data/spec/support/fixtures/containers/cgroups/lxc +10 -0
  182. data/spec/support/fixtures/containers/cgroups/no_permission +0 -0
  183. data/spec/support/fixtures/containers/cgroups/none +1 -0
  184. data/spec/support/fixtures/generated_config.yml +24 -0
  185. data/spec/support/fixtures/uploaded_file.txt +0 -0
  186. data/spec/support/helpers/api_request_helper.rb +19 -0
  187. data/spec/support/helpers/cli_helpers.rb +26 -0
  188. data/spec/support/helpers/config_helpers.rb +21 -0
  189. data/spec/support/helpers/dependency_helper.rb +73 -0
  190. data/spec/support/helpers/directory_helper.rb +27 -0
  191. data/spec/support/helpers/env_helpers.rb +33 -0
  192. data/spec/support/helpers/example_exception.rb +13 -0
  193. data/spec/support/helpers/example_standard_error.rb +13 -0
  194. data/spec/support/helpers/log_helpers.rb +22 -0
  195. data/spec/support/helpers/std_streams_helper.rb +66 -0
  196. data/spec/support/helpers/system_helpers.rb +8 -0
  197. data/spec/support/helpers/time_helpers.rb +11 -0
  198. data/spec/support/helpers/transaction_helpers.rb +37 -0
  199. data/spec/support/matchers/contains_log.rb +7 -0
  200. data/spec/support/mocks/fake_gc_profiler.rb +19 -0
  201. data/spec/support/mocks/mock_extension.rb +6 -0
  202. data/spec/support/project_fixture/config/application.rb +0 -0
  203. data/spec/support/project_fixture/config/appsignal.yml +32 -0
  204. data/spec/support/project_fixture/config/environments/development.rb +0 -0
  205. data/spec/support/project_fixture/config/environments/production.rb +0 -0
  206. data/spec/support/project_fixture/config/environments/test.rb +0 -0
  207. data/spec/support/project_fixture/log/.gitkeep +0 -0
  208. data/spec/support/rails/my_app.rb +6 -0
  209. data/spec/support/shared_examples/instrument.rb +43 -0
  210. data/spec/support/stubs/delayed_job.rb +0 -0
  211. metadata +483 -0
@@ -0,0 +1,116 @@
1
+ ENV["RAILS_ENV"] ||= "test"
2
+ ENV["RACK_ENV"] ||= "test"
3
+ ENV["PADRINO_ENV"] ||= "test"
4
+
5
+ APPSIGNAL_SPEC_DIR = File.expand_path(File.dirname(__FILE__))
6
+ $LOAD_PATH.unshift(File.join(APPSIGNAL_SPEC_DIR, "support/stubs"))
7
+
8
+ Bundler.require :default
9
+ require "cgi"
10
+ require "rack"
11
+ require "rspec"
12
+ require "pry"
13
+ require "timecop"
14
+ require "webmock/rspec"
15
+
16
+ Dir[File.join(APPSIGNAL_SPEC_DIR, "support", "helpers", "*.rb")].each do |f|
17
+ require f
18
+ end
19
+ Dir[File.join(DirectoryHelper.support_dir, "mocks", "*.rb")].each do |f|
20
+ require f
21
+ end
22
+ Dir[File.join(DirectoryHelper.support_dir, "matchers", "*.rb")].each do |f|
23
+ require f
24
+ end
25
+ Dir[File.join(APPSIGNAL_SPEC_DIR, "support/shared_examples", "*.rb")].each do |f|
26
+ require f
27
+ end
28
+ if DependencyHelper.rails_present?
29
+ Dir[File.join(DirectoryHelper.support_dir, "rails", "*.rb")].each do |f|
30
+ require f
31
+ end
32
+ end
33
+ require "appsignal"
34
+
35
+ module Appsignal
36
+ class << self
37
+ remove_method :testing?
38
+
39
+ def testing?
40
+ true
41
+ end
42
+ end
43
+ end
44
+
45
+ puts "Running specs in #{RUBY_VERSION} on #{RUBY_PLATFORM}\n\n"
46
+
47
+ # Add way to clear subscribers between specs
48
+ if defined?(ActiveSupport)
49
+ module ActiveSupport
50
+ module Notifications
51
+ class Fanout
52
+ def clear_subscribers
53
+ @subscribers.clear
54
+ @listeners_for.clear
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+
61
+ RSpec.configure do |config|
62
+ config.include DirectoryHelper
63
+ config.include StdStreamsHelper
64
+ config.include ConfigHelpers
65
+ config.include EnvHelpers
66
+ config.include TimeHelpers
67
+ config.include TransactionHelpers
68
+ config.include ApiRequestHelper
69
+ config.include SystemHelpers
70
+ config.include LogHelpers
71
+ config.extend DependencyHelper
72
+
73
+ config.fail_if_no_examples = true
74
+
75
+ def spec_system_tmp_dir
76
+ File.join(tmp_dir, "system-tmp")
77
+ end
78
+
79
+ config.before :context do
80
+ FileUtils.rm_rf(tmp_dir)
81
+ FileUtils.mkdir_p(spec_system_tmp_dir)
82
+ end
83
+
84
+ config.before do
85
+ ENV["RAILS_ENV"] ||= "test"
86
+ ENV["RACK_ENV"] ||= "test"
87
+ ENV["PADRINO_ENV"] ||= "test"
88
+
89
+ # Clean environment
90
+ appsignal_key_prefixes = %w[APPSIGNAL_ _APPSIGNAL_]
91
+ env_keys = ENV.keys.select { |key| key.start_with?(*appsignal_key_prefixes) }
92
+ env_keys.each do |key|
93
+ # First set the ENV var to an empty string and then delete the key from
94
+ # the env. We set the env var to an empty string first as jRuby doesn't
95
+ # sync `delete` calls to extensions, making our extension think the env
96
+ # var is still set after calling `ENV.delete`. Setting it to an empty
97
+ # string will sort of unset it, our extension ignores env vars with an
98
+ # empty string as a value.
99
+ ENV[key] = ""
100
+ ENV.delete(key)
101
+ end
102
+
103
+ # Stub system_tmp_dir to something in the project dir for specs
104
+ allow(Appsignal::Config).to receive(:system_tmp_dir).and_return(spec_system_tmp_dir)
105
+ end
106
+
107
+ config.after do
108
+ Thread.current[:appsignal_transaction] = nil
109
+ end
110
+
111
+ config.after :context do
112
+ FileUtils.rm_f(File.join(project_fixture_path, "log/appsignal.log"))
113
+ Appsignal.config = nil
114
+ Appsignal.logger = nil
115
+ end
116
+ end
@@ -0,0 +1,14 @@
1
+ 14:name=systemd:/docker/0c703b75cdeaad7c933aa68b4678cc5c37a12d5ef5d7cb52c9cefe684d98e575
2
+ 13:pids:/docker/0c703b75cdeaad7c933aa68b4678cc5c37a12d5ef5d7cb52c9cefe684d98e575
3
+ 12:hugetlb:/docker/0c703b75cdeaad7c933aa68b4678cc5c37a12d5ef5d7cb52c9cefe684d98e575
4
+ 11:net_prio:/docker/0c703b75cdeaad7c933aa68b4678cc5c37a12d5ef5d7cb52c9cefe684d98e575
5
+ 10:perf_event:/docker/0c703b75cdeaad7c933aa68b4678cc5c37a12d5ef5d7cb52c9cefe684d98e575
6
+ 9:net_cls:/docker/0c703b75cdeaad7c933aa68b4678cc5c37a12d5ef5d7cb52c9cefe684d98e575
7
+ 8:freezer:/docker/0c703b75cdeaad7c933aa68b4678cc5c37a12d5ef5d7cb52c9cefe684d98e575
8
+ 7:devices:/docker/0c703b75cdeaad7c933aa68b4678cc5c37a12d5ef5d7cb52c9cefe684d98e575
9
+ 6:memory:/docker/0c703b75cdeaad7c933aa68b4678cc5c37a12d5ef5d7cb52c9cefe684d98e575
10
+ 5:blkio:/docker/0c703b75cdeaad7c933aa68b4678cc5c37a12d5ef5d7cb52c9cefe684d98e575
11
+ 4:cpuacct:/docker/0c703b75cdeaad7c933aa68b4678cc5c37a12d5ef5d7cb52c9cefe684d98e575
12
+ 3:cpu:/docker/0c703b75cdeaad7c933aa68b4678cc5c37a12d5ef5d7cb52c9cefe684d98e575
13
+ 2:cpuset:/docker/0c703b75cdeaad7c933aa68b4678cc5c37a12d5ef5d7cb52c9cefe684d98e575
14
+ 1:name=openrc:/docker
@@ -0,0 +1,8 @@
1
+ 8:net_cls:/system.slice/docker-09f1c4d420025670a3633edbc9b31450f1d6b2ff87b5912a10c320ad398c7215.scope
2
+ 7:freezer:/system.slice/docker-09f1c4d420025670a3633edbc9b31450f1d6b2ff87b5912a10c320ad398c7215.scope
3
+ 6:devices:/system.slice/docker-09f1c4d420025670a3633edbc9b31450f1d6b2ff87b5912a10c320ad398c7215.scope
4
+ 5:memory:/system.slice/docker-09f1c4d420025670a3633edbc9b31450f1d6b2ff87b5912a10c320ad398c7215.scope
5
+ 4:blkio:/system.slice/docker-09f1c4d420025670a3633edbc9b31450f1d6b2ff87b5912a10c320ad398c7215.scope
6
+ 3:cpu,cpuacct:/system.slice/docker-09f1c4d420025670a3633edbc9b31450f1d6b2ff87b5912a10c320ad398c7215.scope
7
+ 2:cpuset:/system.slice/docker-09f1c4d420025670a3633edbc9b31450f1d6b2ff87b5912a10c320ad398c7215.scope
8
+ 1:name=openrc:/system.slice/docker-09f1c4d420025670a3633edbc9b31450f1d6b2ff87b5912a10c320ad398c7215.scope
@@ -0,0 +1,10 @@
1
+ 11:name=systemd:/lxc/1a2e485e-3947-4bb6-8c24-8774f0859648
2
+ 10:hugetlb:/lxc/1a2e485e-3947-4bb6-8c24-8774f0859648
3
+ 9:perf_event:/lxc/1a2e485e-3947-4bb6-8c24-8774f0859648
4
+ 8:blkio:/lxc/1a2e485e-3947-4bb6-8c24-8774f0859648
5
+ 7:freezer:/lxc/1a2e485e-3947-4bb6-8c24-8774f0859648
6
+ 6:devices:/lxc/1a2e485e-3947-4bb6-8c24-8774f0859648
7
+ 5:memory:/lxc/1a2e485e-3947-4bb6-8c24-8774f0859648
8
+ 4:cpuacct:/lxc/1a2e485e-3947-4bb6-8c24-8774f0859648
9
+ 3:cpu:/lxc/1a2e485e-3947-4bb6-8c24-8774f0859648
10
+ 2:cpuset:/lxc/1a2e485e-3947-4bb6-8c24-8774f0859648
@@ -0,0 +1 @@
1
+ 2:name=systemd:/user/0.user/1.session
@@ -0,0 +1,24 @@
1
+ default: &defaults
2
+ # Your push api key, it is possible to set this dynamically using ERB:
3
+ # push_api_key: "<%= ENV['APPSIGNAL_PUSH_API_KEY'] %>"
4
+ push_api_key: "my_app_key"
5
+
6
+ # Your app's name
7
+ name: "MyApp"
8
+
9
+ # The cuttoff point in ms above which a request is considered slow, default is 200
10
+ # slow_request_threshold: 200
11
+
12
+ # Actions that should not be monitored by AppSignal
13
+ # ignore_actions:
14
+ # - ApplicationController#isup
15
+
16
+ # Configuration per environment, leave out an environment or set active
17
+ # to false to not push metrics for that environment.
18
+ development:
19
+ <<: *defaults
20
+ active: true
21
+
22
+ production:
23
+ <<: *defaults
24
+ active: true
@@ -0,0 +1,19 @@
1
+ module ApiRequestHelper
2
+ def stub_api_request(config, path, body = nil)
3
+ options = {
4
+ :query => {
5
+ :api_key => config[:push_api_key],
6
+ :name => config[:name],
7
+ :environment => config.env,
8
+ :hostname => config[:hostname],
9
+ :gem_version => Appsignal::VERSION
10
+ },
11
+ :headers => {
12
+ "Content-Type" => "application/json; charset=UTF-8"
13
+ }
14
+ }
15
+ body = Appsignal::Utils::JSON.generate(body) if body.is_a? Hash
16
+ options[:body] = body if body
17
+ stub_request(:post, "#{config[:endpoint]}/1/#{path}").with(options)
18
+ end
19
+ end
@@ -0,0 +1,26 @@
1
+ module CLIHelpers
2
+ def cli
3
+ Appsignal::CLI
4
+ end
5
+
6
+ def run_cli(command, options = {})
7
+ cli.run(format_cli_arguments_and_options(command, options))
8
+ end
9
+
10
+ def format_cli_arguments_and_options(command, options = {})
11
+ [*command].tap do |o|
12
+ options.each do |key, value|
13
+ o << "--#{key}=#{value}"
14
+ end
15
+ end
16
+ end
17
+
18
+ def set_input(value)
19
+ $stdin.puts value
20
+ end
21
+
22
+ def prepare_input
23
+ # Prepare the input by rewinding the pointer in the StringIO
24
+ $stdin.rewind
25
+ end
26
+ end
@@ -0,0 +1,21 @@
1
+ module ConfigHelpers
2
+ def project_fixture_path
3
+ File.expand_path(
4
+ File.join(File.dirname(__FILE__), "../project_fixture")
5
+ )
6
+ end
7
+
8
+ def project_fixture_config(env = "production", initial_config = {}, logger = Appsignal.logger)
9
+ Appsignal::Config.new(
10
+ project_fixture_path,
11
+ env,
12
+ initial_config,
13
+ logger
14
+ )
15
+ end
16
+
17
+ def start_agent(env = "production")
18
+ Appsignal.config = project_fixture_config(env)
19
+ Appsignal.start
20
+ end
21
+ end
@@ -0,0 +1,73 @@
1
+ module DependencyHelper
2
+ module_function
3
+
4
+ def running_jruby?
5
+ defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
6
+ end
7
+
8
+ def rails_present?
9
+ dependency_present? "rails"
10
+ end
11
+
12
+ def sequel_present?
13
+ dependency_present? "sequel"
14
+ end
15
+
16
+ def resque_present?
17
+ dependency_present? "resque"
18
+ end
19
+
20
+ def redis_present?
21
+ dependency_present? "redis"
22
+ end
23
+
24
+ def action_cable_present?
25
+ dependency_present? "actioncable"
26
+ end
27
+
28
+ def active_job_present?
29
+ dependency_present? "activejob"
30
+ end
31
+
32
+ def active_support_present?
33
+ dependency_present? "activesupport"
34
+ end
35
+
36
+ def sinatra_present?
37
+ dependency_present? "sinatra"
38
+ end
39
+
40
+ def padrino_present?
41
+ dependency_present? "padrino"
42
+ end
43
+
44
+ def grape_present?
45
+ dependency_present? "grape"
46
+ end
47
+
48
+ def webmachine_present?
49
+ dependency_present? "webmachine"
50
+ end
51
+
52
+ def capistrano_present?
53
+ dependency_present? "capistrano"
54
+ end
55
+
56
+ def capistrano2_present?
57
+ capistrano_present? &&
58
+ Gem.loaded_specs["capistrano"].version < Gem::Version.new("3.0")
59
+ end
60
+
61
+ def capistrano3_present?
62
+ capistrano_present? &&
63
+ Gem.loaded_specs["capistrano"].version >= Gem::Version.new("3.0")
64
+ end
65
+
66
+ def que_present?
67
+ dependency_present? "que"
68
+ end
69
+
70
+ def dependency_present?(dependency_file)
71
+ Gem.loaded_specs.key? dependency_file
72
+ end
73
+ end
@@ -0,0 +1,27 @@
1
+ module DirectoryHelper
2
+ module_function
3
+
4
+ def project_dir
5
+ @project_dir ||= File.expand_path("..", spec_dir)
6
+ end
7
+
8
+ def spec_dir
9
+ APPSIGNAL_SPEC_DIR
10
+ end
11
+
12
+ def support_dir
13
+ @support_dir ||= File.join(spec_dir, "support")
14
+ end
15
+
16
+ def tmp_dir
17
+ @tmp_dir ||= File.join(spec_dir, "tmp")
18
+ end
19
+
20
+ def fixtures_dir
21
+ @fixtures_dir ||= File.join(support_dir, "fixtures")
22
+ end
23
+
24
+ def resources_dir
25
+ @resources_dir ||= File.join(project_dir, "resources")
26
+ end
27
+ end
@@ -0,0 +1,33 @@
1
+ module EnvHelpers
2
+ def http_request_env_with_data(args = {})
3
+ path = args.delete(:path) || "/blog"
4
+ Rack::MockRequest.env_for(
5
+ path,
6
+ :params => args[:params] || {
7
+ "controller" => "blog_posts",
8
+ "action" => "show",
9
+ "id" => "1"
10
+ }
11
+ ).merge(
12
+ :controller => "BlogPostsController",
13
+ :action => "show",
14
+ :request_format => "html",
15
+ :request_method => "GET",
16
+ :status => "200",
17
+ :view_runtime => 500,
18
+ :db_runtime => 500,
19
+ :metadata => { :key => "value" }
20
+ ).merge(args)
21
+ end
22
+
23
+ def background_env_with_data(args = {})
24
+ {
25
+ :class => "BackgroundJob",
26
+ :method => "perform",
27
+ :priority => 1,
28
+ :attempts => 0,
29
+ :queue => "default",
30
+ :queue_start => fixed_time - 10.0
31
+ }.merge(args)
32
+ end
33
+ end
@@ -0,0 +1,13 @@
1
+ # This ExampleException is used for throwing Exceptions in specs that are
2
+ # allowed or expected.
3
+ #
4
+ # For example, this error can be thrown to raise an exception in AppSignal's
5
+ # run, which should stop the program and the appsignal gem, but not crash the
6
+ # test suite.
7
+ #
8
+ # There's also {ExampleStandardError}, use this when you need to test against
9
+ # StandardError-level Ruby exceptions.
10
+ #
11
+ # @see ExampleStandardError
12
+ class ExampleException < Exception # rubocop:disable Lint/InheritException
13
+ end
@@ -0,0 +1,13 @@
1
+ # This ExampleStandardError is used for throwing errors in specs that are
2
+ # allowed or expected.
3
+ #
4
+ # For example, this error can be thrown to raise an exception in AppSignal's
5
+ # run, which should stop the program and the appsignal gem, but not crash the
6
+ # test suite.
7
+ #
8
+ # There's also {ExampleException}, use this when you need to test against
9
+ # Exception-level Ruby exceptions.
10
+ #
11
+ # @see ExampleException
12
+ class ExampleStandardError < StandardError
13
+ end
@@ -0,0 +1,22 @@
1
+ module LogHelpers
2
+ def use_logger_with(log)
3
+ Appsignal.logger = test_logger(log)
4
+ yield
5
+ Appsignal.logger = nil
6
+ end
7
+
8
+ def test_logger(log)
9
+ Logger.new(log).tap do |logger|
10
+ logger.formatter =
11
+ proc do |severity, _datetime, _progname, msg|
12
+ # This format is used in the `contains_log` matcher.
13
+ "[#{severity}] #{msg}\n"
14
+ end
15
+ end
16
+ end
17
+
18
+ def log_contents(log)
19
+ log.rewind
20
+ log.read
21
+ end
22
+ end