appsignal 3.13.0-java → 4.0.0.beta.1-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +499 -487
- data/CHANGELOG.md +113 -0
- data/Rakefile +31 -7
- data/benchmark.rake +4 -6
- data/build_matrix.yml +45 -39
- data/ext/agent.rb +27 -27
- data/ext/appsignal_extension.c +25 -0
- data/gemfiles/rails-7.2.gemfile +11 -0
- data/lib/appsignal/check_in/cron.rb +2 -15
- data/lib/appsignal/cli/diagnose.rb +37 -28
- data/lib/appsignal/cli/install.rb +5 -1
- data/lib/appsignal/config.rb +57 -119
- data/lib/appsignal/demo.rb +2 -2
- data/lib/appsignal/extension/jruby.rb +14 -0
- data/lib/appsignal/helpers/instrumentation.rb +139 -417
- data/lib/appsignal/helpers/metrics.rb +0 -16
- data/lib/appsignal/hooks/action_cable.rb +8 -8
- data/lib/appsignal/hooks/active_job.rb +2 -2
- data/lib/appsignal/hooks/at_exit.rb +37 -0
- data/lib/appsignal/hooks.rb +1 -16
- data/lib/appsignal/integrations/action_cable.rb +2 -2
- data/lib/appsignal/integrations/capistrano/appsignal.cap +2 -4
- data/lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb +1 -4
- data/lib/appsignal/integrations/delayed_job_plugin.rb +3 -3
- data/lib/appsignal/integrations/que.rb +2 -2
- data/lib/appsignal/integrations/railtie.rb +26 -59
- data/lib/appsignal/integrations/rake.rb +2 -2
- data/lib/appsignal/integrations/resque.rb +2 -2
- data/lib/appsignal/integrations/shoryuken.rb +4 -4
- data/lib/appsignal/integrations/sidekiq.rb +3 -3
- data/lib/appsignal/integrations/webmachine.rb +2 -2
- data/lib/appsignal/loaders.rb +1 -1
- data/lib/appsignal/probes.rb +0 -9
- data/lib/appsignal/rack/abstract_middleware.rb +4 -26
- data/lib/appsignal/rack/event_handler.rb +4 -4
- data/lib/appsignal/rack/rails_instrumentation.rb +1 -1
- data/lib/appsignal/rack.rb +0 -25
- data/lib/appsignal/sample_data.rb +95 -0
- data/lib/appsignal/transaction.rb +235 -361
- data/lib/appsignal/utils/rails_helper.rb +4 -0
- data/lib/appsignal/version.rb +1 -1
- data/lib/appsignal.rb +19 -71
- data/spec/lib/appsignal/auth_check_spec.rb +1 -1
- data/spec/lib/appsignal/capistrano2_spec.rb +1 -1
- data/spec/lib/appsignal/capistrano3_spec.rb +53 -13
- data/spec/lib/appsignal/check_in_spec.rb +1 -207
- data/spec/lib/appsignal/cli/demo_spec.rb +7 -27
- data/spec/lib/appsignal/cli/diagnose_spec.rb +145 -110
- data/spec/lib/appsignal/config_spec.rb +304 -379
- data/spec/lib/appsignal/extension_install_failure_spec.rb +5 -1
- data/spec/lib/appsignal/extension_spec.rb +5 -1
- data/spec/lib/appsignal/hooks/active_support_notifications/instrument_shared_examples.rb +1 -1
- data/spec/lib/appsignal/hooks/active_support_notifications/start_finish_shared_examples.rb +1 -2
- data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +1 -0
- data/spec/lib/appsignal/hooks/activejob_spec.rb +7 -12
- data/spec/lib/appsignal/hooks/at_exit_spec.rb +72 -0
- data/spec/lib/appsignal/hooks/gvl_spec.rb +10 -5
- data/spec/lib/appsignal/hooks/http_spec.rb +3 -3
- data/spec/lib/appsignal/hooks/net_http_spec.rb +3 -3
- data/spec/lib/appsignal/hooks/rake_spec.rb +6 -9
- data/spec/lib/appsignal/hooks/redis_client_spec.rb +5 -10
- data/spec/lib/appsignal/hooks/redis_spec.rb +4 -7
- data/spec/lib/appsignal/hooks/resque_spec.rb +3 -5
- data/spec/lib/appsignal/hooks_spec.rb +0 -41
- data/spec/lib/appsignal/integrations/data_mapper_spec.rb +29 -20
- data/spec/lib/appsignal/integrations/delayed_job_plugin_spec.rb +4 -9
- data/spec/lib/appsignal/integrations/railtie_spec.rb +179 -157
- data/spec/lib/appsignal/integrations/shoryuken_spec.rb +3 -5
- data/spec/lib/appsignal/integrations/sidekiq_spec.rb +48 -62
- data/spec/lib/appsignal/loaders/hanami_spec.rb +6 -9
- data/spec/lib/appsignal/loaders/padrino_spec.rb +6 -10
- data/spec/lib/appsignal/loaders/sinatra_spec.rb +6 -9
- data/spec/lib/appsignal/loaders_spec.rb +8 -1
- data/spec/lib/appsignal/marker_spec.rb +1 -1
- data/spec/lib/appsignal/probes_spec.rb +4 -83
- data/spec/lib/appsignal/rack/abstract_middleware_spec.rb +4 -63
- data/spec/lib/appsignal/rack/event_handler_spec.rb +18 -15
- data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +3 -11
- data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +4 -5
- data/spec/lib/appsignal/sample_data_spec.rb +174 -0
- data/spec/lib/appsignal/transaction_spec.rb +791 -1031
- data/spec/lib/appsignal/transmitter_spec.rb +6 -8
- data/spec/lib/appsignal_spec.rb +294 -643
- data/spec/spec_helper.rb +1 -3
- data/spec/support/fixtures/projects/valid/config/appsignal.yml +4 -7
- data/spec/support/fixtures/projects/valid_with_rails_app/config/application.rb +16 -0
- data/spec/support/fixtures/projects/valid_with_rails_app/config/appsignal.yml +56 -0
- data/spec/support/fixtures/projects/valid_with_rails_app/config/environment.rb +5 -0
- data/spec/support/helpers/api_request_helper.rb +3 -2
- data/spec/support/helpers/config_helpers.rb +41 -11
- data/spec/support/helpers/dependency_helper.rb +8 -0
- data/spec/support/helpers/log_helpers.rb +1 -0
- data/spec/support/helpers/rails_helper.rb +6 -6
- data/spec/support/helpers/transaction_helpers.rb +2 -24
- data/spec/support/matchers/transaction.rb +3 -3
- data/spec/support/mocks/appsignal_mock.rb +3 -3
- data/spec/support/mocks/mock_probe.rb +2 -0
- data/spec/support/testing.rb +2 -2
- metadata +12 -22
- data/gemfiles/que_beta.gemfile +0 -5
- data/lib/appsignal/helpers/heartbeat.rb +0 -20
- data/lib/appsignal/integrations/grape.rb +0 -35
- data/lib/appsignal/integrations/hanami.rb +0 -13
- data/lib/appsignal/integrations/padrino.rb +0 -13
- data/lib/appsignal/integrations/sinatra.rb +0 -13
- data/lib/appsignal/rack/generic_instrumentation.rb +0 -22
- data/lib/appsignal/rack/streaming_listener.rb +0 -28
- data/spec/lib/appsignal/integrations/grape_spec.rb +0 -36
- data/spec/lib/appsignal/integrations/hanami_spec.rb +0 -17
- data/spec/lib/appsignal/integrations/padrino_spec.rb +0 -15
- data/spec/lib/appsignal/integrations/sinatra_spec.rb +0 -15
- data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +0 -81
- data/spec/lib/appsignal/rack/streaming_listener_spec.rb +0 -69
- data/spec/support/fixtures/projects/valid/config/environments/development.rb +0 -0
- data/spec/support/fixtures/projects/valid/config/environments/production.rb +0 -0
- data/spec/support/fixtures/projects/valid/config/environments/test.rb +0 -0
- data/spec/support/rails/my_app.rb +0 -6
- /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
|
data/lib/appsignal/version.rb
CHANGED
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
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
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"
|
@@ -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) {
|
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(:
|
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(:
|
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 => "
|
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("
|
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
|
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(
|
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(
|
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
|
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(:
|
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
|
-
|
45
|
-
|
46
|
-
|
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
|
-
|
53
|
-
|
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
|