appsignal 3.13.1-java → 4.0.0.beta.1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +499 -487
  3. data/CHANGELOG.md +104 -7
  4. data/Rakefile +31 -7
  5. data/benchmark.rake +4 -6
  6. data/build_matrix.yml +45 -39
  7. data/ext/agent.rb +27 -27
  8. data/ext/appsignal_extension.c +25 -0
  9. data/gemfiles/rails-7.2.gemfile +11 -0
  10. data/lib/appsignal/check_in/cron.rb +2 -15
  11. data/lib/appsignal/cli/diagnose.rb +37 -28
  12. data/lib/appsignal/cli/install.rb +5 -1
  13. data/lib/appsignal/config.rb +57 -119
  14. data/lib/appsignal/demo.rb +2 -2
  15. data/lib/appsignal/extension/jruby.rb +14 -0
  16. data/lib/appsignal/helpers/instrumentation.rb +139 -417
  17. data/lib/appsignal/helpers/metrics.rb +0 -16
  18. data/lib/appsignal/hooks/action_cable.rb +8 -8
  19. data/lib/appsignal/hooks/active_job.rb +2 -2
  20. data/lib/appsignal/hooks/at_exit.rb +37 -0
  21. data/lib/appsignal/hooks.rb +1 -16
  22. data/lib/appsignal/integrations/action_cable.rb +2 -2
  23. data/lib/appsignal/integrations/capistrano/appsignal.cap +2 -4
  24. data/lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb +1 -4
  25. data/lib/appsignal/integrations/delayed_job_plugin.rb +3 -3
  26. data/lib/appsignal/integrations/que.rb +2 -2
  27. data/lib/appsignal/integrations/railtie.rb +26 -59
  28. data/lib/appsignal/integrations/rake.rb +2 -2
  29. data/lib/appsignal/integrations/resque.rb +2 -2
  30. data/lib/appsignal/integrations/shoryuken.rb +4 -4
  31. data/lib/appsignal/integrations/sidekiq.rb +3 -3
  32. data/lib/appsignal/integrations/webmachine.rb +2 -2
  33. data/lib/appsignal/loaders.rb +1 -1
  34. data/lib/appsignal/probes.rb +0 -9
  35. data/lib/appsignal/rack/abstract_middleware.rb +4 -26
  36. data/lib/appsignal/rack/body_wrapper.rb +0 -12
  37. data/lib/appsignal/rack/event_handler.rb +4 -4
  38. data/lib/appsignal/rack/rails_instrumentation.rb +1 -1
  39. data/lib/appsignal/rack.rb +0 -25
  40. data/lib/appsignal/sample_data.rb +95 -0
  41. data/lib/appsignal/transaction.rb +235 -361
  42. data/lib/appsignal/utils/rails_helper.rb +4 -0
  43. data/lib/appsignal/version.rb +1 -1
  44. data/lib/appsignal.rb +19 -71
  45. data/spec/lib/appsignal/auth_check_spec.rb +1 -1
  46. data/spec/lib/appsignal/capistrano2_spec.rb +1 -1
  47. data/spec/lib/appsignal/capistrano3_spec.rb +53 -13
  48. data/spec/lib/appsignal/check_in_spec.rb +1 -207
  49. data/spec/lib/appsignal/cli/demo_spec.rb +7 -27
  50. data/spec/lib/appsignal/cli/diagnose_spec.rb +145 -110
  51. data/spec/lib/appsignal/config_spec.rb +304 -379
  52. data/spec/lib/appsignal/extension_install_failure_spec.rb +5 -1
  53. data/spec/lib/appsignal/extension_spec.rb +5 -1
  54. data/spec/lib/appsignal/hooks/active_support_notifications/instrument_shared_examples.rb +1 -1
  55. data/spec/lib/appsignal/hooks/active_support_notifications/start_finish_shared_examples.rb +1 -2
  56. data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +1 -0
  57. data/spec/lib/appsignal/hooks/activejob_spec.rb +7 -12
  58. data/spec/lib/appsignal/hooks/at_exit_spec.rb +72 -0
  59. data/spec/lib/appsignal/hooks/gvl_spec.rb +10 -5
  60. data/spec/lib/appsignal/hooks/http_spec.rb +3 -3
  61. data/spec/lib/appsignal/hooks/net_http_spec.rb +3 -3
  62. data/spec/lib/appsignal/hooks/rake_spec.rb +6 -9
  63. data/spec/lib/appsignal/hooks/redis_client_spec.rb +5 -10
  64. data/spec/lib/appsignal/hooks/redis_spec.rb +4 -7
  65. data/spec/lib/appsignal/hooks/resque_spec.rb +3 -5
  66. data/spec/lib/appsignal/hooks_spec.rb +0 -41
  67. data/spec/lib/appsignal/integrations/data_mapper_spec.rb +29 -20
  68. data/spec/lib/appsignal/integrations/delayed_job_plugin_spec.rb +4 -9
  69. data/spec/lib/appsignal/integrations/railtie_spec.rb +179 -157
  70. data/spec/lib/appsignal/integrations/shoryuken_spec.rb +3 -5
  71. data/spec/lib/appsignal/integrations/sidekiq_spec.rb +48 -62
  72. data/spec/lib/appsignal/loaders/hanami_spec.rb +6 -9
  73. data/spec/lib/appsignal/loaders/padrino_spec.rb +6 -10
  74. data/spec/lib/appsignal/loaders/sinatra_spec.rb +6 -9
  75. data/spec/lib/appsignal/loaders_spec.rb +8 -1
  76. data/spec/lib/appsignal/marker_spec.rb +1 -1
  77. data/spec/lib/appsignal/probes_spec.rb +4 -83
  78. data/spec/lib/appsignal/rack/abstract_middleware_spec.rb +4 -63
  79. data/spec/lib/appsignal/rack/body_wrapper_spec.rb +0 -48
  80. data/spec/lib/appsignal/rack/event_handler_spec.rb +18 -15
  81. data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +3 -11
  82. data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +4 -5
  83. data/spec/lib/appsignal/sample_data_spec.rb +174 -0
  84. data/spec/lib/appsignal/transaction_spec.rb +791 -1031
  85. data/spec/lib/appsignal/transmitter_spec.rb +6 -8
  86. data/spec/lib/appsignal_spec.rb +294 -643
  87. data/spec/spec_helper.rb +1 -3
  88. data/spec/support/fixtures/projects/valid/config/appsignal.yml +4 -7
  89. data/spec/support/fixtures/projects/valid_with_rails_app/config/application.rb +16 -0
  90. data/spec/support/fixtures/projects/valid_with_rails_app/config/appsignal.yml +56 -0
  91. data/spec/support/fixtures/projects/valid_with_rails_app/config/environment.rb +5 -0
  92. data/spec/support/helpers/api_request_helper.rb +3 -2
  93. data/spec/support/helpers/config_helpers.rb +41 -11
  94. data/spec/support/helpers/dependency_helper.rb +8 -0
  95. data/spec/support/helpers/log_helpers.rb +1 -0
  96. data/spec/support/helpers/rails_helper.rb +6 -6
  97. data/spec/support/helpers/transaction_helpers.rb +2 -24
  98. data/spec/support/matchers/transaction.rb +3 -3
  99. data/spec/support/mocks/appsignal_mock.rb +3 -3
  100. data/spec/support/mocks/mock_probe.rb +2 -0
  101. data/spec/support/testing.rb +2 -2
  102. metadata +11 -21
  103. data/gemfiles/que_beta.gemfile +0 -5
  104. data/lib/appsignal/helpers/heartbeat.rb +0 -20
  105. data/lib/appsignal/integrations/grape.rb +0 -35
  106. data/lib/appsignal/integrations/hanami.rb +0 -13
  107. data/lib/appsignal/integrations/padrino.rb +0 -13
  108. data/lib/appsignal/integrations/sinatra.rb +0 -13
  109. data/lib/appsignal/rack/generic_instrumentation.rb +0 -22
  110. data/lib/appsignal/rack/streaming_listener.rb +0 -28
  111. data/spec/lib/appsignal/integrations/grape_spec.rb +0 -36
  112. data/spec/lib/appsignal/integrations/hanami_spec.rb +0 -17
  113. data/spec/lib/appsignal/integrations/padrino_spec.rb +0 -15
  114. data/spec/lib/appsignal/integrations/sinatra_spec.rb +0 -15
  115. data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +0 -81
  116. data/spec/lib/appsignal/rack/streaming_listener_spec.rb +0 -69
  117. data/spec/support/fixtures/projects/valid/config/environments/development.rb +0 -0
  118. data/spec/support/fixtures/projects/valid/config/environments/production.rb +0 -0
  119. data/spec/support/fixtures/projects/valid/config/environments/test.rb +0 -0
  120. data/spec/support/rails/my_app.rb +0 -6
  121. /data/spec/support/fixtures/projects/{valid/config/application.rb → valid_with_rails_app/log/.gitkeep} +0 -0
@@ -15,6 +15,10 @@ module Appsignal
15
15
  def self.application_config_path
16
16
  File.expand_path(File.join(Dir.pwd, "config/application.rb"))
17
17
  end
18
+
19
+ def self.environment_config_path
20
+ File.expand_path(File.join(Dir.pwd, "config/environment.rb"))
21
+ end
18
22
  end
19
23
  end
20
24
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Appsignal
4
- VERSION = "3.13.1"
4
+ VERSION = "4.0.0.beta.1"
5
5
  end
data/lib/appsignal.rb CHANGED
@@ -6,7 +6,6 @@ require "stringio"
6
6
 
7
7
  require "appsignal/logger"
8
8
  require "appsignal/utils/stdout_and_logger_message"
9
- require "appsignal/helpers/heartbeat"
10
9
  require "appsignal/helpers/instrumentation"
11
10
  require "appsignal/helpers/metrics"
12
11
 
@@ -18,7 +17,6 @@ require "appsignal/helpers/metrics"
18
17
  # {Appsignal::Helpers::Metrics}) for ease of use.
19
18
  module Appsignal
20
19
  class << self
21
- include Helpers::Heartbeat
22
20
  include Helpers::Instrumentation
23
21
  include Helpers::Metrics
24
22
 
@@ -36,26 +34,6 @@ module Appsignal
36
34
  # @see Config
37
35
  attr_reader :config
38
36
 
39
- # Set the AppSignal config.
40
- #
41
- # @deprecated Use {Appsignal.configure} instead.
42
- # @param conf [Appsignal::Config]
43
- # @return [void]
44
- # @see Config
45
- def config=(conf)
46
- Appsignal::Utils::StdoutAndLoggerMessage.warning \
47
- "Configuring AppSignal with `Appsignal.config=` is deprecated. " \
48
- "Use `Appsignal.configure { |config| ... }` to configure AppSignal. " \
49
- "https://docs.appsignal.com/ruby/configuration.html\n" \
50
- "#{caller.first}"
51
- @config = conf
52
- end
53
-
54
- # @api private
55
- def _config=(conf)
56
- @config = conf
57
- end
58
-
59
37
  # Accessor for toggle if the AppSignal C-extension is loaded.
60
38
  #
61
39
  # Can be `nil` if extension has not been loaded yet. See
@@ -113,7 +91,17 @@ module Appsignal
113
91
  #
114
92
  # @return [void]
115
93
  # @since 0.7.0
116
- def start
94
+ def start # rubocop:disable Metrics/AbcSize
95
+ if ENV.fetch("_APPSIGNAL_DIAGNOSE", false)
96
+ internal_logger.warn("Skipping start in diagnose context")
97
+ return
98
+ end
99
+
100
+ if started?
101
+ internal_logger.warn("Ignoring call to Appsignal.start after AppSignal has started")
102
+ return
103
+ end
104
+
117
105
  unless extension_loaded?
118
106
  internal_logger.info("Not starting AppSignal, extension is not loaded")
119
107
  return
@@ -122,6 +110,7 @@ module Appsignal
122
110
  internal_logger.debug("Loading AppSignal gem")
123
111
 
124
112
  @config ||= Config.new(Config.determine_root_path, Config.determine_env)
113
+ @config.validate
125
114
 
126
115
  _start_logger
127
116
 
@@ -143,6 +132,7 @@ module Appsignal
143
132
  Appsignal::Probes.start if config[:enable_minutely_probes]
144
133
 
145
134
  collect_environment_metadata
135
+ @config.freeze
146
136
  else
147
137
  internal_logger.info("Not starting, not active for #{config.env}")
148
138
  end
@@ -251,20 +241,15 @@ module Appsignal
251
241
  @config = Config.new(
252
242
  root_path || Config.determine_root_path,
253
243
  Config.determine_env(env),
254
- {},
255
- Appsignal.internal_logger,
256
- nil,
257
- false
244
+ Appsignal.internal_logger
258
245
  )
259
- config.load_config
260
246
  end
261
247
 
262
248
  config_dsl = Appsignal::Config::ConfigDSL.new(config)
263
- if block_given?
264
- yield config_dsl
265
- config.merge_dsl_options(config_dsl.dsl_options)
266
- end
267
- config.validate
249
+ return unless block_given?
250
+
251
+ yield config_dsl
252
+ config.merge_dsl_options(config_dsl.dsl_options)
268
253
  end
269
254
 
270
255
  def forked
@@ -334,18 +319,6 @@ module Appsignal
334
319
  end
335
320
  end
336
321
 
337
- # @deprecated Only {.start} has to be called.
338
- # @return [void]
339
- # @since 0.7.0
340
- def start_logger
341
- callers = caller
342
- Appsignal::Utils::StdoutAndLoggerMessage.warning \
343
- "Calling 'Appsignal.start_logger' is deprecated. " \
344
- "The logger will be started when calling 'Appsignal.start'. " \
345
- "Remove the 'Appsignal.start_logger' call in the following file to " \
346
- "remove this message.\n#{callers.first}"
347
- end
348
-
349
322
  # Start the AppSignal internal logger.
350
323
  #
351
324
  # Sets the log level and sets the logger. Uses a file-based logger or the
@@ -449,36 +422,11 @@ module Appsignal
449
422
  end
450
423
  Appsignal::Environment.report_supported_gems
451
424
  end
452
-
453
- # Alias constants that have moved with a warning message that points to the
454
- # place to update the reference.
455
- def const_missing(name)
456
- case name
457
- when :Minutely
458
- callers = caller
459
- Appsignal::Utils::StdoutAndLoggerMessage.warning \
460
- "The constant Appsignal::Minutely has been deprecated. " \
461
- "Please update the constant name to Appsignal::Probes " \
462
- "in the following file to remove this message.\n#{callers.first}"
463
- Appsignal::Probes
464
- when :Heartbeat
465
- unless @heartbeat_constant_deprecation_warning_emitted
466
- callers = caller
467
- Appsignal::Utils::StdoutAndLoggerMessage.warning \
468
- "The constant Appsignal::Heartbeat has been deprecated. " \
469
- "Please update the constant name to Appsignal::CheckIn::Cron " \
470
- "in the following file and elsewhere to remove this message.\n#{callers.first}"
471
- @heartbeat_constant_deprecation_warning_emitted = true
472
- end
473
- Appsignal::CheckIn::Cron
474
- else
475
- super
476
- end
477
- end
478
425
  end
479
426
  end
480
427
 
481
428
  require "appsignal/loaders"
429
+ require "appsignal/sample_data"
482
430
  require "appsignal/environment"
483
431
  require "appsignal/system"
484
432
  require "appsignal/utils"
@@ -1,5 +1,5 @@
1
1
  describe Appsignal::AuthCheck do
2
- let(:config) { project_fixture_config }
2
+ let(:config) { build_config }
3
3
  let(:auth_check) { Appsignal::AuthCheck.new(config) }
4
4
  let(:auth_url) do
5
5
  query = build_uri_query_string(
@@ -6,7 +6,7 @@ if DependencyHelper.capistrano2_present?
6
6
  describe "Capistrano 2 integration" do
7
7
  let(:out_stream) { std_stream }
8
8
  let(:output) { out_stream.read }
9
- let(:config) { project_fixture_config }
9
+ let(:config) { build_config }
10
10
  let(:capistrano_config) do
11
11
  Capistrano::Configuration.new.tap do |c|
12
12
  c.set(:rails_env, "production")
@@ -5,7 +5,9 @@ if DependencyHelper.capistrano3_present?
5
5
 
6
6
  describe "Capistrano 3 integration" do
7
7
  let(:capistrano) { Class.new.extend(Capistrano::DSL) }
8
- let(:config) { project_fixture_config }
8
+ let(:env) { :production }
9
+ let(:options) { {} }
10
+ let(:config) { build_config(:env => env, :options => options) }
9
11
  let(:out_stream) { std_stream }
10
12
  let(:output) { out_stream.read }
11
13
  let(:logger) { Logger.new(out_stream) }
@@ -50,7 +52,7 @@ if DependencyHelper.capistrano3_present?
50
52
  end
51
53
 
52
54
  context "config" do
53
- let(:env) { "production" }
55
+ let(:options) { { :name => "AppName" } }
54
56
  before do
55
57
  capistrano_config.set(
56
58
  :appsignal_config,
@@ -58,9 +60,6 @@ if DependencyHelper.capistrano3_present?
58
60
  :active => true,
59
61
  :push_api_key => "abc"
60
62
  )
61
- config[:name] = "AppName"
62
- config.instance_variable_set(:@env, env)
63
- stub_marker_request.to_return(:status => 200)
64
63
  end
65
64
 
66
65
  context "when rack_env is the only env set" do
@@ -71,6 +70,11 @@ if DependencyHelper.capistrano3_present?
71
70
  end
72
71
 
73
72
  it "uses the rack_env as the env" do
73
+ stub_marker_request(
74
+ :environment => env.to_s,
75
+ :name => "AppName",
76
+ :push_api_key => "abc"
77
+ ).to_return(:status => 200)
74
78
  original_new = Appsignal::Marker.method(:new)
75
79
 
76
80
  expect(Appsignal::Marker).to receive(:new) do |data, given_config|
@@ -90,6 +94,11 @@ if DependencyHelper.capistrano3_present?
90
94
  end
91
95
 
92
96
  it "prefers the Capistrano stage rather than rails_env and rack_env" do
97
+ stub_marker_request(
98
+ :environment => env.to_s,
99
+ :name => "AppName",
100
+ :push_api_key => "abc"
101
+ ).to_return(:status => 200)
93
102
  original_new = Appsignal::Marker.method(:new)
94
103
 
95
104
  expect(Appsignal::Marker).to receive(:new) do |data, given_config|
@@ -104,15 +113,19 @@ if DependencyHelper.capistrano3_present?
104
113
  context "when `appsignal_config` is set" do
105
114
  before do
106
115
  ENV["APPSIGNAL_APP_NAME"] = "EnvName"
107
- capistrano_config.set(:appsignal_config, :name => "AppName")
108
- config[:name] = "AppName"
116
+ capistrano_config.set(:appsignal_config, :name => "CapName")
109
117
  end
110
118
 
111
119
  it "overrides the default config with the custom appsignal_config" do
120
+ stub_marker_request(
121
+ :environment => env.to_s,
122
+ :name => "CapName",
123
+ :push_api_key => "abc"
124
+ ).to_return(:status => 200)
112
125
  original_new = Appsignal::Marker.method(:new)
113
126
 
114
127
  expect(Appsignal::Marker).to receive(:new) do |data, given_config|
115
- expect(given_config[:name]).to eq("AppName")
128
+ expect(given_config[:name]).to eq("CapName")
116
129
  original_new.call(data, given_config)
117
130
  end
118
131
 
@@ -141,6 +154,11 @@ if DependencyHelper.capistrano3_present?
141
154
  end
142
155
 
143
156
  it "prefers the appsignal_env rather than stage, rails_env and rack_env" do
157
+ stub_marker_request(
158
+ :environment => env.to_s,
159
+ :name => "AppName",
160
+ :push_api_key => "abc"
161
+ ).to_return(:status => 200)
144
162
  original_new = Appsignal::Marker.method(:new)
145
163
 
146
164
  expect(Appsignal::Marker).to receive(:new) do |data, given_config|
@@ -156,7 +174,11 @@ if DependencyHelper.capistrano3_present?
156
174
  describe "markers" do
157
175
  context "when active for this environment" do
158
176
  it "transmits marker" do
159
- stub_marker_request.to_return(:status => 200)
177
+ stub_marker_request(
178
+ :environment => env.to_s,
179
+ :name => "TestApp",
180
+ :push_api_key => "abc"
181
+ ).to_return(:status => 200)
160
182
  run
161
183
 
162
184
  expect(output).to include \
@@ -168,7 +190,14 @@ if DependencyHelper.capistrano3_present?
168
190
  context "with overridden revision" do
169
191
  before do
170
192
  capistrano_config.set(:appsignal_revision, "abc123")
171
- stub_marker_request(:revision => "abc123").to_return(:status => 200)
193
+ stub_marker_request(
194
+ {
195
+ :environment => env.to_s,
196
+ :name => "TestApp",
197
+ :push_api_key => "abc"
198
+ },
199
+ :revision => "abc123"
200
+ ).to_return(:status => 200)
172
201
  run
173
202
  end
174
203
 
@@ -182,7 +211,14 @@ if DependencyHelper.capistrano3_present?
182
211
  context "with overridden deploy user" do
183
212
  before do
184
213
  capistrano_config.set(:appsignal_user, "robin")
185
- stub_marker_request(:user => "robin").to_return(:status => 200)
214
+ stub_marker_request(
215
+ {
216
+ :environment => env.to_s,
217
+ :name => "TestApp",
218
+ :push_api_key => "abc"
219
+ },
220
+ :user => "robin"
221
+ ).to_return(:status => 200)
186
222
  run
187
223
  end
188
224
 
@@ -209,7 +245,11 @@ if DependencyHelper.capistrano3_present?
209
245
 
210
246
  context "with failed request" do
211
247
  before do
212
- stub_marker_request.to_return(:status => 500)
248
+ stub_marker_request(
249
+ :environment => env.to_s,
250
+ :name => "TestApp",
251
+ :push_api_key => "abc"
252
+ ).to_return(:status => 500)
213
253
  run
214
254
  end
215
255
 
@@ -238,7 +278,7 @@ if DependencyHelper.capistrano3_present?
238
278
  end
239
279
  end
240
280
 
241
- def stub_marker_request(data = {})
281
+ def stub_marker_request(config = {}, data = {})
242
282
  stub_api_request config, "markers", marker_data.merge(data)
243
283
  end
244
284
  end
@@ -1,173 +1,6 @@
1
- describe Appsignal::Heartbeat do
2
- let(:err_stream) { std_stream }
3
-
4
- after do
5
- Appsignal.instance_variable_set(:@heartbeat_constant_deprecation_warning_emitted, false)
6
- end
7
-
8
- it "returns the Cron constant calling the Heartbeat constant" do
9
- silence { expect(Appsignal::Heartbeat).to be(Appsignal::CheckIn::Cron) }
10
- end
11
-
12
- it "prints a deprecation warning to STDERR" do
13
- capture_std_streams(std_stream, err_stream) do
14
- expect(Appsignal::Heartbeat).to be(Appsignal::CheckIn::Cron)
15
- end
16
-
17
- expect(err_stream.read)
18
- .to include("appsignal WARNING: The constant Appsignal::Heartbeat has been deprecated.")
19
- end
20
-
21
- it "does not print a deprecation warning to STDERR more than once" do
22
- capture_std_streams(std_stream, err_stream) do
23
- expect(Appsignal::Heartbeat).to be(Appsignal::CheckIn::Cron)
24
- end
25
-
26
- expect(err_stream.read)
27
- .to include("appsignal WARNING: The constant Appsignal::Heartbeat has been deprecated.")
28
-
29
- err_stream.truncate(0)
30
-
31
- capture_std_streams(std_stream, err_stream) do
32
- expect(Appsignal::Heartbeat).to be(Appsignal::CheckIn::Cron)
33
- end
34
-
35
- expect(err_stream.read)
36
- .not_to include("appsignal WARNING: The constant Appsignal::Heartbeat has been deprecated.")
37
- end
38
-
39
- it "logs a warning" do
40
- logs =
41
- capture_logs do
42
- silence do
43
- expect(Appsignal::Heartbeat).to be(Appsignal::CheckIn::Cron)
44
- end
45
- end
46
-
47
- expect(logs).to contains_log(
48
- :warn,
49
- "The constant Appsignal::Heartbeat has been deprecated."
50
- )
51
- end
52
-
53
- it "does not log a warning more than once" do
54
- logs =
55
- capture_logs do
56
- silence do
57
- expect(Appsignal::Heartbeat).to be(Appsignal::CheckIn::Cron)
58
- end
59
- end
60
-
61
- expect(logs).to contains_log(
62
- :warn,
63
- "The constant Appsignal::Heartbeat has been deprecated."
64
- )
65
-
66
- logs =
67
- capture_logs do
68
- silence do
69
- expect(Appsignal::Heartbeat).to be(Appsignal::CheckIn::Cron)
70
- end
71
- end
72
-
73
- expect(logs).not_to contains_log(
74
- :warn,
75
- "The constant Appsignal::Heartbeat has been deprecated."
76
- )
77
- end
78
- end
79
-
80
- describe "Appsignal.heartbeat" do
81
- let(:err_stream) { std_stream }
82
-
83
- before do
84
- Appsignal.instance_variable_set(:@heartbeat_helper_deprecation_warning_emitted, false)
85
- end
86
-
87
- it "should forward the call to Appsignal::CheckIn.cron" do
88
- expect(Appsignal::CheckIn).to receive(:cron).with("heartbeat-name")
89
- expect do
90
- Appsignal.heartbeat("heartbeat-name")
91
- end.not_to raise_error
92
-
93
- block = proc { 42 }
94
- expect(Appsignal::CheckIn).to receive(:cron).with("heartbeat-name") do |&given_block|
95
- expect(given_block).to be(block)
96
- end.and_return("output")
97
- expect(Appsignal.heartbeat("heartbeat-name", &block)).to eq("output")
98
- end
99
-
100
- it "prints a deprecation warning to STDERR" do
101
- capture_std_streams(std_stream, err_stream) do
102
- Appsignal.heartbeat("heartbeat-name")
103
- end
104
-
105
- expect(err_stream.read)
106
- .to include("appsignal WARNING: The helper Appsignal.heartbeat has been deprecated.")
107
- end
108
-
109
- it "does not print a deprecation warning to STDERR more than once" do
110
- capture_std_streams(std_stream, err_stream) do
111
- Appsignal.heartbeat("heartbeat-name")
112
- end
113
-
114
- expect(err_stream.read)
115
- .to include("appsignal WARNING: The helper Appsignal.heartbeat has been deprecated.")
116
-
117
- err_stream.truncate(0)
118
-
119
- capture_std_streams(std_stream, err_stream) do
120
- Appsignal.heartbeat("heartbeat-name")
121
- end
122
-
123
- expect(err_stream.read)
124
- .not_to include("appsignal WARNING: The helper Appsignal.heartbeat has been deprecated.")
125
- end
126
-
127
- it "logs a warning" do
128
- logs =
129
- capture_logs do
130
- silence do
131
- Appsignal.heartbeat("heartbeat-name")
132
- end
133
- end
134
-
135
- expect(logs).to contains_log(
136
- :warn,
137
- "The helper Appsignal.heartbeat has been deprecated."
138
- )
139
- end
140
-
141
- it "does not log a warning more than once" do
142
- logs =
143
- capture_logs do
144
- silence do
145
- Appsignal.heartbeat("heartbeat-name")
146
- end
147
- end
148
-
149
- expect(logs).to contains_log(
150
- :warn,
151
- "The helper Appsignal.heartbeat has been deprecated."
152
- )
153
-
154
- logs =
155
- capture_logs do
156
- silence do
157
- Appsignal.heartbeat("heartbeat-name")
158
- end
159
- end
160
-
161
- expect(logs).not_to contains_log(
162
- :warn,
163
- "The helper Appsignal.heartbeat has been deprecated."
164
- )
165
- end
166
- end
167
-
168
1
  describe Appsignal::CheckIn::Cron do
169
2
  let(:config) { project_fixture_config }
170
- let(:cron_checkin) { described_class.new(:name => "cron-checkin-name") }
3
+ let(:cron_checkin) { described_class.new(:identifier => "cron-checkin-name") }
171
4
  let(:transmitter) { Appsignal::Transmitter.new("http://cron_checkins/", config) }
172
5
 
173
6
  before(:each) do
@@ -300,43 +133,4 @@ describe Appsignal::CheckIn::Cron do
300
133
  end
301
134
  end
302
135
  end
303
-
304
- describe "#initialize" do
305
- describe "when initialised with deprecated heartbeat keyword names" do
306
- let(:err_stream) { std_stream }
307
-
308
- after do
309
- described_class.instance_variable_set(:@initializer_deprecation_warning_emitted, false)
310
- end
311
-
312
- it "can be initialised" do
313
- cron_checkin = described_class.new(:name => "cron-checkin-name")
314
- expect(cron_checkin.identifier).to eq("cron-checkin-name")
315
- end
316
-
317
- it "logs a deprecation warning" do
318
- capture_std_streams(std_stream, err_stream) do
319
- expect(described_class.new(:name => "cron-checkin-name"))
320
- .to be_a(Appsignal::CheckIn::Cron)
321
- end
322
-
323
- expect(err_stream.read)
324
- .to include(
325
- "appsignal WARNING: Passing a `name` keyword argument to " \
326
- "`Appsignal::CheckIn::Cron.new` is deprecated."
327
- )
328
- end
329
- end
330
-
331
- it "can be initialised with cron check-in keyword names" do
332
- cron_checkin = described_class.new(:identifier => "cron-checkin-name")
333
- expect(cron_checkin.identifier).to eq("cron-checkin-name")
334
- end
335
-
336
- it "raises an error when no identifier is given" do
337
- expect do
338
- described_class.new
339
- end.to raise_error(ArgumentError, "missing keyword: :identifier")
340
- end
341
- end
342
136
  end
@@ -7,12 +7,6 @@ describe Appsignal::CLI::Demo do
7
7
  let(:out_stream) { std_stream }
8
8
  let(:output) { out_stream.read }
9
9
  before(:context) { Appsignal.stop }
10
- before do
11
- ENV.delete("APPSIGNAL_APP_ENV")
12
- ENV.delete("RAILS_ENV")
13
- ENV.delete("RACK_ENV")
14
- stub_api_request config, "auth"
15
- end
16
10
 
17
11
  def run
18
12
  run_within_dir project_fixture_path
@@ -25,8 +19,6 @@ describe Appsignal::CLI::Demo do
25
19
  end
26
20
 
27
21
  context "without configuration" do
28
- let(:config) { Appsignal::Config.new("development", tmp_dir) }
29
-
30
22
  it "returns an error" do
31
23
  expect { run_within_dir tmp_dir }.to raise_error(SystemExit)
32
24
 
@@ -35,32 +27,20 @@ describe Appsignal::CLI::Demo do
35
27
  end
36
28
 
37
29
  context "with configuration" do
38
- let(:config) { project_fixture_config }
39
30
  before do
40
31
  # Ignore sleeps to speed up the test
41
32
  allow(Appsignal::Demo).to receive(:sleep)
42
33
  end
34
+ let(:options) { { :environment => "development" } }
43
35
 
44
- context "without environment" do
45
- it "returns an error" do
46
- expect { run_within_dir tmp_dir }.to raise_error(SystemExit)
47
-
48
- expect(output).to include("Error: Unable to start the AppSignal agent")
49
- end
36
+ it "calls Appsignal::Demo transmitter" do
37
+ expect(Appsignal::Demo).to receive(:transmit).and_return(true)
38
+ run
50
39
  end
51
40
 
52
- context "with environment" do
53
- let(:options) { { :environment => "development" } }
54
-
55
- it "calls Appsignal::Demo transmitter" do
56
- expect(Appsignal::Demo).to receive(:transmit).and_return(true)
57
- run
58
- end
59
-
60
- it "outputs message" do
61
- run
62
- expect(output).to include("Demonstration sample data sent!")
63
- end
41
+ it "outputs message" do
42
+ run
43
+ expect(output).to include("Demonstration sample data sent!")
64
44
  end
65
45
  end
66
46
  end